git.delta.rocks / unique-network / refs/commits / 231aa66d6048

difftreelog

Add more transferCross tests

Max Andreev2022-12-02parent: #3509456.patch.diff
in: master

2 files changed

modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -276,6 +276,21 @@
       expect(balance).to.equal(50n);
     }
   });
+
+  itEth('Cannot transferCross() more than have', async ({helper}) => {
+    const sender = await helper.eth.createAccountWithBalance(donor);
+    const receiverEth = await helper.eth.createAccountWithBalance(donor);
+    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);
+    const BALANCE = 200n;
+    const BALANCE_TO_TRANSFER = BALANCE + 100n;
+
+    const collection = await helper.ft.mintCollection(alice);
+    await collection.mint(alice, BALANCE, {Ethereum: sender});
+    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);
+
+    await expect(collectionEvm.methods.transferCross(receiverCrossEth, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;
+  });
   
   itEth('Can perform transfer()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
415415
416 itEth('Cannot transferCross with invalid params', async ({helper}) => {416 itEth('Cannot transferCross with invalid params', 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 receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);419 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);
419420
420 const collection = await helper.rft.mintCollection(minter, {});421 const collection = await helper.rft.mintCollection(minter, {});
421 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);422 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
422 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);423 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);
423424
425 await collection.mintToken(minter, 50n, {Ethereum: sender});
424 const {tokenId} = await collection.mintToken(minter, 50n, {Ethereum: sender});426 const notSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});
425 // FIXME (transaction successful): Cannot transfer token if it does not exist:427 // Cannot transferCross someone else's token:
426 await expect(collectionEvm.methods.transferCross(receiverCrossSub, tokenId + 1).send({from: sender})).to.be.rejected;428 await expect(collectionEvm.methods.transferCross(receiverCrossSub, notSendersToken.tokenId).send({from: sender})).to.be.rejected;
429 // FIXME: (transaction successful): Cannot transfer token if it does not exist:
430 await expect(collectionEvm.methods.transferCross(receiverCrossSub, 999999).send({from: sender})).to.be.rejected;
427 });431 });
428432
429 itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {433 itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {