git.delta.rocks / unique-network / refs/commits / 2d796dacac37

difftreelog

Fix test. Change source of pieces info.

Trubnikov Sergey2022-06-30parent: #860bb39.patch.diff
in: master

2 files changed

modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -712,7 +712,6 @@
 	}
 
 	fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> u128 {
-		// Not "try_fold" because total count of pieces is limited by 'MAX_REFUNGIBLE_PIECES'.
-		<Balance<T>>::iter_prefix((collection_id, token_id)).fold(0, |total, piece| total + piece.1)
+		<TotalSupply<T>>::get((collection_id, token_id))
 	}
 }
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
68 });68 });
69 });69 });
70
71 it.only('Check total pieces of token', async () => {
72 await usingApi(async api => {
73 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
74 expect(createCollectionResult.success).to.be.true;
75 const collectionId = createCollectionResult.collectionId;
76 const amountPieces = 100n;
77 const result = await createRefungibleToken(api, alice, collectionId, amountPieces);
78 expect(result.success).to.be.true;
79 {
80 const totalPieces = await api.rpc.unique.totalPieces(collectionId, result.itemId);
81 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
82 }
83
84 await transfer(api, collectionId, result.itemId, alice, bob, 60n);
85 {
86 const totalPieces = await api.rpc.unique.totalPieces(collectionId, result.itemId);
87 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
88 }
89 });
90 });
7091
71 it('Transfer token pieces', async () => {92 it('Transfer token pieces', async () => {
72 await usingApi(async api => {93 await usingApi(async api => {