git.delta.rocks / unique-network / refs/commits / f66a1ba0392c

difftreelog

Add permission and zero transfer tests

Max Andreev2022-12-05parent: #98f7ab5.patch.diff
in: master

3 files changed

modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
before · tests/src/eth/fungible.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect, itEth, usingEthPlaygrounds} from './util';18import {IKeyringPair} from '@polkadot/types/types';1920describe('Fungible: Information getting', () => {21  let donor: IKeyringPair;22  let alice: IKeyringPair;2324  before(async function() {25    await usingEthPlaygrounds(async (helper, privateKey) => {26      donor = await privateKey({filename: __filename});27      [alice] = await helper.arrange.createAccounts([20n], donor);28    });29  });3031  itEth('totalSupply', async ({helper}) => {32    const caller = await helper.eth.createAccountWithBalance(donor);33    const collection = await helper.ft.mintCollection(alice);34    await collection.mint(alice, 200n);3536    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);37    const totalSupply = await contract.methods.totalSupply().call();38    expect(totalSupply).to.equal('200');39  });4041  itEth('balanceOf', async ({helper}) => {42    const caller = await helper.eth.createAccountWithBalance(donor);43    const collection = await helper.ft.mintCollection(alice);44    await collection.mint(alice, 200n, {Ethereum: caller});4546    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);47    const balance = await contract.methods.balanceOf(caller).call();48    expect(balance).to.equal('200');49  });50});5152describe('Fungible: Plain calls', () => {53  let donor: IKeyringPair;54  let alice: IKeyringPair;55  let owner: IKeyringPair;5657  before(async function() {58    await usingEthPlaygrounds(async (helper, privateKey) => {59      donor = await privateKey({filename: __filename});60      [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);61    });62  });6364  itEth('Can perform mint()', async ({helper}) => {65    const owner = await helper.eth.createAccountWithBalance(donor);66    const receiver = helper.eth.createAccount();67    const collection = await helper.ft.mintCollection(alice);68    await collection.addAdmin(alice, {Ethereum: owner});6970    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);71    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);7273    const result = await contract.methods.mint(receiver, 100).send();74    75    const event = result.events.Transfer;76    expect(event.address).to.equal(collectionAddress);77    expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');78    expect(event.returnValues.to).to.equal(receiver);79    expect(event.returnValues.value).to.equal('100');80  });8182  itEth('Can perform mintBulk()', async ({helper}) => {83    const owner = await helper.eth.createAccountWithBalance(donor);84    const bulkSize = 3;85    const receivers = [...new Array(bulkSize)].map(() => helper.eth.createAccount());86    const collection = await helper.ft.mintCollection(alice);87    await collection.addAdmin(alice, {Ethereum: owner});8889    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);90    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);9192    const result = await contract.methods.mintBulk(Array.from({length: bulkSize}, (_, i) => (93      [receivers[i], (i + 1) * 10]94    ))).send();95    const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.value - b.returnValues.value);96    for (let i = 0; i < bulkSize; i++) {97      const event = events[i];98      expect(event.address).to.equal(collectionAddress);99      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');100      expect(event.returnValues.to).to.equal(receivers[i]);101      expect(event.returnValues.value).to.equal(String(10 * (i + 1)));102    }103  });104105  // Soft-deprecated106  itEth('Can perform burn()', async ({helper}) => {107    const owner = await helper.eth.createAccountWithBalance(donor);108    const receiver = await helper.eth.createAccountWithBalance(donor);109    const collection = await helper.ft.mintCollection(alice);110    await collection.addAdmin(alice, {Ethereum: owner});111112    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);113    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);114    await contract.methods.mint(receiver, 100).send();115116    const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});117    118    const event = result.events.Transfer;119    expect(event.address).to.equal(collectionAddress);120    expect(event.returnValues.from).to.equal(receiver);121    expect(event.returnValues.to).to.equal('0x0000000000000000000000000000000000000000');122    expect(event.returnValues.value).to.equal('49');123124    const balance = await contract.methods.balanceOf(receiver).call();125    expect(balance).to.equal('51');126  });127128  itEth('Can perform approve()', async ({helper}) => {129    const owner = await helper.eth.createAccountWithBalance(donor);130    const spender = helper.eth.createAccount();131    const collection = await helper.ft.mintCollection(alice);132    await collection.mint(alice, 200n, {Ethereum: owner});133134    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);135    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);136137    {138      const result = await contract.methods.approve(spender, 100).send({from: owner});139140      const event = result.events.Approval;141      expect(event.address).to.be.equal(collectionAddress);142      expect(event.returnValues.owner).to.be.equal(owner);143      expect(event.returnValues.spender).to.be.equal(spender);144      expect(event.returnValues.value).to.be.equal('100');145    }146147    {148      const allowance = await contract.methods.allowance(owner, spender).call();149      expect(+allowance).to.equal(100);150    }151  });152153  itEth('Can perform burnFromCross()', async ({helper}) => {154    const sender = await helper.eth.createAccountWithBalance(donor, 100n);155156    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);157158    await collection.mint(owner, 200n, {Substrate: owner.address});159    await collection.approveTokens(owner, {Ethereum: sender}, 100n);160161    const address = helper.ethAddress.fromCollectionId(collection.collectionId);162    const contract = helper.ethNativeContract.collection(address, 'ft');163164    const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});165    166    const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);167    const result = await contract.methods.burnFromCross(ownerCross, 49).send({from: sender});168    const events = result.events;169170    expect(events).to.be.like({171      Transfer: {172        address: helper.ethAddress.fromCollectionId(collection.collectionId),173        event: 'Transfer',174        returnValues: {175          from: helper.address.substrateToEth(owner.address),176          to: '0x0000000000000000000000000000000000000000',177          value: '49',178        },179      },180      Approval: {181        address: helper.ethAddress.fromCollectionId(collection.collectionId),182        returnValues: {183          owner: helper.address.substrateToEth(owner.address),184          spender: sender,185          value: '51',186        },187        event: 'Approval',188      },189    });190191    const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});192    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(49n);193  });194195  itEth('Can perform transferFrom()', async ({helper}) => {196    const owner = await helper.eth.createAccountWithBalance(donor);197    const spender = await helper.eth.createAccountWithBalance(donor);198    const receiver = helper.eth.createAccount();199    const collection = await helper.ft.mintCollection(alice);200    await collection.mint(alice, 200n, {Ethereum: owner});201202    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);203    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);204205    await contract.methods.approve(spender, 100).send();206207    {208      const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: spender});209      210      let event = result.events.Transfer;211      expect(event.address).to.be.equal(collectionAddress);212      expect(event.returnValues.from).to.be.equal(owner);213      expect(event.returnValues.to).to.be.equal(receiver);214      expect(event.returnValues.value).to.be.equal('49');215216      event = result.events.Approval;217      expect(event.address).to.be.equal(collectionAddress);218      expect(event.returnValues.owner).to.be.equal(owner);219      expect(event.returnValues.spender).to.be.equal(spender);220      expect(event.returnValues.value).to.be.equal('51');221    }222223    {224      const balance = await contract.methods.balanceOf(receiver).call();225      expect(+balance).to.equal(49);226    }227228    {229      const balance = await contract.methods.balanceOf(owner).call();230      expect(+balance).to.equal(151);231    }232  });233234  itEth('Can perform transferCross()', async ({helper}) => {235    const sender = await helper.eth.createAccountWithBalance(donor);236    const receiverEth = await helper.eth.createAccountWithBalance(donor);237    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);238    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(donor);239    const collection = await helper.ft.mintCollection(alice);240    await collection.mint(alice, 200n, {Ethereum: sender});241242    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);243    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);244245    {246      // Can transferCross to ethereum address:247      const result = await collectionEvm.methods.transferCross(receiverCrossEth, 50).send({from: sender});248      // Check events:249      const event = result.events.Transfer;250      expect(event.address).to.be.equal(collectionAddress);251      expect(event.returnValues.from).to.be.equal(sender);252      expect(event.returnValues.to).to.be.equal(receiverEth);253      expect(event.returnValues.value).to.be.equal('50');254      // Sender's balance decreased:255      const ownerBalance = await collectionEvm.methods.balanceOf(sender).call();256      expect(+ownerBalance).to.equal(150);257      // Receiver's balance increased:258      const receiverBalance = await collectionEvm.methods.balanceOf(receiverEth).call();259      expect(+receiverBalance).to.equal(50);260    }261    262    {263      // Can transferCross to substrate address:264      const result = await collectionEvm.methods.transferCross(receiverCrossSub, 50).send({from: sender});265      // Check events:266      const event = result.events.Transfer;267      expect(event.address).to.be.equal(collectionAddress);268      expect(event.returnValues.from).to.be.equal(sender);269      expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(donor.address));270      expect(event.returnValues.value).to.be.equal('50');271      // Sender's balance decreased:272      const senderBalance = await collection.getBalance({Ethereum: sender});273      expect(senderBalance).to.equal(100n);274      // Receiver's balance increased:275      const balance = await collection.getBalance({Substrate: donor.address});276      expect(balance).to.equal(50n);277    }278  });279280  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;286287    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);291292    await expect(collectionEvm.methods.transferCross(receiverCrossEth, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;293  });294  295  itEth('Can perform transfer()', async ({helper}) => {296    const owner = await helper.eth.createAccountWithBalance(donor);297    const receiver = await helper.eth.createAccountWithBalance(donor);298    const collection = await helper.ft.mintCollection(alice);299    await collection.mint(alice, 200n, {Ethereum: owner});300301    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);302    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);303304    {305      const result = await contract.methods.transfer(receiver, 50).send({from: owner});306      307      const event = result.events.Transfer;308      expect(event.address).to.be.equal(collectionAddress);309      expect(event.returnValues.from).to.be.equal(owner);310      expect(event.returnValues.to).to.be.equal(receiver);311      expect(event.returnValues.value).to.be.equal('50');312    }313314    {315      const balance = await contract.methods.balanceOf(owner).call();316      expect(+balance).to.equal(150);317    }318319    {320      const balance = await contract.methods.balanceOf(receiver).call();321      expect(+balance).to.equal(50);322    }323  });324325  itEth('Can perform transferFromCross()', async ({helper}) => {326    const sender = await helper.eth.createAccountWithBalance(donor, 100n);327328    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);329330    const receiver = helper.eth.createAccount();331332    await collection.mint(owner, 200n, {Substrate: owner.address});333    await collection.approveTokens(owner, {Ethereum: sender}, 100n);334335    const address = helper.ethAddress.fromCollectionId(collection.collectionId);336    const contract = helper.ethNativeContract.collection(address, 'ft');337338    const from = helper.ethCrossAccount.fromKeyringPair(owner);339    const to = helper.ethCrossAccount.fromAddress(receiver);340341    const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});342    const toBalanceBefore = await collection.getBalance({Ethereum: receiver});343    344    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});345346    expect(result.events).to.be.like({347      Transfer: {348        address,349        event: 'Transfer',350        returnValues: {351          from: helper.address.substrateToEth(owner.address),352          to: receiver,353          value: '51',354        },355      },356      Approval: {357        address,358        event: 'Approval',359        returnValues: {360          owner: helper.address.substrateToEth(owner.address),361          spender: sender,362          value: '49',363        },364      }});365366    const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});367    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(51n);368    const toBalanceAfter = await collection.getBalance({Ethereum: receiver});369    expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);370  });371});372373describe('Fungible: Fees', () => {374  let donor: IKeyringPair;375  let alice: IKeyringPair;376377  before(async function() {378    await usingEthPlaygrounds(async (helper, privateKey) => {379      donor = await privateKey({filename: __filename});380      [alice] = await helper.arrange.createAccounts([20n], donor);381    });382  });383  384  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {385    const owner = await helper.eth.createAccountWithBalance(donor);386    const spender = helper.eth.createAccount();387    const collection = await helper.ft.mintCollection(alice);388    await collection.mint(alice, 200n, {Ethereum: owner});389390    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);391    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);392393    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));394    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));395  });396397  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {398    const owner = await helper.eth.createAccountWithBalance(donor);399    const spender = await helper.eth.createAccountWithBalance(donor);400    const collection = await helper.ft.mintCollection(alice);401    await collection.mint(alice, 200n, {Ethereum: owner});402403    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);404    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);405406    await contract.methods.approve(spender, 100).send({from: owner});407408    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, 100).send({from: spender}));409    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));410  });411412  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {413    const owner = await helper.eth.createAccountWithBalance(donor);414    const receiver = helper.eth.createAccount();415    const collection = await helper.ft.mintCollection(alice);416    await collection.mint(alice, 200n, {Ethereum: owner});417418    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);419    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);420421    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));422    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));423  });424});425426describe('Fungible: Substrate calls', () => {427  let donor: IKeyringPair;428  let alice: IKeyringPair;429  let owner: IKeyringPair;430431  before(async function() {432    await usingEthPlaygrounds(async (helper, privateKey) => {433      donor = await privateKey({filename: __filename});434      [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);435    });436  });437438  itEth('Events emitted for approve()', async ({helper}) => {439    const receiver = helper.eth.createAccount();440    const collection = await helper.ft.mintCollection(alice);441    await collection.mint(alice, 200n);442443    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);444    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft');445446    const events: any = [];447    contract.events.allEvents((_: any, event: any) => {448      events.push(event);449    });450    451    await collection.approveTokens(alice, {Ethereum: receiver}, 100n);452    if (events.length == 0) await helper.wait.newBlocks(1);453    const event = events[0];454455    expect(event.event).to.be.equal('Approval');456    expect(event.address).to.be.equal(collectionAddress);457    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));458    expect(event.returnValues.spender).to.be.equal(receiver);459    expect(event.returnValues.value).to.be.equal('100');460  });461462  itEth('Events emitted for transferFrom()', async ({helper}) => {463    const [bob] = await helper.arrange.createAccounts([10n], donor);464    const receiver = helper.eth.createAccount();465    const collection = await helper.ft.mintCollection(alice);466    await collection.mint(alice, 200n);467    await collection.approveTokens(alice, {Substrate: bob.address}, 100n);468469    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);470    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft');471472    const events: any = [];473    contract.events.allEvents((_: any, event: any) => {474      events.push(event);475    });476477    await collection.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver}, 51n);478    if (events.length == 0) await helper.wait.newBlocks(1);479    let event = events[0];480481    expect(event.event).to.be.equal('Transfer');482    expect(event.address).to.be.equal(collectionAddress);483    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));484    expect(event.returnValues.to).to.be.equal(receiver);485    expect(event.returnValues.value).to.be.equal('51');486487    event = events[1];488    expect(event.event).to.be.equal('Approval');489    expect(event.address).to.be.equal(collectionAddress);490    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));491    expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(bob.address));492    expect(event.returnValues.value).to.be.equal('49');493  });494495  itEth('Events emitted for transfer()', async ({helper}) => {496    const receiver = helper.eth.createAccount();497    const collection = await helper.ft.mintCollection(alice);498    await collection.mint(alice, 200n);499500    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);501    const contract = helper.ethNativeContract.collection(collectionAddress, 'ft');502503    const events: any = [];504    contract.events.allEvents((_: any, event: any) => {505      events.push(event);506    });507    508    await collection.transfer(alice, {Ethereum:receiver}, 51n);509    if (events.length == 0) await helper.wait.newBlocks(1);510    const event = events[0];511512    expect(event.event).to.be.equal('Transfer');513    expect(event.address).to.be.equal(collectionAddress);514    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));515    expect(event.returnValues.to).to.be.equal(receiver);516    expect(event.returnValues.value).to.be.equal('51');517  });518519  itEth('Events emitted for transferFromCross()', async ({helper}) => {520    const sender = await helper.eth.createAccountWithBalance(donor, 100n);521522    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);523524    const receiver = helper.eth.createAccount();525526    await collection.mint(owner, 200n, {Substrate: owner.address});527    await collection.approveTokens(owner, {Ethereum: sender}, 100n);528529    const address = helper.ethAddress.fromCollectionId(collection.collectionId);530    const contract = helper.ethNativeContract.collection(address, 'ft');531532    const from = helper.ethCrossAccount.fromKeyringPair(owner);533    const to = helper.ethCrossAccount.fromAddress(receiver);534    535    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});536537    expect(result.events).to.be.like({538      Transfer: {539        address,540        event: 'Transfer',541        returnValues: {542          from: helper.address.substrateToEth(owner.address),543          to: receiver,544          value: '51',545        },546      },547      Approval: {548        address,549        event: 'Approval',550        returnValues: {551          owner: helper.address.substrateToEth(owner.address),552          spender: sender,553          value: '49',554        },555      }});556  });557});
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -517,6 +517,26 @@
       expect(receiverBalance).to.contain(tokenId);
     }
   });
+
+  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {
+    const sender = await helper.eth.createAccountWithBalance(donor);
+    const tokenOwner = await helper.eth.createAccountWithBalance(donor);
+    const receiverSub = minter;
+    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);
+
+    const collection = await helper.nft.mintCollection(minter, {});
+    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', sender);
+
+    await collection.mintToken(minter, {Ethereum: sender});
+    const nonSendersToken = await collection.mintToken(minter, {Ethereum: tokenOwner});
+
+    // Cannot transferCross someone else's token:
+    const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;
+    await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;
+    // Cannot transfer token if it does not exist:
+    await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;
+  }));
 });
 
 describe('NFT: Fees', () => {
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -413,9 +413,10 @@
     }
   });
 
-  itEth.skip('Cannot transferCross with invalid params', async ({helper}) => {
+  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {
     const sender = await helper.eth.createAccountWithBalance(donor);
     const tokenOwner = await helper.eth.createAccountWithBalance(donor);
+    const receiverSub = minter;
     const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);
 
     const collection = await helper.rft.mintCollection(minter, {});
@@ -423,12 +424,14 @@
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);
 
     await collection.mintToken(minter, 50n, {Ethereum: sender});
-    const notSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});
+    const nonSendersToken = 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;
-  });
+    const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;
+    await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;
+    // Cannot transfer token if it does not exist:
+    await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;
+  }));
 
   itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);