difftreelog
Add call-methods checks
in: master
6 files changed
tests/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();
tests/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');
}));
tests/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}) => {
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth1// 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 {expect, itEth, usingEthPlaygrounds} from './util';20import { CollectionLimits } from './util/playgrounds/types';212223describe('Create NFT collection from EVM', () => {24 let donor: IKeyringPair;2526 before(async function () {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = await privateKey({filename: __filename});29 });30 });3132 itEth('Create collection with properties & get desctription', async ({helper}) => {33 const owner = await helper.eth.createAccountWithBalance(donor);3435 const name = 'CollectionEVM';36 const description = 'Some description';37 const prefix = 'token prefix';38 const baseUri = 'BaseURI';3940 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);41 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');42 43 expect(events).to.be.deep.equal([44 {45 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',46 event: 'CollectionCreated',47 args: {48 owner: owner,49 collectionId: collectionAddress,50 },51 },52 ]);5354 const collection = helper.nft.getCollectionObject(collectionId);55 const data = (await collection.getData())!;56 57 expect(data.name).to.be.eq(name);58 expect(data.description).to.be.eq(description);59 expect(data.raw.tokenPrefix).to.be.eq(prefix);60 expect(data.raw.mode).to.be.eq('NFT');61 62 expect(await contract.methods.description().call()).to.deep.equal(description);63 64 const options = await collection.getOptions();65 expect(options.tokenPropertyPermissions).to.be.deep.equal([66 {67 key: 'URI',68 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},69 },70 {71 key: 'URISuffix',72 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},73 },74 ]);75 });7677 // Soft-deprecated78 itEth('[eth] Set sponsorship', async ({helper}) => {79 const owner = await helper.eth.createAccountWithBalance(donor);80 const sponsor = await helper.eth.createAccountWithBalance(donor);81 const ss58Format = helper.chain.getChainProperties().ss58Format;82 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');8384 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);85 await collection.methods.setCollectionSponsor(sponsor).send();8687 let data = (await helper.nft.getData(collectionId))!;88 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));8990 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');9192 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);93 await sponsorCollection.methods.confirmCollectionSponsorship().send();9495 data = (await helper.nft.getData(collectionId))!;96 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));97 });9899 itEth('[cross] Set sponsorship & get description', async ({helper}) => {100 const owner = await helper.eth.createAccountWithBalance(donor);101 const sponsor = await helper.eth.createAccountWithBalance(donor);102 const ss58Format = helper.chain.getChainProperties().ss58Format;103 const description = 'absolutely anything';104 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');105106 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);107 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);108 await collection.methods.setCollectionSponsorCross(sponsorCross).send();109110 let data = (await helper.nft.getData(collectionId))!;111 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));112113 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');114115 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);116 await sponsorCollection.methods.confirmCollectionSponsorship().send();117118 data = (await helper.nft.getData(collectionId))!;119 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));120 121 expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);122 });123124 itEth('Collection address exist', async ({helper}) => {125 const owner = await helper.eth.createAccountWithBalance(donor);126 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';127 expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)128 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())129 .to.be.false;130131 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');132 expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)133 .methods.isCollectionExist(collectionAddress).call())134 .to.be.true;135 });136});137138describe('(!negative tests!) Create NFT collection from EVM', () => {139 let donor: IKeyringPair;140 let nominal: bigint;141142 before(async function () {143 await usingEthPlaygrounds(async (helper, privateKey) => {144 donor = await privateKey({filename: __filename});145 nominal = helper.balance.getOneTokenNominal();146 });147 });148149 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {150 const owner = await helper.eth.createAccountWithBalance(donor);151 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);152 {153 const MAX_NAME_LENGTH = 64;154 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);155 const description = 'A';156 const tokenPrefix = 'A';157158 await expect(collectionHelper.methods159 .createNFTCollection(collectionName, description, tokenPrefix)160 .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);161162 }163 {164 const MAX_DESCRIPTION_LENGTH = 256;165 const collectionName = 'A';166 const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);167 const tokenPrefix = 'A';168 await expect(collectionHelper.methods169 .createNFTCollection(collectionName, description, tokenPrefix)170 .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);171 }172 {173 const MAX_TOKEN_PREFIX_LENGTH = 16;174 const collectionName = 'A';175 const description = 'A';176 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);177 await expect(collectionHelper.methods178 .createNFTCollection(collectionName, description, tokenPrefix)179 .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);180 }181 });182183 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {184 const owner = await helper.eth.createAccountWithBalance(donor);185 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);186 await expect(collectionHelper.methods187 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')188 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');189 });190191 // Soft-deprecated192 itEth('(!negative test!) [eth] Check owner', async ({helper}) => {193 const owner = await helper.eth.createAccountWithBalance(donor);194 const malfeasant = helper.eth.createAccount();195 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');196 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);197 const EXPECTED_ERROR = 'NoPermission';198 {199 const sponsor = await helper.eth.createAccountWithBalance(donor);200 await expect(malfeasantCollection.methods201 .setCollectionSponsor(sponsor)202 .call()).to.be.rejectedWith(EXPECTED_ERROR);203204 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);205 await expect(sponsorCollection.methods206 .confirmCollectionSponsorship()207 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');208 }209 {210 await expect(malfeasantCollection.methods211 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)212 .call()).to.be.rejectedWith(EXPECTED_ERROR);213 }214 });215216 itEth('(!negative test!) [cross] Check owner', async ({helper}) => {217 const owner = await helper.eth.createAccountWithBalance(donor);218 const malfeasant = helper.eth.createAccount();219 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');220 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);221 const EXPECTED_ERROR = 'NoPermission';222 {223 const sponsor = await helper.eth.createAccountWithBalance(donor);224 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);225 await expect(malfeasantCollection.methods226 .setCollectionSponsorCross(sponsorCross)227 .call()).to.be.rejectedWith(EXPECTED_ERROR);228229 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);230 await expect(sponsorCollection.methods231 .confirmCollectionSponsorship()232 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');233 }234 {235 await expect(malfeasantCollection.methods236 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)237 .call()).to.be.rejectedWith(EXPECTED_ERROR);238 }239 });240241 itEth('destroyCollection', async ({helper}) => {242 const owner = await helper.eth.createAccountWithBalance(donor);243 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');244 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);245246247 const result = await collectionHelper.methods248 .destroyCollection(collectionAddress)249 .send({from: owner});250251 const events = helper.eth.normalizeEvents(result.events);252 253 expect(events).to.be.deep.equal([254 {255 address: collectionHelper.options.address,256 event: 'CollectionDestroyed',257 args: {258 collectionId: collectionAddress,259 },260 },261 ]);262263 expect(await collectionHelper.methods264 .isCollectionExist(collectionAddress)265 .call()).to.be.false;266 expect(await helper.collection.getData(collectionId)).to.be.null;267 });268});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 {expect, itEth, usingEthPlaygrounds} from './util';20import { CollectionLimits } from './util/playgrounds/types';212223describe('Create NFT collection from EVM', () => {24 let donor: IKeyringPair;2526 before(async function () {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = await privateKey({filename: __filename});29 });30 });3132 itEth('Create collection with properties & get desctription', async ({helper}) => {33 const owner = await helper.eth.createAccountWithBalance(donor);3435 const name = 'CollectionEVM';36 const description = 'Some description';37 const prefix = 'token prefix';38 const baseUri = 'BaseURI';3940 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);41 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');42 43 expect(events).to.be.deep.equal([44 {45 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',46 event: 'CollectionCreated',47 args: {48 owner: owner,49 collectionId: collectionAddress,50 },51 },52 ]);5354 const collection = helper.nft.getCollectionObject(collectionId);55 const data = (await collection.getData())!;56 57 expect(data.name).to.be.eq(name);58 expect(data.description).to.be.eq(description);59 expect(data.raw.tokenPrefix).to.be.eq(prefix);60 expect(data.raw.mode).to.be.eq('NFT');61 62 expect(await contract.methods.description().call()).to.deep.equal(description);63 64 const options = await collection.getOptions();65 expect(options.tokenPropertyPermissions).to.be.deep.equal([66 {67 key: 'URI',68 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},69 },70 {71 key: 'URISuffix',72 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},73 },74 ]);75 });7677 // Soft-deprecated78 itEth('[eth] Set sponsorship', async ({helper}) => {79 const owner = await helper.eth.createAccountWithBalance(donor);80 const sponsor = await helper.eth.createAccountWithBalance(donor);81 const ss58Format = helper.chain.getChainProperties().ss58Format;82 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');8384 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);85 await collection.methods.setCollectionSponsor(sponsor).send();8687 let data = (await helper.nft.getData(collectionId))!;88 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));8990 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');9192 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);93 await sponsorCollection.methods.confirmCollectionSponsorship().send();9495 data = (await helper.nft.getData(collectionId))!;96 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));97 });9899 itEth('[cross] Set sponsorship & get description', async ({helper}) => {100 const owner = await helper.eth.createAccountWithBalance(donor);101 const sponsor = await helper.eth.createAccountWithBalance(donor);102 const ss58Format = helper.chain.getChainProperties().ss58Format;103 const description = 'absolutely anything';104 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');105106 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);107 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);108 await collection.methods.setCollectionSponsorCross(sponsorCross).send();109110 let data = (await helper.nft.getData(collectionId))!;111 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));112113 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');114115 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);116 await sponsorCollection.methods.confirmCollectionSponsorship().send();117118 data = (await helper.nft.getData(collectionId))!;119 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));120 121 expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);122 });123124 itEth('Collection address exist', async ({helper}) => {125 const owner = await helper.eth.createAccountWithBalance(donor);126 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';127 expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)128 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())129 .to.be.false;130131 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');132 expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)133 .methods.isCollectionExist(collectionAddress).call())134 .to.be.true;135136 // check collectionOwner:137 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);138 const collectionOwner = await collectionEvm.methods.collectionOwner().call();139 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));140 });141});142143describe('(!negative tests!) Create NFT collection from EVM', () => {144 let donor: IKeyringPair;145 let nominal: bigint;146147 before(async function () {148 await usingEthPlaygrounds(async (helper, privateKey) => {149 donor = await privateKey({filename: __filename});150 nominal = helper.balance.getOneTokenNominal();151 });152 });153154 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {155 const owner = await helper.eth.createAccountWithBalance(donor);156 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);157 {158 const MAX_NAME_LENGTH = 64;159 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);160 const description = 'A';161 const tokenPrefix = 'A';162163 await expect(collectionHelper.methods164 .createNFTCollection(collectionName, description, tokenPrefix)165 .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);166167 }168 {169 const MAX_DESCRIPTION_LENGTH = 256;170 const collectionName = 'A';171 const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);172 const tokenPrefix = 'A';173 await expect(collectionHelper.methods174 .createNFTCollection(collectionName, description, tokenPrefix)175 .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);176 }177 {178 const MAX_TOKEN_PREFIX_LENGTH = 16;179 const collectionName = 'A';180 const description = 'A';181 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);182 await expect(collectionHelper.methods183 .createNFTCollection(collectionName, description, tokenPrefix)184 .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);185 }186 });187188 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {189 const owner = await helper.eth.createAccountWithBalance(donor);190 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);191 await expect(collectionHelper.methods192 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')193 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');194 });195196 // Soft-deprecated197 itEth('(!negative test!) [eth] Check owner', async ({helper}) => {198 const owner = await helper.eth.createAccountWithBalance(donor);199 const malfeasant = helper.eth.createAccount();200 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');201 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);202 const EXPECTED_ERROR = 'NoPermission';203 {204 const sponsor = await helper.eth.createAccountWithBalance(donor);205 await expect(malfeasantCollection.methods206 .setCollectionSponsor(sponsor)207 .call()).to.be.rejectedWith(EXPECTED_ERROR);208209 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);210 await expect(sponsorCollection.methods211 .confirmCollectionSponsorship()212 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');213 }214 {215 await expect(malfeasantCollection.methods216 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)217 .call()).to.be.rejectedWith(EXPECTED_ERROR);218 }219 });220221 itEth('(!negative test!) [cross] Check owner', async ({helper}) => {222 const owner = await helper.eth.createAccountWithBalance(donor);223 const malfeasant = helper.eth.createAccount();224 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');225 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);226 const EXPECTED_ERROR = 'NoPermission';227 {228 const sponsor = await helper.eth.createAccountWithBalance(donor);229 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);230 await expect(malfeasantCollection.methods231 .setCollectionSponsorCross(sponsorCross)232 .call()).to.be.rejectedWith(EXPECTED_ERROR);233234 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);235 await expect(sponsorCollection.methods236 .confirmCollectionSponsorship()237 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');238 }239 {240 await expect(malfeasantCollection.methods241 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)242 .call()).to.be.rejectedWith(EXPECTED_ERROR);243 }244 });245246 itEth('destroyCollection', async ({helper}) => {247 const owner = await helper.eth.createAccountWithBalance(donor);248 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');249 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);250251252 const result = await collectionHelper.methods253 .destroyCollection(collectionAddress)254 .send({from: owner});255256 const events = helper.eth.normalizeEvents(result.events);257 258 expect(events).to.be.deep.equal([259 {260 address: collectionHelper.options.address,261 event: 'CollectionDestroyed',262 args: {263 collectionId: collectionAddress,264 },265 },266 ]);267268 expect(await collectionHelper.methods269 .isCollectionExist(collectionAddress)270 .call()).to.be.false;271 expect(await helper.collection.getData(collectionId)).to.be.null;272 });273});tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -88,27 +88,6 @@
]);
});
- // this test will occasionally fail when in async environment.
- itEth.skip('Check collection address exist', async ({helper}) => {
- const owner = await helper.eth.createAccountWithBalance(donor);
-
- const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
- const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
- const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
-
- expect(await collectionHelpers.methods
- .isCollectionExist(expectedCollectionAddress)
- .call()).to.be.false;
-
- await collectionHelpers.methods
- .createRFTCollection('A', 'A', 'A')
- .send({value: Number(2n * helper.balance.getOneTokenNominal())});
-
- expect(await collectionHelpers.methods
- .isCollectionExist(expectedCollectionAddress)
- .call()).to.be.true;
- });
-
// Soft-deprecated
itEth('[eth] Set sponsorship', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
@@ -164,6 +143,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));
});
});
tests/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,