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
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
--- 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
--- 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));
   });
 });
 
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,