git.delta.rocks / unique-network / refs/commits / d05c19b445d1

difftreelog

fix after rebase

Trubnikov Sergey2022-12-09parent: #e047487.patch.diff
in: master

4 files changed

modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
after · tests/src/eth/collectionLimits.test.ts
1import {IKeyringPair} from '@polkadot/types/types';2import {Pallets} from '../util';3import {expect, itEth, usingEthPlaygrounds} from './util';456describe('Can set collection limits', () => {7  let donor: IKeyringPair;89  before(async () => {10    await usingEthPlaygrounds(async (_helper, privateKey) => {11      donor = await privateKey({filename: __filename});12    });13  });1415  [16    {case: 'nft' as const},17    {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},18    {case: 'ft' as const},19  ].map(testCase =>20    itEth.ifWithPallets(`for ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {21      const owner = await helper.eth.createAccountWithBalance(donor);22      const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'FLO', 18);23      const limits = {24        accountTokenOwnershipLimit: 1000,25        sponsoredDataSize: 1024,26        sponsoredDataRateLimit: 30,27        tokenLimit: 1000000,28        sponsorTransferTimeout: 6,29        sponsorApproveTimeout: 6,30        ownerCanTransfer: 1,31        ownerCanDestroy: 0,32        transfersEnabled: 0,33      };34      35      const expectedLimits = {36        accountTokenOwnershipLimit: 1000,37        sponsoredDataSize: 1024,38        sponsoredDataRateLimit: {blocks: 30},39        tokenLimit: 1000000,40        sponsorTransferTimeout: 6,41        sponsorApproveTimeout: 6,42        ownerCanTransfer: true,43        ownerCanDestroy: false,44        transfersEnabled: false,45      };46     47      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);48      await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();49      await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();50      await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();51      await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();52      await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();53      await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();54      await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();55      await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();56      await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();57      58      const data = (await helper.rft.getData(collectionId))!;59      expect(data.raw.limits).to.deep.eq(expectedLimits);60      expect(await helper.collection.getEffectiveLimits(collectionId)).to.deep.eq(expectedLimits);61    }));62});6364describe('Cannot set invalid collection limits', () => {65  let donor: IKeyringPair;6667  before(async () => {68    await usingEthPlaygrounds(async (_helper, privateKey) => {69      donor = await privateKey({filename: __filename});70    });71  });7273  [74    {case: 'nft' as const},75    {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},76    {case: 'ft' as const},77  ].map(testCase =>78    itEth.ifWithPallets(`for ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {79      const invalidLimits = {80        accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),81        transfersEnabled: 3,82      };8384      const owner = await helper.eth.createAccountWithBalance(donor);85      const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);86      const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);87      await expect(collectionEvm.methods88        .setCollectionLimit('badLimit', '1')89        .call()).to.be.rejectedWith('unknown limit "badLimit"');90      91      await expect(collectionEvm.methods92        .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)93        .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);94      95      await expect(collectionEvm.methods96        .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)97        .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);98    }));99});100  
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -128,7 +128,7 @@
       let sponsorship = (await collectionSub.getData())!.raw.sponsorship;
       expect(sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));
       // Account cannot confirm sponsorship if it is not set as a sponsor
-      await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
+      await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmUnsetSponsorFail');
       
       // Sponsor can confirm sponsorship:
       await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});
@@ -173,7 +173,7 @@
               tokenId: '1',
             },
           },
-        ]);
+        );
   
         const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
         const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));
@@ -289,7 +289,7 @@
             tokenId: '1',
           },
         },
-      ]);
+      );
       expect(await collectionEvm.methods.tokenURI(tokenId).call({from: user})).to.be.equal('Test URI');
   
       const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
modifiedtests/src/eth/destroyCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/destroyCollection.test.ts
+++ b/tests/src/eth/destroyCollection.test.ts
@@ -21,9 +21,9 @@
 describe('Destroy Collection from EVM', function() {
   let donor: IKeyringPair;
   const testCases = [
-    {method: 'createRFTCollection' as const, params: ['Limits', 'absolutely anything', 'OLF'], requiredPallets: [Pallets.ReFungible]},
-    {method: 'createNFTCollection' as const, params: ['Limits', 'absolutely anything', 'OLF'], requiredPallets: [Pallets.NFT]},
-    {method: 'createFTCollection' as const, params: ['Limits', 'absolutely anything', 'OLF', 18], requiredPallets: [Pallets.Fungible]},
+    {case: 'rft' as const, params: ['Limits', 'absolutely anything', 'OLF'], requiredPallets: [Pallets.ReFungible]},
+    {case: 'nft' as const, params: ['Limits', 'absolutely anything', 'OLF'], requiredPallets: [Pallets.NFT]},
+    {case: 'ft' as const, params: ['Limits', 'absolutely anything', 'OLF', 18], requiredPallets: [Pallets.Fungible]},
   ];
 
   before(async function() {
@@ -33,14 +33,14 @@
   });
 
   testCases.map((testCase) => 
-    itEth.ifWithPallets(`Cannot burn non-owned or non-existing collection ${testCase.method}`, testCase.requiredPallets, async ({helper}) => {
+    itEth.ifWithPallets(`Cannot burn non-owned or non-existing collection ${testCase.case}`, testCase.requiredPallets, async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const signer = await helper.eth.createAccountWithBalance(donor);
       
       const unexistedCollection = helper.ethAddress.fromCollectionId(1000000);
       
       const collectionHelpers = helper.ethNativeContract.collectionHelpers(signer);
-      const {collectionAddress} = await helper.eth.createCollecion(testCase.method, owner, ...testCase.params as [string, string, string, number?]);
+      const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, ...testCase.params as [string, string, string, number?]);
 
       // cannot burn collec
       await expect(collectionHelpers.methods
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -202,7 +202,7 @@
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
     const functionName: string = this.createCollectionMethodName(mode);
 
-    const functionParams = functionName === 'createFTCollection' ? [name, decimals, description, tokenPrefix] : [name, description, tokenPrefix];
+    const functionParams = mode === 'ft' ? [name, decimals, description, tokenPrefix] : [name, description, tokenPrefix];
     const result = await collectionHelper.methods[functionName](...functionParams).send({value: Number(collectionCreationPrice)});
 
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
@@ -231,7 +231,7 @@
   }
 
   createFungibleCollection(signer: string, name: string, decimals: number, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {
-    return this.createCollecion('createFTCollection', signer, name, description, tokenPrefix, decimals);
+    return this.createCollection('ft', signer, name, description, tokenPrefix, decimals);
   }
 
   async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {