git.delta.rocks / unique-network / refs/commits / 26015a9e913d

difftreelog

Merge pull request #114 from usetech-llc/feature/NFTPAR-218

usetech-llc2021-04-02parents: #040a586 #d68f54a.patch.diff
in: master
Feature/nftpar 218

11 files changed

modifiedtests/package.jsondiffbeforeafterboth
21 "test": "mocha --timeout 9999999 -r ts-node/register ./**/*.test.ts",21 "test": "mocha --timeout 9999999 -r ts-node/register ./**/*.test.ts",
22 "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",22 "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",
23 "loadTransfer": "ts-node src/transfer.nload.ts",23 "loadTransfer": "ts-node src/transfer.nload.ts",
24 "testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",
24 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",25 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",
25 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",26 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",
26 "testSetVariableMetaData": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetaData.test.ts",27 "testSetVariableMetaData": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetaData.test.ts",
addedtests/src/collision-tests/admVsOwnerChanges.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/admVsOwnerChanges.test.ts
@@ -0,0 +1,55 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { alicesPublicKey, bobsPublicKey } from '../accounts';
+import getBalance from '../substrate/get-balance';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
+import waitNewBlocks from '../substrate/wait-new-blocks';
+import {
+  createCollectionExpectSuccess,
+  createItemExpectSuccess,
+  setCollectionSponsorExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Admin vs Owner changes token: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('The collection admin changes the owner of the token and in the same block the current owner transfers the token to another address ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTxBob);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);
+      await submitTransactionAsync(Bob, changeAdminTxFerdie);
+      const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');
+      //
+      const changeOwner = api.tx.nft.transferFrom(Ferdie.address, Bob.address, collectionId, itemId, 1);
+      const approve = api.tx.nft.approve(Bob.address, collectionId, itemId, 1);
+      const sendItem = api.tx.nft.transfer(Alice.address, collectionId, itemId, 1);
+      await Promise.all
+      ([
+        changeOwner.signAndSend(Alice),
+        approve.signAndSend(Bob),
+        sendItem.signAndSend(Ferdie),
+      ]);
+      const itemBefore: any = await api.query.nft.nftItemList(collectionId, itemId);
+      expect(itemBefore.Owner).not.to.be.eq(Bob.address);
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/admVsOwnerData.test.ts
@@ -0,0 +1,54 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { alicesPublicKey, bobsPublicKey } from '../accounts';
+import getBalance from '../substrate/get-balance';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
+import waitNewBlocks from '../substrate/wait-new-blocks';
+import {
+  createCollectionExpectSuccess,
+  createItemExpectSuccess,
+  setCollectionSponsorExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Admin vs Owner changes the data in the token: ', () => {
+  it('The collection admin changes the data in the token and in the same block the token owner also changes the data in it ', async () => {
+    await usingApi(async (api) => {
+      const AliceData = 1;
+      const BobData = 2;
+      const collectionId = await createCollectionExpectSuccess();
+      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTx);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
+      //
+      // tslint:disable-next-line: max-line-length
+      const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());
+      // tslint:disable-next-line: max-line-length
+      const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());
+      await Promise.all
+      ([
+        AliceTx.signAndSend(Alice),
+        BobTx.signAndSend(Bob),
+      ]);
+      const item: any = await api.query.nft.nftItemList(collectionId, itemId);
+      expect(item.VariableData).not.to.be.eq(null); // Pseudo-random selection of one of two values
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/admVsOwnerTake.test.ts
@@ -0,0 +1,54 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { alicesPublicKey, bobsPublicKey } from '../accounts';
+import getBalance from '../substrate/get-balance';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
+import waitNewBlocks from '../substrate/wait-new-blocks';
+import {
+  createCollectionExpectSuccess,
+  createItemExpectSuccess,
+  setCollectionSponsorExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Admin vs Owner take token: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTx);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
+      //
+      const sendItem = api.tx.nft.transfer(Ferdie.address, collectionId, itemId, 1);
+      const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);
+      await Promise.all
+      ([
+        sendItem.signAndSend(Bob),
+        burnItem.signAndSend(Alice),
+      ]);
+      await timeoutPromise(10000);
+      let itemBurn: boolean = false;
+      itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;
+      // tslint:disable-next-line: no-unused-expression
+      expect(itemBurn).to.be.null;
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/adminDestroyCollection.test.ts
@@ -0,0 +1,61 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';
+import {
+  createCollectionExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+interface ITokenDataType {
+  Owner: number[];
+  ConstData: number[];
+  VariableData: number[];
+}
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+let Charlie: IKeyringPair;
+let Eve: IKeyringPair;
+let Dave: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+    Charlie = privateKey('//Charlie');
+    Eve = privateKey('//Eve');
+    Dave = privateKey('//Dave');
+  });
+});
+
+describe('Deleting a collection while add address to whitelist: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTx);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      await timeoutPromise(10000);
+      //
+      const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, Ferdie.address);
+      const destroyCollection = api.tx.nft.destroyCollection(collectionId);
+      await Promise.all
+      ([
+        addWhitelistAdm.signAndSend(Bob),
+        destroyCollection.signAndSend(Alice),
+      ]);
+      await timeoutPromise(10000);
+      let whiteList: boolean = false;
+      whiteList = (await api.query.nft.whiteList(collectionId, Ferdie.address)).toJSON() as boolean;
+      // tslint:disable-next-line: no-unused-expression
+      expect(whiteList).to.be.false;
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/adminLimitsOff.test.ts
@@ -0,0 +1,74 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';
+import {
+  createCollectionExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+interface ITokenDataType {
+  Owner: number[];
+  ConstData: number[];
+  VariableData: number[];
+}
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+let Charlie: IKeyringPair;
+let Eve: IKeyringPair;
+let Dave: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+    Charlie = privateKey('//Charlie');
+    Eve = privateKey('//Eve');
+    Dave = privateKey('//Dave');
+  });
+});
+
+describe('Admin limit exceeded collection: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+
+      const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };
+      const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();
+      expect(chainAdminLimit).to.be.equal(5);
+
+      const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, Eve.address);
+      await submitTransactionAsync(Alice, changeAdminTx1);
+      const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, Dave.address);
+      await submitTransactionAsync(Alice, changeAdminTx2);
+      const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTx3);
+
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      //
+      const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);
+      const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);
+      await Promise.all
+      ([
+        addAdmOne.signAndSend(Bob),
+        addAdmTwo.signAndSend(Alice),
+      ]);
+      await timeoutPromise(10000);
+      const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, Alice.address);
+      // tslint:disable-next-line: no-unused-expression
+      expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;
+
+      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
+      expect(adminListAfterAddAdmin).to.be.contains(Eve.address);
+      expect(adminListAfterAddAdmin).to.be.contains(Ferdie.address);
+      expect(adminListAfterAddAdmin).not.to.be.contains(Alice.address);
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/adminRightsOff.test.ts
@@ -0,0 +1,62 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';
+import {
+  createCollectionExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+interface ITokenDataType {
+  Owner: number[];
+  ConstData: number[];
+  VariableData: number[];
+}
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+let Charlie: IKeyringPair;
+let Eve: IKeyringPair;
+let Dave: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+    Charlie = privateKey('//Charlie');
+    Eve = privateKey('//Eve');
+    Dave = privateKey('//Dave');
+  });
+});
+
+describe('Deprivation of admin rights: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTx);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      await timeoutPromise(10000);
+      //
+      const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
+      const addItemAdm = api.tx.nft.createMultipleItems(collectionId, Bob.address, args);
+      const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);
+      await Promise.all
+      ([
+        addItemAdm.signAndSend(Bob),
+        removeAdm.signAndSend(Alice),
+      ]);
+      await timeoutPromise(10000);
+      const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
+      expect(itemsListIndex.toNumber()).to.be.equal(0);
+      const adminList: any = (await api.query.nft.adminList(collectionId));
+      expect(adminList).not.to.be.contains(Bob.address);
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/setSponsorNewOwner.test.ts
@@ -0,0 +1,53 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';
+import {
+  createCollectionExpectSuccess, createItemExpectSuccess, setCollectionSponsorExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+interface ITokenDataType {
+  Owner: number[];
+  ConstData: number[];
+  VariableData: number[];
+}
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Sponsored with new owner ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      await setCollectionSponsorExpectSuccess(collectionId, Bob.address);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      await timeoutPromise(10000);
+      //
+      const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);
+      const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);
+      await Promise.all
+      ([
+        confirmSponsorship.signAndSend(Bob),
+        changeCollectionOwner.signAndSend(Alice),
+      ]);
+      await timeoutPromise(10000);
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+      expect(collection.Sponsorship.Confirmed).to.be.eq(Bob.address);
+      expect(collection.Owner).to.be.eq(Ferdie.address);
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/sponsorPayments.test.ts
@@ -0,0 +1,58 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { alicesPublicKey, bobsPublicKey } from '../accounts';
+import getBalance from '../substrate/get-balance';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
+import waitNewBlocks from '../substrate/wait-new-blocks';
+import {
+  confirmSponsorshipExpectSuccess,
+  createCollectionExpectSuccess,
+  createItemExpectSuccess,
+  setCollectionSponsorExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Payment of commission if one block: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('Payment of commission if one block contains transactions for payment from the sponsor\'s balance and his (sponsor\'s) exclusion from the collection ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, changeAdminTxBob);
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
+      await setCollectionSponsorExpectSuccess(collectionId, Bob.address);
+      await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
+      //
+      const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
+      const sendItem = api.tx.nft.transfer(Alice.address, collectionId, itemId, 1);
+      const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);
+      await Promise.all
+      ([
+        sendItem.signAndSend(Bob),
+        revokeSponsor.signAndSend(Alice),
+      ]);
+      const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
+      // tslint:disable-next-line:no-unused-expression
+      expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;
+      // tslint:disable-next-line:no-unused-expression
+      expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;
+      await timeoutPromise(20000);
+    });
+  });
+});
addedtests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/tokenLimitsOff.test.ts
@@ -0,0 +1,84 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
+import {
+  addToWhiteListExpectSuccess,
+  createCollectionExpectSuccess,
+  getCreateItemResult,
+  setMintPermissionExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+interface ITokenDataType {
+  Owner: number[];
+  ConstData: number[];
+  VariableData: number[];
+}
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+const AccountTokenOwnershipLimit = 4;
+const SponsoredMintSize = 4294967295;
+const TokenLimit = 4;
+const SponsorTimeout = 14400;
+const OwnerCanTransfer = false;
+const OwnerCanDestroy = false;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Token limit exceeded collection: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      await setMintPermissionExpectSuccess(Alice, collectionId, true);
+      await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);
+      await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
+      const setCollectionLim = api.tx.nft.setCollectionLimits(
+        collectionId,
+        {
+          AccountTokenOwnershipLimit,
+          SponsoredMintSize,
+          TokenLimit,
+          // tslint:disable-next-line: object-literal-sort-keys
+          SponsorTimeout,
+          OwnerCanTransfer,
+          OwnerCanDestroy,
+        },
+      );
+      const subTx = await submitTransactionAsync(Alice, setCollectionLim);
+      const subTxTesult = getCreateItemResult(subTx);
+      // tslint:disable-next-line:no-unused-expression
+      expect(subTxTesult.success).to.be.true;
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      await timeoutPromise(10000);
+      //
+      const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
+      const mintItemOne = api.tx.nft
+        .createMultipleItems(collectionId, Ferdie.address, args);
+      const mintItemTwo = api.tx.nft
+        .createMultipleItems(collectionId, Bob.address, args);
+      await Promise.all
+      ([
+        mintItemOne.signAndSend(Ferdie),
+        mintItemTwo.signAndSend(Bob),
+      ]);
+      await timeoutPromise(10000);
+      const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
+      expect(itemsListIndexAfter.toNumber()).to.be.equal(3);
+      // TokenLimit = 4. The first transaction is successful. The second should fail.
+      await timeoutPromise(10000);
+    });
+  });
+});
addedtests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/collision-tests/turnsOffMinting.test.ts
@@ -0,0 +1,50 @@
+import { IKeyringPair } from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from '../substrate/privateKey';
+import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
+import waitNewBlocks from '../substrate/wait-new-blocks';
+import {
+  addToWhiteListExpectSuccess,
+  createCollectionExpectSuccess,
+  setMintPermissionExpectSuccess,
+} from '../util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Ferdie: IKeyringPair;
+
+before(async () => {
+  await usingApi(async () => {
+    Alice = privateKey('//Alice');
+    Bob = privateKey('//Bob');
+    Ferdie = privateKey('//Ferdie');
+  });
+});
+
+describe('Turns off minting mode: ', () => {
+  // tslint:disable-next-line: max-line-length
+  it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
+      await setMintPermissionExpectSuccess(Alice, collectionId, true);
+      await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);
+      //
+      const mintItem = api.tx.nft.createItem(collectionId, Ferdie.address, 'NFT');
+      const offMinting = api.tx.nft.setMintPermission(collectionId, false);
+      await Promise.all
+      ([
+        mintItem.signAndSend(Ferdie),
+        offMinting.signAndSend(Alice),
+      ]);
+      let itemList: boolean = false;
+      itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;
+      // tslint:disable-next-line: no-unused-expression
+      expect(itemList).to.be.null;
+      await timeoutPromise(20000);
+    });
+  });
+});