difftreelog
Fix test. Change source of pieces info.
in: master
2 files changed
pallets/refungible/src/lib.rsdiffbeforeafterboth712 }712 }713713714 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> u128 {714 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> u128 {715 // Not "try_fold" because total count of pieces is limited by 'MAX_REFUNGIBLE_PIECES'.716 <Balance<T>>::iter_prefix((collection_id, token_id)).fold(0, |total, piece| total + piece.1)715 <TotalSupply<T>>::get((collection_id, token_id))717 }716 }718}717}719718tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -68,6 +68,27 @@
});
});
+ it.only('Check total pieces of token', async () => {
+ await usingApi(async api => {
+ const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
+ expect(createCollectionResult.success).to.be.true;
+ const collectionId = createCollectionResult.collectionId;
+ const amountPieces = 100n;
+ const result = await createRefungibleToken(api, alice, collectionId, amountPieces);
+ expect(result.success).to.be.true;
+ {
+ const totalPieces = await api.rpc.unique.totalPieces(collectionId, result.itemId);
+ expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
+ }
+
+ await transfer(api, collectionId, result.itemId, alice, bob, 60n);
+ {
+ const totalPieces = await api.rpc.unique.totalPieces(collectionId, result.itemId);
+ expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
+ }
+ });
+ });
+
it('Transfer token pieces', async () => {
await usingApi(async api => {
const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;