From ddd521cfaa4daf1184e1129093aed23c07673d2f Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Thu, 22 Dec 2022 14:19:47 +0000 Subject: [PATCH] Add call-methods checks --- --- 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(); --- 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'); })); --- 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}) => { --- 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)); }); }); --- 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)); }); }); --- 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, -- gitstuff