difftreelog
Add permission and zero transfer tests
in: master
3 files changed
tests/src/eth/fungible.test.tsdiffbeforeafterboth277 }277 }278 });278 });279279280 itEth('Cannot transferCross() more than have', async ({helper}) => {280 ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} incorrect amount`, async ({helper}) => {281 const sender = await helper.eth.createAccountWithBalance(donor);281 const sender = await helper.eth.createAccountWithBalance(donor);282 const receiverEth = await helper.eth.createAccountWithBalance(donor);282 const receiverEth = await helper.eth.createAccountWithBalance(donor);283 const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);283 const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);289 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);289 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);290 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);290 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);291291292 // 1. Cannot transfer more than have293 const receiver = testCase === 'transfer' ? receiverEth : receiverCrossEth;292 await expect(collectionEvm.methods.transferCross(receiverCrossEth, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;294 await expect(collectionEvm.methods[testCase](receiver, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;295 // 2. Zero transfer not allowed296 await expect(collectionEvm.methods[testCase](receiver, 0n).send({from: sender})).to.be.rejected;293 });297 }));294 298 299 295 itEth('Can perform transfer()', async ({helper}) => {300 itEth('Can perform transfer()', async ({helper}) => {tests/src/eth/nonFungible.test.tsdiffbeforeafterboth518 }518 }519 });519 });520521 ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {522 const sender = await helper.eth.createAccountWithBalance(donor);523 const tokenOwner = await helper.eth.createAccountWithBalance(donor);524 const receiverSub = minter;525 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);526527 const collection = await helper.nft.mintCollection(minter, {});528 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);529 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', sender);530531 await collection.mintToken(minter, {Ethereum: sender});532 const nonSendersToken = await collection.mintToken(minter, {Ethereum: tokenOwner});533534 // Cannot transferCross someone else's token:535 const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;536 await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;537 // Cannot transfer token if it does not exist:538 await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;539 }));520});540});521541522describe('NFT: Fees', () => {542describe('NFT: Fees', () => {tests/src/eth/reFungible.test.tsdiffbeforeafterboth413 }413 }414 });414 });415415416 itEth.skip('Cannot transferCross with invalid params', async ({helper}) => {416 ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {417 const sender = await helper.eth.createAccountWithBalance(donor);417 const sender = await helper.eth.createAccountWithBalance(donor);418 const tokenOwner = await helper.eth.createAccountWithBalance(donor);418 const tokenOwner = await helper.eth.createAccountWithBalance(donor);419 const receiverSub = minter;419 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);420 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);420421421 const collection = await helper.rft.mintCollection(minter, {});422 const collection = await helper.rft.mintCollection(minter, {});422 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);423 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);423 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);424 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);424425425 await collection.mintToken(minter, 50n, {Ethereum: sender});426 await collection.mintToken(minter, 50n, {Ethereum: sender});426 const notSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});427 const nonSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});428427 // Cannot transferCross someone else's token:429 // Cannot transferCross someone else's token:430 const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;428 await expect(collectionEvm.methods.transferCross(receiverCrossSub, notSendersToken.tokenId).send({from: sender})).to.be.rejected;431 await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;429 // FIXME: (transaction successful): Cannot transfer token if it does not exist:432 // Cannot transfer token if it does not exist:430 await expect(collectionEvm.methods.transferCross(receiverCrossSub, 999999).send({from: sender})).to.be.rejected;433 await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;431 });434 }));432435433 itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {436 itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {434 const caller = await helper.eth.createAccountWithBalance(donor);437 const caller = await helper.eth.createAccountWithBalance(donor);