From d0fe2e949cad15a5e5605d0f5f0516cfdf119e80 Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Tue, 06 Dec 2022 13:25:00 +0000 Subject: [PATCH] Fix tests: Zero transfer allowed (EIP-20) --- --- a/tests/src/eth/fungible.test.ts +++ b/tests/src/eth/fungible.test.ts @@ -292,8 +292,8 @@ // 1. Cannot transfer more than have const receiver = testCase === 'transfer' ? receiverEth : receiverCrossEth; await expect(collectionEvm.methods[testCase](receiver, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected; - // 2. Zero transfer not allowed - await expect(collectionEvm.methods[testCase](receiver, 0n).send({from: sender})).to.be.rejected; + // 2. Zero transfer allowed (EIP-20): + await collectionEvm.methods[testCase](receiver, 0n).send({from: sender}); })); --- a/tests/src/fungible.test.ts +++ b/tests/src/fungible.test.ts @@ -167,7 +167,7 @@ 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.ZeroTransferNotAllowed'); + await expect(collection.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow'); 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'); @@ -176,8 +176,8 @@ 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 not allowed: - await expect(collection.transfer(bob, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.ZeroTransferNotAllowed'); + // 3. Zero transfer allowed (EIP-20): + await collection.transfer(bob, {Substrate: charlie.address}, 0n); expect(await collection.getBalance({Substrate: alice.address})).to.eq(0n); expect(await collection.getBalance({Substrate: bob.address})).to.eq(10n); --- a/tests/src/refungible.test.ts +++ b/tests/src/refungible.test.ts @@ -276,17 +276,17 @@ const tokenBob = await collection.mintToken(alice, 10n, {Substrate: bob.address}); // 1. Alice cannot transfer Bob's token: - await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejected; - await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejected; - await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejected; - await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejected; + await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow'); + await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow'); + await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejectedWith('common.TokenValueTooLow'); + await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejectedWith('common.TokenValueTooLow'); // 2. Alice cannot transfer non-existing token: - await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 0n)).to.be.rejected; - await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 1n)).to.be.rejected; + await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow'); + await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow'); - // 3. Zero transfer not allowed: - await expect(tokenAlice.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.ZeroTransferNotAllowed'); + // 3. Zero transfer allowed (EIP-20): + await tokenAlice.transfer(alice, {Substrate: charlie.address}, 0n); expect(await tokenAlice.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]); expect(await tokenBob.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]); -- gitstuff