difftreelog
Add regungible burn test and fix fungible zero transfer test
in: master
2 files changed
tests/src/burnItem.test.tsdiffbeforeafterboth140 await expect(token.burn(bob)).to.be.rejectedWith('common.NoPermission');140 await expect(token.burn(bob)).to.be.rejectedWith('common.NoPermission');141 });141 });142143 itSub('RFT: cannot burn non-owned token pieces', async ({helper}) => {144 const collection = await helper.rft.mintCollection(alice);145 const aliceToken = await collection.mintToken(alice, 10n, {Substrate: alice.address});146 const bobToken = await collection.mintToken(alice, 10n, {Substrate: bob.address});147148 // 1. Cannot burn non-owned token:149 await expect(bobToken.burn(alice, 0n)).to.be.rejectedWith('common.TokenValueTooLow');150 await expect(bobToken.burn(alice, 5n)).to.be.rejectedWith('common.TokenValueTooLow');151 // 2. Cannot burn non-existing token:152 await expect(helper.rft.burnToken(alice, 99999, 10)).to.be.rejectedWith('common.CollectionNotFound');153 await expect(helper.rft.burnToken(alice, collection.collectionId, 99999)).to.be.rejectedWith('common.TokenValueTooLow');154 // 3. Can burn zero amount of owned tokens (EIP-20)155 await aliceToken.burn(alice, 0n);156157 // 4. Storage is not corrupted:158 expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);159 expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);160161 // 4.1 Tokens can be transfered:162 await aliceToken.transfer(alice, {Substrate: bob.address}, 10n);163 await bobToken.transfer(bob, {Substrate: alice.address}, 10n);164 expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);165 expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);166 });142167143 itSub('Transfer a burned token', async ({helper}) => {168 itSub('Transfer a burned token', async ({helper}) => {144 const collection = await helper.nft.mintCollection(alice);169 const collection = await helper.nft.mintCollection(alice);tests/src/fungible.test.tsdiffbeforeafterboth--- a/tests/src/fungible.test.ts
+++ b/tests/src/fungible.test.ts
@@ -166,18 +166,18 @@
const nonExistingCollection = helper.ft.getCollectionObject(99999);
await collection.mint(alice, 10n, {Substrate: bob.address});
- // 1. Alice cannot transfer Bob's token:
- await expect(collection.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
+ // 1. Alice cannot transfer more than 0 tokens if balance low:
await expect(collection.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
- await expect(collection.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejectedWith('common.TokenValueTooLow');
await expect(collection.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejectedWith('common.TokenValueTooLow');
// 2. Alice cannot transfer non-existing token:
await expect(nonExistingCollection.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.CollectionNotFound');
await expect(nonExistingCollection.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.CollectionNotFound');
-
+
// 3. Zero transfer allowed (EIP-20):
await collection.transfer(bob, {Substrate: charlie.address}, 0n);
+ // 3.1 even if the balance = 0
+ await collection.transfer(alice, {Substrate: charlie.address}, 0n);
expect(await collection.getBalance({Substrate: alice.address})).to.eq(0n);
expect(await collection.getBalance({Substrate: bob.address})).to.eq(10n);