difftreelog
Fix tests
in: master
4 files changed
tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionLimits.test.ts
+++ b/tests/src/eth/collectionLimits.test.ts
@@ -1,6 +1,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets} from '../util';
-import {expect, itEth, usingEthPlaygrounds} from './util';
+import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';
describe('Can set collection limits', () => {
@@ -45,15 +45,15 @@
};
const collection = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
- await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
- await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
- await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
- await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
- await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
- await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
- await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
- await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
- await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
+ 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).to.deep.eq(expectedLimits);
@@ -85,16 +85,15 @@
const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);
const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
await expect(collectionEvm.methods
- .setCollectionLimit('badLimit', '1')
- .call()).to.be.rejectedWith('unknown limit "badLimit"');
+ .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(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, BigInt(Number.MAX_SAFE_INTEGER))
.call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
await expect(collectionEvm.methods
- .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+ .setCollectionLimit(CollectionLimits.TransferEnabled, true, 3)
.call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
}));
});
-
\ No newline at end of file
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth79 expect(await collection.methods.description().call()).to.deep.equal(description);79 expect(await collection.methods.description().call()).to.deep.equal(description);80 });80 });8182 itEth('Set limits', async ({helper}) => {83 const owner = await helper.eth.createAccountWithBalance(donor);84 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');85 const limits = {86 accountTokenOwnershipLimit: 1000,87 sponsoredDataSize: 1024,88 sponsoredDataRateLimit: 30,89 tokenLimit: 1000000,90 sponsorTransferTimeout: 6,91 sponsorApproveTimeout: 6,92 ownerCanTransfer: 0,93 ownerCanDestroy: 0,94 transfersEnabled: 0,95 };96 97 const expectedLimits = {98 accountTokenOwnershipLimit: 1000,99 sponsoredDataSize: 1024,100 sponsoredDataRateLimit: 30,101 tokenLimit: 1000000,102 sponsorTransferTimeout: 6,103 sponsorApproveTimeout: 6,104 ownerCanTransfer: false,105 ownerCanDestroy: false,106 transfersEnabled: false,107 };108 109 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);110 await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();111 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();112 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();113 await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();114 await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();115 await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();116 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();117 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();118 await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();119 120 const data = (await helper.rft.getData(collectionId))!;121 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);122 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);123 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);124 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);125 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);126 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);127 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);128 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);129 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);130 });13181132 itEth('Collection address exist', async ({helper}) => {82 itEth('Collection address exist', async ({helper}) => {133 const owner = await helper.eth.createAccountWithBalance(donor);83 const owner = await helper.eth.createAccountWithBalance(donor);277 }227 }278 });228 }); 279280 itEth('(!negative test!) Set limits', async ({helper}) => {281282 const invalidLimits = {283 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),284 transfersEnabled: 3,285 };286287 const owner = await helper.eth.createAccountWithBalance(donor);288 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');289 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);290 await expect(collectionEvm.methods291 .setCollectionLimit(20, true, '1')292 .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');293 294 await expect(collectionEvm.methods295 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)296 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);297 298 await expect(collectionEvm.methods299 .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)300 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);301 });302303 304 tests/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}) => {
tests/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}) => {