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

difftreelog

Add call-methods checks

Max Andreev2022-12-22parent: #7d30844.patch.diff
in: master

6 files changed

modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -62,6 +62,8 @@
       expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossSub).call()).to.be.false;
       expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossEth).call()).to.be.false;
       expect(await collectionEvm.methods.isOwnerOrAdminCross(helper.ethCrossAccount.fromAddress(adminDeprecated)).call()).to.be.false;
+      expect(await collectionEvm.methods.collectionAdmins().call()).to.be.like([]);
+
       
       // Soft-deprecated: can addCollectionAdmin 
       await collectionEvm.methods.addCollectionAdmin(adminDeprecated).send();
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -101,11 +101,13 @@
       expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
   
       await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
+      let sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
+      expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor));
       expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
   
       await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
   
-      const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
+      sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
       expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');
     }));
 
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -18,7 +18,7 @@
 import {evmToAddress} from '@polkadot/util-crypto';
 import {Pallets, requirePalletsOrSkip} from '../util';
 import {expect, itEth, usingEthPlaygrounds} from './util';
-import { CollectionLimits } from './util/playgrounds/types';
+import {CollectionLimits} from './util/playgrounds/types';
 
 const DECIMALS = 18;
 
@@ -32,6 +32,7 @@
     });
   });
   
+  // TODO move sponsorship tests to another file:
   // Soft-deprecated
   itEth('[eth] Set sponsorship', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
@@ -91,6 +92,11 @@
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
+    
+    // check collectionOwner:
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
+    const collectionOwner = await collectionEvm.methods.collectionOwner().call();
+    expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));
   });
   
   itEth('destroyCollection', async ({helper}) => {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -132,6 +132,11 @@
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
+
+    // check collectionOwner:
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
+    const collectionOwner = await collectionEvm.methods.collectionOwner().call();
+    expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));
   });
 });
 
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
before · tests/src/eth/createRFTCollection.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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets, requirePalletsOrSkip} from '../util';20import {expect, itEth, usingEthPlaygrounds} from './util';21import {CollectionLimits} from './util/playgrounds/types';222324describe('Create RFT collection from EVM', () => {25  let donor: IKeyringPair;2627  before(async function() {28    await usingEthPlaygrounds(async (helper, privateKey) => {29      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);30      donor = await privateKey({filename: __filename});31    });32  });3334  itEth('Create collection', async ({helper}) => {35    const owner = await helper.eth.createAccountWithBalance(donor);36    37    const name = 'CollectionEVM';38    const description = 'Some description';39    const prefix = 'token prefix';40  41    const {collectionId} = await helper.eth.createRFTCollection(owner, name, description, prefix);42    const data = (await helper.rft.getData(collectionId))!;43    const collection = helper.rft.getCollectionObject(collectionId);4445    expect(data.name).to.be.eq(name);46    expect(data.description).to.be.eq(description);47    expect(data.raw.tokenPrefix).to.be.eq(prefix);48    expect(data.raw.mode).to.be.eq('ReFungible');4950    const options = await collection.getOptions();5152    expect(options.tokenPropertyPermissions).to.be.empty;53  });5455  5657  itEth('Create collection with properties & get description', async ({helper}) => {58    const owner = await helper.eth.createAccountWithBalance(donor);5960    const name = 'CollectionEVM';61    const description = 'Some description';62    const prefix = 'token prefix';63    const baseUri = 'BaseURI';6465    const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);66    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');6768    const collection = helper.rft.getCollectionObject(collectionId);69    const data = (await collection.getData())!;70    71    expect(data.name).to.be.eq(name);72    expect(data.description).to.be.eq(description);73    expect(data.raw.tokenPrefix).to.be.eq(prefix);74    expect(data.raw.mode).to.be.eq('ReFungible');7576    expect(await contract.methods.description().call()).to.deep.equal(description);7778    const options = await collection.getOptions();79    expect(options.tokenPropertyPermissions).to.be.deep.equal([80      {81        key: 'URI',82        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},83      },84      {85        key: 'URISuffix',86        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},87      },88    ]);89  });90  91  // this test will occasionally fail when in async environment.92  itEth.skip('Check collection address exist', async ({helper}) => {93    const owner = await helper.eth.createAccountWithBalance(donor);9495    const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;96    const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);97    const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);9899    expect(await collectionHelpers.methods100      .isCollectionExist(expectedCollectionAddress)101      .call()).to.be.false;102103    await collectionHelpers.methods104      .createRFTCollection('A', 'A', 'A')105      .send({value: Number(2n * helper.balance.getOneTokenNominal())});106    107    expect(await collectionHelpers.methods108      .isCollectionExist(expectedCollectionAddress)109      .call()).to.be.true;110  });111  112  // Soft-deprecated113  itEth('[eth] Set sponsorship', async ({helper}) => {114    const owner = await helper.eth.createAccountWithBalance(donor);115    const sponsor = await helper.eth.createAccountWithBalance(donor);116    const ss58Format = helper.chain.getChainProperties().ss58Format;117    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');118119    const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);120    await collection.methods.setCollectionSponsor(sponsor).send();121122    let data = (await helper.rft.getData(collectionId))!;123    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));124125    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');126127    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);128    await sponsorCollection.methods.confirmCollectionSponsorship().send();129130    data = (await helper.rft.getData(collectionId))!;131    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));132  });133134  itEth('[cross] Set sponsorship', async ({helper}) => {135    const owner = await helper.eth.createAccountWithBalance(donor);136    const sponsor = await helper.eth.createAccountWithBalance(donor);137    const ss58Format = helper.chain.getChainProperties().ss58Format;138    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');139140    const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);141    const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);142    await collection.methods.setCollectionSponsorCross(sponsorCross).send();143144    let data = (await helper.rft.getData(collectionId))!;145    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));146147    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');148149    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);150    await sponsorCollection.methods.confirmCollectionSponsorship().send();151152    data = (await helper.rft.getData(collectionId))!;153    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));154  });155156  itEth('Collection address exist', async ({helper}) => {157    const owner = await helper.eth.createAccountWithBalance(donor);158    const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';159    expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)160      .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())161      .to.be.false;162    163    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Exister', 'absolutely anything', 'WIWT');164    expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)165      .methods.isCollectionExist(collectionAddress).call())166      .to.be.true;167  });168});169170describe('(!negative tests!) Create RFT collection from EVM', () => {171  let donor: IKeyringPair;172  let nominal: bigint;173174  before(async function() {175    await usingEthPlaygrounds(async (helper, privateKey) => {176      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);177      donor = await privateKey({filename: __filename});178      nominal = helper.balance.getOneTokenNominal();179    });180  });181182  itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {183    const owner = await helper.eth.createAccountWithBalance(donor);184    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);185    {186      const MAX_NAME_LENGTH = 64;187      const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);188      const description = 'A';189      const tokenPrefix = 'A';190191      await expect(collectionHelper.methods192        .createRFTCollection(collectionName, description, tokenPrefix)193        .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);194    }195    {196      const MAX_DESCRIPTION_LENGTH = 256;197      const collectionName = 'A';198      const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);199      const tokenPrefix = 'A';200      await expect(collectionHelper.methods201        .createRFTCollection(collectionName, description, tokenPrefix)202        .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);203    }204    {205      const MAX_TOKEN_PREFIX_LENGTH = 16;206      const collectionName = 'A';207      const description = 'A';208      const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);209      await expect(collectionHelper.methods210        .createRFTCollection(collectionName, description, tokenPrefix)211        .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);212    }213  });214  215  itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {216    const owner = await helper.eth.createAccountWithBalance(donor);217    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);218    await expect(collectionHelper.methods219      .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')220      .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');221  });222223  // Soft-deprecated224  itEth('(!negative test!) [eth] Check owner', async ({helper}) => {225    const owner = await helper.eth.createAccountWithBalance(donor);226    const peasant = helper.eth.createAccount();227    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');228    const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);229    const EXPECTED_ERROR = 'NoPermission';230    {231      const sponsor = await helper.eth.createAccountWithBalance(donor);232      await expect(peasantCollection.methods233        .setCollectionSponsor(sponsor)234        .call()).to.be.rejectedWith(EXPECTED_ERROR);235      236      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);237      await expect(sponsorCollection.methods238        .confirmCollectionSponsorship()239        .call()).to.be.rejectedWith('ConfirmSponsorshipFail');240    }241    {242      await expect(peasantCollection.methods243        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)244        .call()).to.be.rejectedWith(EXPECTED_ERROR);245    }246  });247248  itEth('(!negative test!) [cross] Check owner', async ({helper}) => {249    const owner = await helper.eth.createAccountWithBalance(donor);250    const peasant = helper.eth.createAccount();251    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');252    const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);253    const EXPECTED_ERROR = 'NoPermission';254    {255      const sponsor = await helper.eth.createAccountWithBalance(donor);256      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);257      await expect(peasantCollection.methods258        .setCollectionSponsorCross(sponsorCross)259        .call()).to.be.rejectedWith(EXPECTED_ERROR);260      261      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);262      await expect(sponsorCollection.methods263        .confirmCollectionSponsorship()264        .call()).to.be.rejectedWith('ConfirmSponsorshipFail');265    }266    {267      await expect(peasantCollection.methods268        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)269        .call()).to.be.rejectedWith(EXPECTED_ERROR);270    }271  });272  273  itEth('destroyCollection', async ({helper}) => {274    const owner = await helper.eth.createAccountWithBalance(donor);275    const {collectionAddress, collectionId} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');276    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);277    278    await expect(collectionHelper.methods279      .destroyCollection(collectionAddress)280      .send({from: owner})).to.be.fulfilled;281    282    expect(await collectionHelper.methods283      .isCollectionExist(collectionAddress)284      .call()).to.be.false;285    expect(await helper.collection.getData(collectionId)).to.be.null;286  });287});
after · tests/src/eth/createRFTCollection.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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets, requirePalletsOrSkip} from '../util';20import {expect, itEth, usingEthPlaygrounds} from './util';21import {CollectionLimits} from './util/playgrounds/types';222324describe('Create RFT collection from EVM', () => {25  let donor: IKeyringPair;2627  before(async function() {28    await usingEthPlaygrounds(async (helper, privateKey) => {29      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);30      donor = await privateKey({filename: __filename});31    });32  });3334  itEth('Create collection', async ({helper}) => {35    const owner = await helper.eth.createAccountWithBalance(donor);36    37    const name = 'CollectionEVM';38    const description = 'Some description';39    const prefix = 'token prefix';40  41    const {collectionId} = await helper.eth.createRFTCollection(owner, name, description, prefix);42    const data = (await helper.rft.getData(collectionId))!;43    const collection = helper.rft.getCollectionObject(collectionId);4445    expect(data.name).to.be.eq(name);46    expect(data.description).to.be.eq(description);47    expect(data.raw.tokenPrefix).to.be.eq(prefix);48    expect(data.raw.mode).to.be.eq('ReFungible');4950    const options = await collection.getOptions();5152    expect(options.tokenPropertyPermissions).to.be.empty;53  });5455  5657  itEth('Create collection with properties & get description', async ({helper}) => {58    const owner = await helper.eth.createAccountWithBalance(donor);5960    const name = 'CollectionEVM';61    const description = 'Some description';62    const prefix = 'token prefix';63    const baseUri = 'BaseURI';6465    const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);66    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');6768    const collection = helper.rft.getCollectionObject(collectionId);69    const data = (await collection.getData())!;70    71    expect(data.name).to.be.eq(name);72    expect(data.description).to.be.eq(description);73    expect(data.raw.tokenPrefix).to.be.eq(prefix);74    expect(data.raw.mode).to.be.eq('ReFungible');7576    expect(await contract.methods.description().call()).to.deep.equal(description);7778    const options = await collection.getOptions();79    expect(options.tokenPropertyPermissions).to.be.deep.equal([80      {81        key: 'URI',82        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},83      },84      {85        key: 'URISuffix',86        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},87      },88    ]);89  });90  91  // Soft-deprecated92  itEth('[eth] Set sponsorship', async ({helper}) => {93    const owner = await helper.eth.createAccountWithBalance(donor);94    const sponsor = await helper.eth.createAccountWithBalance(donor);95    const ss58Format = helper.chain.getChainProperties().ss58Format;96    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');9798    const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);99    await collection.methods.setCollectionSponsor(sponsor).send();100101    let data = (await helper.rft.getData(collectionId))!;102    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));103104    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');105106    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);107    await sponsorCollection.methods.confirmCollectionSponsorship().send();108109    data = (await helper.rft.getData(collectionId))!;110    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));111  });112113  itEth('[cross] Set sponsorship', async ({helper}) => {114    const owner = await helper.eth.createAccountWithBalance(donor);115    const sponsor = await helper.eth.createAccountWithBalance(donor);116    const ss58Format = helper.chain.getChainProperties().ss58Format;117    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');118119    const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);120    const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);121    await collection.methods.setCollectionSponsorCross(sponsorCross).send();122123    let data = (await helper.rft.getData(collectionId))!;124    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));125126    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');127128    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);129    await sponsorCollection.methods.confirmCollectionSponsorship().send();130131    data = (await helper.rft.getData(collectionId))!;132    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));133  });134135  itEth('Collection address exist', async ({helper}) => {136    const owner = await helper.eth.createAccountWithBalance(donor);137    const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';138    expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)139      .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())140      .to.be.false;141    142    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Exister', 'absolutely anything', 'WIWT');143    expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)144      .methods.isCollectionExist(collectionAddress).call())145      .to.be.true;146147    // check collectionOwner:148    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);149    const collectionOwner = await collectionEvm.methods.collectionOwner().call();150    expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));151  });152});153154describe('(!negative tests!) Create RFT collection from EVM', () => {155  let donor: IKeyringPair;156  let nominal: bigint;157158  before(async function() {159    await usingEthPlaygrounds(async (helper, privateKey) => {160      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);161      donor = await privateKey({filename: __filename});162      nominal = helper.balance.getOneTokenNominal();163    });164  });165166  itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {167    const owner = await helper.eth.createAccountWithBalance(donor);168    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);169    {170      const MAX_NAME_LENGTH = 64;171      const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);172      const description = 'A';173      const tokenPrefix = 'A';174175      await expect(collectionHelper.methods176        .createRFTCollection(collectionName, description, tokenPrefix)177        .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);178    }179    {180      const MAX_DESCRIPTION_LENGTH = 256;181      const collectionName = 'A';182      const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);183      const tokenPrefix = 'A';184      await expect(collectionHelper.methods185        .createRFTCollection(collectionName, description, tokenPrefix)186        .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);187    }188    {189      const MAX_TOKEN_PREFIX_LENGTH = 16;190      const collectionName = 'A';191      const description = 'A';192      const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);193      await expect(collectionHelper.methods194        .createRFTCollection(collectionName, description, tokenPrefix)195        .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);196    }197  });198  199  itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {200    const owner = await helper.eth.createAccountWithBalance(donor);201    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);202    await expect(collectionHelper.methods203      .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')204      .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');205  });206207  // Soft-deprecated208  itEth('(!negative test!) [eth] Check owner', async ({helper}) => {209    const owner = await helper.eth.createAccountWithBalance(donor);210    const peasant = helper.eth.createAccount();211    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');212    const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);213    const EXPECTED_ERROR = 'NoPermission';214    {215      const sponsor = await helper.eth.createAccountWithBalance(donor);216      await expect(peasantCollection.methods217        .setCollectionSponsor(sponsor)218        .call()).to.be.rejectedWith(EXPECTED_ERROR);219      220      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);221      await expect(sponsorCollection.methods222        .confirmCollectionSponsorship()223        .call()).to.be.rejectedWith('ConfirmSponsorshipFail');224    }225    {226      await expect(peasantCollection.methods227        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)228        .call()).to.be.rejectedWith(EXPECTED_ERROR);229    }230  });231232  itEth('(!negative test!) [cross] Check owner', async ({helper}) => {233    const owner = await helper.eth.createAccountWithBalance(donor);234    const peasant = helper.eth.createAccount();235    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');236    const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);237    const EXPECTED_ERROR = 'NoPermission';238    {239      const sponsor = await helper.eth.createAccountWithBalance(donor);240      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);241      await expect(peasantCollection.methods242        .setCollectionSponsorCross(sponsorCross)243        .call()).to.be.rejectedWith(EXPECTED_ERROR);244      245      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);246      await expect(sponsorCollection.methods247        .confirmCollectionSponsorship()248        .call()).to.be.rejectedWith('ConfirmSponsorshipFail');249    }250    {251      await expect(peasantCollection.methods252        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)253        .call()).to.be.rejectedWith(EXPECTED_ERROR);254    }255  });256  257  itEth('destroyCollection', async ({helper}) => {258    const owner = await helper.eth.createAccountWithBalance(donor);259    const {collectionAddress, collectionId} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');260    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);261    262    await expect(collectionHelper.methods263      .destroyCollection(collectionAddress)264      .send({from: owner})).to.be.fulfilled;265    266    expect(await collectionHelper.methods267      .isCollectionExist(collectionAddress)268      .call()).to.be.false;269    expect(await helper.collection.getData(collectionId)).to.be.null;270  });271});
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -167,7 +167,6 @@
     expect(event.returnValues.to).to.be.equal(receiver);
 
     expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
-    console.log(await contract.methods.crossOwnerOf(tokenId).call());
     expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
     // TODO: this wont work right now, need release 919000 first
     // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
@@ -200,8 +199,7 @@
             },
           };
         });
-    
-    
+
       const collection = await helper.nft.mintCollection(minter, {
         tokenPrefix: 'ethp',
         tokenPropertyPermissions: permissions,