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
62 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossSub).call()).to.be.false;62 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossSub).call()).to.be.false;
63 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossEth).call()).to.be.false;63 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossEth).call()).to.be.false;
64 expect(await collectionEvm.methods.isOwnerOrAdminCross(helper.ethCrossAccount.fromAddress(adminDeprecated)).call()).to.be.false;64 expect(await collectionEvm.methods.isOwnerOrAdminCross(helper.ethCrossAccount.fromAddress(adminDeprecated)).call()).to.be.false;
65 65 expect(await collectionEvm.methods.collectionAdmins().call()).to.be.like([]);
66
67
66 // Soft-deprecated: can addCollectionAdmin 68 // Soft-deprecated: can addCollectionAdmin
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
101 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;101 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
102 102
103 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});103 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
104 let sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
105 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor));
104 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;106 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
105 107
106 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});108 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
107 109
108 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});110 sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
109 expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');111 expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');
110 }));112 }));
111113
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
32 });32 });
33 });33 });
34 34
35 // TODO move sponsorship tests to another file:
35 // Soft-deprecated36 // Soft-deprecated
36 itEth('[eth] Set sponsorship', async ({helper}) => {37 itEth('[eth] Set sponsorship', async ({helper}) => {
37 const owner = await helper.eth.createAccountWithBalance(donor);38 const owner = await helper.eth.createAccountWithBalance(donor);
92 .methods.isCollectionExist(collectionAddress).call())93 .methods.isCollectionExist(collectionAddress).call())
93 .to.be.true;94 .to.be.true;
95
96 // check collectionOwner:
97 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
98 const collectionOwner = await collectionEvm.methods.collectionOwner().call();
99 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner));
94 });100 });
95 101
96 itEth('destroyCollection', async ({helper}) => {102 itEth('destroyCollection', async ({helper}) => {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
133 .methods.isCollectionExist(collectionAddress).call())133 .methods.isCollectionExist(collectionAddress).call())
134 .to.be.true;134 .to.be.true;
135
136 // 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));
135 });140 });
136});141});
137142
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
88 ]);88 ]);
89 });89 });
90 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);
94
95 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);
98
99 expect(await collectionHelpers.methods
100 .isCollectionExist(expectedCollectionAddress)
101 .call()).to.be.false;
102
103 await collectionHelpers.methods
104 .createRFTCollection('A', 'A', 'A')
105 .send({value: Number(2n * helper.balance.getOneTokenNominal())});
106
107 expect(await collectionHelpers.methods
108 .isCollectionExist(expectedCollectionAddress)
109 .call()).to.be.true;
110 });
111
112 // Soft-deprecated91 // Soft-deprecated
113 itEth('[eth] Set sponsorship', async ({helper}) => {92 itEth('[eth] Set sponsorship', async ({helper}) => {
165 .methods.isCollectionExist(collectionAddress).call())144 .methods.isCollectionExist(collectionAddress).call())
166 .to.be.true;145 .to.be.true;
146
147 // 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));
167 });151 });
168});152});
169153
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
167 expect(event.returnValues.to).to.be.equal(receiver);167 expect(event.returnValues.to).to.be.equal(receiver);
168168
169 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');169 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
170 console.log(await contract.methods.crossOwnerOf(tokenId).call());
171 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);170 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
172 // TODO: this wont work right now, need release 919000 first171 // TODO: this wont work right now, need release 919000 first
173 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();172 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();