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

difftreelog

Fix tests

Max Andreev2022-12-09parent: #fb2c7d6.patch.diff
in: master

4 files changed

modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
before · 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/createFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -79,56 +79,6 @@
     expect(await collection.methods.description().call()).to.deep.equal(description);
   });
 
-  itEth('Set limits', async ({helper}) => {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');
-    const limits = {
-      accountTokenOwnershipLimit: 1000,
-      sponsoredDataSize: 1024,
-      sponsoredDataRateLimit: 30,
-      tokenLimit: 1000000,
-      sponsorTransferTimeout: 6,
-      sponsorApproveTimeout: 6,
-      ownerCanTransfer: 0,
-      ownerCanDestroy: 0,
-      transfersEnabled: 0,
-    };
-    
-    const expectedLimits = {
-      accountTokenOwnershipLimit: 1000,
-      sponsoredDataSize: 1024,
-      sponsoredDataRateLimit: 30,
-      tokenLimit: 1000000,
-      sponsorTransferTimeout: 6,
-      sponsorApproveTimeout: 6,
-      ownerCanTransfer: false,
-      ownerCanDestroy: false,
-      transfersEnabled: false,
-    };
-   
-    const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
-    await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
-    
-    const data = (await helper.rft.getData(collectionId))!;
-    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
-    expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
-    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
-    expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
-    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
-    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
-    expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
-    expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
-    expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
-  });
-
   itEth('Collection address exist', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
@@ -275,31 +225,5 @@
         .setCollectionLimit('accountTokenOwnershipLimit', '1000')
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
-  });
-
-  itEth('(!negative test!) Set limits', async ({helper}) => {
-
-    const invalidLimits = {
-      accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
-      transfersEnabled: 3,
-    };
-
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
-    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
-    await expect(collectionEvm.methods
-      .setCollectionLimit(20, true, '1')
-      .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');
-    
-    await expect(collectionEvm.methods
-      .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
-      .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
-    
-    await expect(collectionEvm.methods
-      .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
-      .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
-  });
-
-   
-    
+  });    
 });
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -120,56 +120,6 @@
     expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);
   });
 
-  itEth('Set limits', async ({helper}) => {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');
-    const limits = {
-      accountTokenOwnershipLimit: 1000,
-      sponsoredDataSize: 1024,
-      sponsoredDataRateLimit: 30,
-      tokenLimit: 1000000,
-      sponsorTransferTimeout: 6,
-      sponsorApproveTimeout: 6,
-      ownerCanTransfer: 0,
-      ownerCanDestroy: 0,
-      transfersEnabled: 0,
-    };
-    
-    const expectedLimits = {
-      accountTokenOwnershipLimit: 1000,
-      sponsoredDataSize: 1024,
-      sponsoredDataRateLimit: 30,
-      tokenLimit: 1000000,
-      sponsorTransferTimeout: 6,
-      sponsorApproveTimeout: 6,
-      ownerCanTransfer: false,
-      ownerCanDestroy: false,
-      transfersEnabled: false,
-    };
-
-    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-    await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
-
-    const data = (await helper.rft.getData(collectionId))!;
-    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
-    expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
-    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
-    expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
-    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
-    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
-    expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
-    expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
-    expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
-  });
-
   itEth('Collection address exist', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
@@ -285,25 +235,6 @@
         .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
-  });
-
-  itEth('(!negative test!) Set limits', async ({helper}) => {
-    const invalidLimits = {
-      accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
-      transfersEnabled: 3,
-    };
-
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
-    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-    
-    await expect(collectionEvm.methods
-      .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
-      .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
-    
-    await expect(collectionEvm.methods
-      .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
-      .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
   });
 
   itEth('destroyCollection', async ({helper}) => {
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -152,56 +152,6 @@
     expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
   });
 
-  itEth('Set limits', async ({helper}) => {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'INSI');
-    const limits = {
-      accountTokenOwnershipLimit: 1000,
-      sponsoredDataSize: 1024,
-      sponsoredDataRateLimit: 30,
-      tokenLimit: 1000000,
-      sponsorTransferTimeout: 6,
-      sponsorApproveTimeout: 6,
-      ownerCanTransfer: 0,
-      ownerCanDestroy: 0,
-      transfersEnabled: 0,
-    };
-    
-    const expectedLimits = {
-      accountTokenOwnershipLimit: 1000,
-      sponsoredDataSize: 1024,
-      sponsoredDataRateLimit: 30,
-      tokenLimit: 1000000,
-      sponsorTransferTimeout: 6,
-      sponsorApproveTimeout: 6,
-      ownerCanTransfer: false,
-      ownerCanDestroy: false,
-      transfersEnabled: false,
-    };
-    
-    const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
-    await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
-    
-    const data = (await helper.rft.getData(collectionId))!;
-    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
-    expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
-    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
-    expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
-    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
-    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
-    expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
-    expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
-    expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
-  });
-
   itEth('Collection address exist', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
@@ -317,25 +267,6 @@
         .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
-  });
-
-  itEth('(!negative test!) Set limits', async ({helper}) => {
-    const invalidLimits = {
-      accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
-      transfersEnabled: 3,
-    };
-
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
-    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    await expect(collectionEvm.methods
-      .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
-      .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
-    
-    await expect(collectionEvm.methods
-      .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
-      .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
   });
   
   itEth('destroyCollection', async ({helper}) => {