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
277 }277 }
278 });278 });
279 279
280 itEth('Cannot transferCross() more than have', async ({helper}) => {
281 const sender = await helper.eth.createAccountWithBalance(donor);
282 const receiverEth = await helper.eth.createAccountWithBalance(donor);
283 const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);
284 const BALANCE = 200n;
285 const BALANCE_TO_TRANSFER = BALANCE + 100n;
286
287 const collection = await helper.ft.mintCollection(alice);
288 await collection.mint(alice, BALANCE, {Ethereum: sender});
289 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
290 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);
291
292 await expect(collectionEvm.methods.transferCross(receiverCrossEth, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;
293 });
294
280 itEth('Can perform transfer()', async ({helper}) => {295 itEth('Can perform transfer()', async ({helper}) => {
281 const owner = await helper.eth.createAccountWithBalance(donor);296 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -415,15 +415,19 @@
 
   itEth('Cannot transferCross with invalid params', async ({helper}) => {
     const sender = await helper.eth.createAccountWithBalance(donor);
+    const tokenOwner = await helper.eth.createAccountWithBalance(donor);
     const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);
 
     const collection = await helper.rft.mintCollection(minter, {});
     const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);
 
-    const {tokenId} = await collection.mintToken(minter, 50n, {Ethereum: sender});
-    // FIXME (transaction successful): Cannot transfer token if it does not exist:
-    await expect(collectionEvm.methods.transferCross(receiverCrossSub, tokenId + 1).send({from: sender})).to.be.rejected;
+    await collection.mintToken(minter, 50n, {Ethereum: sender});
+    const notSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});
+    // Cannot transferCross someone else's token:
+    await expect(collectionEvm.methods.transferCross(receiverCrossSub, notSendersToken.tokenId).send({from: sender})).to.be.rejected;
+    // FIXME: (transaction successful): Cannot transfer token if it does not exist:
+    await expect(collectionEvm.methods.transferCross(receiverCrossSub, 999999).send({from: sender})).to.be.rejected;
   });
 
   itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {