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
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
--- 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,