difftreelog
turn off collision-tests
in: master
10 files changed
tests/src/collision-tests/admVsOwnerChanges.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createItemExpectSuccess,8import privateKey from '../substrate/privateKey';9 normalizeAccountId,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10 waitNewBlocks,10import {11} from '../util/helpers';11 createCollectionExpectSuccess,1212 createItemExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;1617let Ferdie: IKeyringPair;17chai.use(chaiAsPromised);1818const expect = chai.expect;19before(async () => {19let Alice: IKeyringPair;20 await usingApi(async () => {20let Bob: IKeyringPair;21 Alice = privateKey('//Alice');21let Ferdie: IKeyringPair;22 Bob = privateKey('//Bob');2223 Ferdie = privateKey('//Ferdie');23before(async () => {24 });24 await usingApi(async () => {25});25 Alice = privateKey('//Alice');2626 Bob = privateKey('//Bob');27describe('Admin vs Owner changes token: ', () => {27 Ferdie = privateKey('//Ferdie');28 // tslint:disable-next-line: max-line-length28 });29 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 () => {29});303031 await usingApi(async (api) => {31describe('Admin vs Owner changes token: ', () => {32 const collectionId = await createCollectionExpectSuccess();32 // tslint:disable-next-line: max-line-length33 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));33 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 () => {34 await submitTransactionAsync(Alice, changeAdminTxBob);3435 const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));35 await usingApi(async (api) => {36 await submitTransactionAsync(Bob, changeAdminTxFerdie);36 const collectionId = await createCollectionExpectSuccess();37 const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');37 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));3838 await submitTransactionAsync(Alice, changeAdminTxBob);39 const changeOwner = api.tx.nft.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);39 const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));40 const approve = api.tx.nft.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);40 await submitTransactionAsync(Bob, changeAdminTxFerdie);41 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);41 const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');42 await Promise.all([4243 changeOwner.signAndSend(Alice),43 const changeOwner = api.tx.nft.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);44 approve.signAndSend(Bob),44 const approve = api.tx.nft.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);45 sendItem.signAndSend(Ferdie),45 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46 ]);46 await Promise.all([47 const itemBefore: any = await api.query.nft.nftItemList(collectionId, itemId);47 changeOwner.signAndSend(Alice),48 expect(itemBefore.owner).not.to.be.eq(Bob.address);48 approve.signAndSend(Bob),49 await waitNewBlocks(2);49 sendItem.signAndSend(Ferdie),50 });50 ]);51 });51 const itemBefore: any = await api.query.nft.nftItemList(collectionId, itemId);52});52 expect(itemBefore.owner).not.to.be.eq(Bob.address);5353 await waitNewBlocks(2);54 });55 });56});57*/tests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createItemExpectSuccess,8import privateKey from '../substrate/privateKey';9 normalizeAccountId,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10 waitNewBlocks,10import {11} from '../util/helpers';11 createCollectionExpectSuccess,1212 createItemExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;161717chai.use(chaiAsPromised);18before(async () => {18const expect = chai.expect;19 await usingApi(async () => {19let Alice: IKeyringPair;20 Alice = privateKey('//Alice');20let Bob: IKeyringPair;21 Bob = privateKey('//Bob');2122 });22before(async () => {23});23 await usingApi(async () => {2424 Alice = privateKey('//Alice');25describe('Admin vs Owner changes the data in the token: ', () => {25 Bob = privateKey('//Bob');26 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 () => {26 });27 await usingApi(async (api) => {27});28 const AliceData = 1;2829 const BobData = 2;29describe('Admin vs Owner changes the data in the token: ', () => {30 const collectionId = await createCollectionExpectSuccess();30 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 () => {31 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));31 await usingApi(async (api) => {32 await submitTransactionAsync(Alice, changeAdminTx);32 const AliceData = 1;33 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');33 const BobData = 2;34 //34 const collectionId = await createCollectionExpectSuccess();35 // tslint:disable-next-line: max-line-length35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());36 await submitTransactionAsync(Alice, changeAdminTx);37 // tslint:disable-next-line: max-line-length37 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');38 const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());38 //39 await Promise.all([39 // tslint:disable-next-line: max-line-length40 AliceTx.signAndSend(Alice),40 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());41 BobTx.signAndSend(Bob),41 // tslint:disable-next-line: max-line-length42 ]);42 const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());43 const item: any = await api.query.nft.nftItemList(collectionId, itemId);43 await Promise.all([44 expect(item.variableData).not.to.be.eq(null); // Pseudo-random selection of one of two values44 AliceTx.signAndSend(Alice),45 await waitNewBlocks(2);45 BobTx.signAndSend(Bob),46 });46 ]);47 });47 const item: any = await api.query.nft.nftItemList(collectionId, itemId);48});48 expect(item.variableData).not.to.be.eq(null); // Pseudo-random selection of one of two values4949 await waitNewBlocks(2);50 });51 });52});53*/tests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createItemExpectSuccess,8import privateKey from '../substrate/privateKey';9 normalizeAccountId,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10 waitNewBlocks,10import {11} from '../util/helpers';11 createCollectionExpectSuccess,1212 createItemExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;1617let Ferdie: IKeyringPair;17chai.use(chaiAsPromised);1818const expect = chai.expect;19before(async () => {19let Alice: IKeyringPair;20 await usingApi(async () => {20let Bob: IKeyringPair;21 Alice = privateKey('//Alice');21let Ferdie: IKeyringPair;22 Bob = privateKey('//Bob');2223 Ferdie = privateKey('//Ferdie');23before(async () => {24 });24 await usingApi(async () => {25});25 Alice = privateKey('//Alice');2626 Bob = privateKey('//Bob');27describe('Admin vs Owner take token: ', () => {27 Ferdie = privateKey('//Ferdie');28 // tslint:disable-next-line: max-line-length28 });29 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {29});30 await usingApi(async (api) => {3031 const collectionId = await createCollectionExpectSuccess();31describe('Admin vs Owner take token: ', () => {32 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));32 // tslint:disable-next-line: max-line-length33 await submitTransactionAsync(Alice, changeAdminTx);33 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {34 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');34 await usingApi(async (api) => {35 //35 const collectionId = await createCollectionExpectSuccess();36 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);36 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));37 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);37 await submitTransactionAsync(Alice, changeAdminTx);38 await Promise.all([38 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');39 sendItem.signAndSend(Bob),39 //40 burnItem.signAndSend(Alice),40 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);41 ]);41 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);42 await waitNewBlocks(2);42 await Promise.all([43 let itemBurn = false;43 sendItem.signAndSend(Bob),44 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;44 burnItem.signAndSend(Alice),45 // tslint:disable-next-line: no-unused-expression45 ]);46 expect(itemBurn).to.be.null;46 await waitNewBlocks(2);47 await waitNewBlocks(2);47 let itemBurn = false;48 });48 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;49 });49 // tslint:disable-next-line: no-unused-expression50});50 expect(itemBurn).to.be.null;5151 await waitNewBlocks(2);52 });53 });54});55*/tests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 normalizeAccountId,8import privateKey from '../substrate/privateKey';9 waitNewBlocks,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10} from '../util/helpers';10import {1111 createCollectionExpectSuccess,12chai.use(chaiAsPromised);12 normalizeAccountId,13const expect = chai.expect;13 waitNewBlocks,14let Alice: IKeyringPair;14} from '../util/helpers';15let Bob: IKeyringPair;1516let Ferdie: IKeyringPair;16chai.use(chaiAsPromised);1717const expect = chai.expect;18before(async () => {18let Alice: IKeyringPair;19 await usingApi(async () => {19let Bob: IKeyringPair;20 Alice = privateKey('//Alice');20let Ferdie: IKeyringPair;21 Bob = privateKey('//Bob');2122 Ferdie = privateKey('//Ferdie');22before(async () => {23 });23 await usingApi(async () => {24});24 Alice = privateKey('//Alice');2525 Bob = privateKey('//Bob');26describe('Deleting a collection while add address to whitelist: ', () => {26 Ferdie = privateKey('//Ferdie');27 // tslint:disable-next-line: max-line-length27 });28 it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {28});29 await usingApi(async (api) => {2930 const collectionId = await createCollectionExpectSuccess();30describe('Deleting a collection while add address to whitelist: ', () => {31 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));31 // tslint:disable-next-line: max-line-length32 await submitTransactionAsync(Alice, changeAdminTx);32 it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {33 await waitNewBlocks(1);33 await usingApi(async (api) => {34 //34 const collectionId = await createCollectionExpectSuccess();35 const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Ferdie.address));35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 const destroyCollection = api.tx.nft.destroyCollection(collectionId);36 await submitTransactionAsync(Alice, changeAdminTx);37 await Promise.all([37 await waitNewBlocks(1);38 addWhitelistAdm.signAndSend(Bob),38 //39 destroyCollection.signAndSend(Alice),39 const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Ferdie.address));40 ]);40 const destroyCollection = api.tx.nft.destroyCollection(collectionId);41 await waitNewBlocks(1);41 await Promise.all([42 let whiteList = false;42 addWhitelistAdm.signAndSend(Bob),43 whiteList = (await api.query.nft.whiteList(collectionId, Ferdie.address)).toJSON() as boolean;43 destroyCollection.signAndSend(Alice),44 // tslint:disable-next-line: no-unused-expression44 ]);45 expect(whiteList).to.be.false;45 await waitNewBlocks(1);46 await waitNewBlocks(2);46 let whiteList = false;47 });47 whiteList = (await api.query.nft.whiteList(collectionId, Ferdie.address)).toJSON() as boolean;48 });48 // tslint:disable-next-line: no-unused-expression49});49 expect(whiteList).to.be.false;5050 await waitNewBlocks(2);51 });52 });53});54*/tests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 normalizeAccountId,8import privateKey from '../substrate/privateKey';9 waitNewBlocks,9import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';10} from '../util/helpers';10import {1111 createCollectionExpectSuccess,12chai.use(chaiAsPromised);12 normalizeAccountId,13const expect = chai.expect;13 waitNewBlocks,14let Alice: IKeyringPair;14} from '../util/helpers';15let Bob: IKeyringPair;1516let Ferdie: IKeyringPair;16chai.use(chaiAsPromised);17let Charlie: IKeyringPair;17const expect = chai.expect;18let Eve: IKeyringPair;18let Alice: IKeyringPair;19let Dave: IKeyringPair;19let Bob: IKeyringPair;2020let Ferdie: IKeyringPair;21before(async () => {21let Charlie: IKeyringPair;22 await usingApi(async () => {22let Eve: IKeyringPair;23 Alice = privateKey('//Alice');23let Dave: IKeyringPair;24 Bob = privateKey('//Bob');2425 Ferdie = privateKey('//Ferdie');25before(async () => {26 Charlie = privateKey('//Charlie');26 await usingApi(async () => {27 Eve = privateKey('//Eve');27 Alice = privateKey('//Alice');28 Dave = privateKey('//Dave');28 Bob = privateKey('//Bob');29 });29 Ferdie = privateKey('//Ferdie');30});30 Charlie = privateKey('//Charlie');3131 Eve = privateKey('//Eve');32describe('Admin limit exceeded collection: ', () => {32 Dave = privateKey('//Dave');33 // tslint:disable-next-line: max-line-length33 });34 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {34});35 await usingApi(async (api) => {3536 const collectionId = await createCollectionExpectSuccess();36describe('Admin limit exceeded collection: ', () => {3737 // tslint:disable-next-line: max-line-length38 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();38 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {39 expect(chainAdminLimit).to.be.equal(5);39 await usingApi(async (api) => {4040 const collectionId = await createCollectionExpectSuccess();41 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));4142 await submitTransactionAsync(Alice, changeAdminTx1);42 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();43 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));43 expect(chainAdminLimit).to.be.equal(5);44 await submitTransactionAsync(Alice, changeAdminTx2);4445 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));45 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));46 await submitTransactionAsync(Alice, changeAdminTx3);46 await submitTransactionAsync(Alice, changeAdminTx1);4747 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));48 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));48 await submitTransactionAsync(Alice, changeAdminTx2);49 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));49 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));50 await Promise.all([50 await submitTransactionAsync(Alice, changeAdminTx3);51 addAdmOne.signAndSend(Bob),5152 addAdmTwo.signAndSend(Alice),52 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));53 ]);53 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));54 await waitNewBlocks(2);54 await Promise.all([55 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));55 addAdmOne.signAndSend(Bob),56 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;56 addAdmTwo.signAndSend(Alice),5757 ]);58 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));58 await waitNewBlocks(2);59 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));59 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));60 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));60 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;61 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));6162 await waitNewBlocks(2);62 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));63 });63 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));64 });64 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));65});65 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));6666 await waitNewBlocks(2);67 });68 });69});70*/tests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth1/* obsolete1/* broken by design22// substrate transactions are sequential, not parallel3// the order of execution is indeterminate43import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';4import BN from 'bn.js';6import BN from 'bn.js';5import chai from 'chai';7import chai from 'chai';6import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';7import privateKey from '../substrate/privateKey';9import privateKey from '../substrate/privateKey';8import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';9import {11import {10 createCollectionExpectSuccess,12 createCollectionExpectSuccess,11 normalizeAccountId,13 normalizeAccountId,12 waitNewBlocks,14 waitNewBlocks,13} from '../util/helpers';15} from '../util/helpers';141615chai.use(chaiAsPromised);17chai.use(chaiAsPromised);16const expect = chai.expect;18const expect = chai.expect;17let Alice: IKeyringPair;19let Alice: IKeyringPair;18let Bob: IKeyringPair;20let Bob: IKeyringPair;192120before(async () => {22before(async () => {21 await usingApi(async () => {23 await usingApi(async () => {22 Alice = privateKey('//Alice');24 Alice = privateKey('//Alice');23 Bob = privateKey('//Bob');25 Bob = privateKey('//Bob');24 });26 });25});27});262827describe('Deprivation of admin rights: ', () => {29describe('Deprivation of admin rights: ', () => {28 // tslint:disable-next-line: max-line-length30 // tslint:disable-next-line: max-line-length29 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {31 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {30 await usingApi(async (api) => {32 await usingApi(async (api) => {31 const collectionId = await createCollectionExpectSuccess();33 const collectionId = await createCollectionExpectSuccess();32 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));34 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));33 await submitTransactionAsync(Alice, changeAdminTx);35 await submitTransactionAsync(Alice, changeAdminTx);34 await waitNewBlocks(1);36 await waitNewBlocks(1);35 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];37 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];36 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);38 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);37 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));39 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));38 await Promise.all([40 await Promise.all([39 addItemAdm.signAndSend(Bob),41 addItemAdm.signAndSend(Bob),40 removeAdm.signAndSend(Alice),42 removeAdm.signAndSend(Alice),41 ]);43 ]);42 await waitNewBlocks(2);44 await waitNewBlocks(2);43 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;45 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;44 expect(itemsListIndex.toNumber()).to.be.equal(0);46 expect(itemsListIndex.toNumber()).to.be.equal(0);45 const adminList: any = (await api.query.nft.adminList(collectionId));47 const adminList: any = (await api.query.nft.adminList(collectionId));46 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));48 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));47 await waitNewBlocks(2);49 await waitNewBlocks(2);48 });50 });49 });51 });50});52});5153*/52*/tests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 setCollectionSponsorExpectSuccess,8import privateKey from '../substrate/privateKey';9 waitNewBlocks,9import usingApi from '../substrate/substrate-api';10} from '../util/helpers';10import {1111 createCollectionExpectSuccess,12chai.use(chaiAsPromised);12 setCollectionSponsorExpectSuccess,13const expect = chai.expect;13 waitNewBlocks,14let Alice: IKeyringPair;14} from '../util/helpers';15let Bob: IKeyringPair;1516let Ferdie: IKeyringPair;16chai.use(chaiAsPromised);1717const expect = chai.expect;18before(async () => {18let Alice: IKeyringPair;19 await usingApi(async () => {19let Bob: IKeyringPair;20 Alice = privateKey('//Alice');20let Ferdie: IKeyringPair;21 Bob = privateKey('//Bob');2122 Ferdie = privateKey('//Ferdie');22before(async () => {23 });23 await usingApi(async () => {24});24 Alice = privateKey('//Alice');2525 Bob = privateKey('//Bob');26describe('Sponsored with new owner ', () => {26 Ferdie = privateKey('//Ferdie');27 // tslint:disable-next-line: max-line-length27 });28 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {28});29 await usingApi(async (api) => {2930 const collectionId = await createCollectionExpectSuccess();30describe('Sponsored with new owner ', () => {31 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);31 // tslint:disable-next-line: max-line-length32 await waitNewBlocks(2);32 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {33 const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);33 await usingApi(async (api) => {34 const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);34 const collectionId = await createCollectionExpectSuccess();35 await Promise.all([35 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);36 confirmSponsorship.signAndSend(Bob),36 await waitNewBlocks(2);37 changeCollectionOwner.signAndSend(Alice),37 const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);38 ]);38 const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);39 await waitNewBlocks(2);39 await Promise.all([40 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();40 confirmSponsorship.signAndSend(Bob),41 expect(collection.sponsorship.confirmed).to.be.eq(Bob.address);41 changeCollectionOwner.signAndSend(Alice),42 expect(collection.owner).to.be.eq(Ferdie.address);42 ]);43 await waitNewBlocks(2);43 await waitNewBlocks(2);44 });44 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();45 });45 expect(collection.sponsorship.confirmed).to.be.eq(Bob.address);46});46 expect(collection.owner).to.be.eq(Ferdie.address);4747 await waitNewBlocks(2);48 });49 });50});51*/tests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import { alicesPublicKey, bobsPublicKey } from '../accounts';45import getBalance from '../substrate/get-balance';5import { IKeyringPair } from '@polkadot/types/types';6import privateKey from '../substrate/privateKey';6import chai from 'chai';7import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';7import chaiAsPromised from 'chai-as-promised';8import {8import { alicesPublicKey, bobsPublicKey } from '../accounts';9 confirmSponsorshipExpectSuccess,9import getBalance from '../substrate/get-balance';10 createCollectionExpectSuccess,10import privateKey from '../substrate/privateKey';11 createItemExpectSuccess,11import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';12 setCollectionSponsorExpectSuccess,12import {13 normalizeAccountId,13 confirmSponsorshipExpectSuccess,14 waitNewBlocks,14 createCollectionExpectSuccess,15} from '../util/helpers';15 createItemExpectSuccess,1616 setCollectionSponsorExpectSuccess,17chai.use(chaiAsPromised);17 normalizeAccountId,18const expect = chai.expect;18 waitNewBlocks,19let Alice: IKeyringPair;19} from '../util/helpers';20let Bob: IKeyringPair;202121chai.use(chaiAsPromised);22before(async () => {22const expect = chai.expect;23 await usingApi(async () => {23let Alice: IKeyringPair;24 Alice = privateKey('//Alice');24let Bob: IKeyringPair;25 Bob = privateKey('//Bob');2526 });26before(async () => {27});27 await usingApi(async () => {2828 Alice = privateKey('//Alice');29describe('Payment of commission if one block: ', () => {29 Bob = privateKey('//Bob');30 // tslint:disable-next-line: max-line-length30 });31 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 () => {31});32 await usingApi(async (api) => {3233 const collectionId = await createCollectionExpectSuccess();33describe('Payment of commission if one block: ', () => {34 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));34 // tslint:disable-next-line: max-line-length35 await submitTransactionAsync(Alice, changeAdminTxBob);35 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 () => {36 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');36 await usingApi(async (api) => {37 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);37 const collectionId = await createCollectionExpectSuccess();38 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');38 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));3939 await submitTransactionAsync(Alice, changeAdminTxBob);40 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);40 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');41 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);41 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);42 const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);42 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');43 await Promise.all([4344 sendItem.signAndSend(Bob),44 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);45 revokeSponsor.signAndSend(Alice),45 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46 ]);46 const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);47 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);47 await Promise.all([48 // tslint:disable-next-line:no-unused-expression48 sendItem.signAndSend(Bob),49 expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;49 revokeSponsor.signAndSend(Alice),50 // tslint:disable-next-line:no-unused-expression50 ]);51 expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;51 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);52 await waitNewBlocks(2);52 // tslint:disable-next-line:no-unused-expression53 });53 expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;54 });54 // tslint:disable-next-line:no-unused-expression55});55 expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;5656 await waitNewBlocks(2);57 });58 });59});60*/tests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth1/* obsolete1/* broken by design2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate42import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';3import BN from 'bn.js';6import BN from 'bn.js';4import chai from 'chai';7import chai from 'chai';5import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';6import privateKey from '../substrate/privateKey';9import privateKey from '../substrate/privateKey';7import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';8import {11import {9 addToWhiteListExpectSuccess,12 addToWhiteListExpectSuccess,10 createCollectionExpectSuccess,13 createCollectionExpectSuccess,11 getCreateItemResult,14 getCreateItemResult,12 setMintPermissionExpectSuccess,15 setMintPermissionExpectSuccess,13 normalizeAccountId,16 normalizeAccountId,14 waitNewBlocks,17 waitNewBlocks,15} from '../util/helpers';18} from '../util/helpers';161917chai.use(chaiAsPromised);20chai.use(chaiAsPromised);18const expect = chai.expect;21const expect = chai.expect;19let Alice: IKeyringPair;22let Alice: IKeyringPair;20let Bob: IKeyringPair;23let Bob: IKeyringPair;21let Ferdie: IKeyringPair;24let Ferdie: IKeyringPair;222523const accountTokenOwnershipLimit = 4;26const accountTokenOwnershipLimit = 4;24const sponsoredMintSize = 4294967295;27const sponsoredMintSize = 4294967295;25const tokenLimit = 4;28const tokenLimit = 4;26const sponsorTimeout = 14400;29const sponsorTimeout = 14400;27const ownerCanTransfer = false;30const ownerCanTransfer = false;28const ownerCanDestroy = false;31const ownerCanDestroy = false;293230before(async () => {33before(async () => {31 await usingApi(async () => {34 await usingApi(async () => {32 Alice = privateKey('//Alice');35 Alice = privateKey('//Alice');33 Bob = privateKey('//Bob');36 Bob = privateKey('//Bob');34 Ferdie = privateKey('//Ferdie');37 Ferdie = privateKey('//Ferdie');35 });38 });36});39});374038describe('Token limit exceeded collection: ', () => {41describe('Token limit exceeded collection: ', () => {39 // tslint:disable-next-line: max-line-length42 // tslint:disable-next-line: max-line-length40 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {43 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {41 await usingApi(async (api) => {44 await usingApi(async (api) => {42 const collectionId = await createCollectionExpectSuccess();45 const collectionId = await createCollectionExpectSuccess();43 await setMintPermissionExpectSuccess(Alice, collectionId, true);46 await setMintPermissionExpectSuccess(Alice, collectionId, true);44 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);47 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);45 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);48 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);46 const setCollectionLim = api.tx.nft.setCollectionLimits(49 const setCollectionLim = api.tx.nft.setCollectionLimits(47 collectionId,50 collectionId,48 {51 {49 accountTokenOwnershipLimit,52 accountTokenOwnershipLimit,50 sponsoredMintSize,53 sponsoredMintSize,51 tokenLimit,54 tokenLimit,52 // tslint:disable-next-line: object-literal-sort-keys55 // tslint:disable-next-line: object-literal-sort-keys53 sponsorTimeout,56 sponsorTimeout,54 ownerCanTransfer,57 ownerCanTransfer,55 ownerCanDestroy,58 ownerCanDestroy,56 },59 },57 );60 );58 const subTx = await submitTransactionAsync(Alice, setCollectionLim);61 const subTx = await submitTransactionAsync(Alice, setCollectionLim);59 const subTxTesult = getCreateItemResult(subTx);62 const subTxTesult = getCreateItemResult(subTx);60 // tslint:disable-next-line:no-unused-expression63 // tslint:disable-next-line:no-unused-expression61 expect(subTxTesult.success).to.be.true;64 expect(subTxTesult.success).to.be.true;62 await waitNewBlocks(2);65 await waitNewBlocks(2);636664 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];67 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];65 const mintItemOne = api.tx.nft68 const mintItemOne = api.tx.nft66 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);67 const mintItemTwo = api.tx.nft70 const mintItemTwo = api.tx.nft68 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);71 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);69 await Promise.all([72 await Promise.all([70 mintItemOne.signAndSend(Ferdie),73 mintItemOne.signAndSend(Ferdie),71 mintItemTwo.signAndSend(Bob),74 mintItemTwo.signAndSend(Bob),72 ]);75 ]);73 await waitNewBlocks(2);76 await waitNewBlocks(2);74 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;77 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;75 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);78 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);76 // TokenLimit = 4. The first transaction is successful. The second should fail.79 // TokenLimit = 4. The first transaction is successful. The second should fail.77 await waitNewBlocks(2);80 await waitNewBlocks(2);78 });81 });79 });82 });80});83});81*/84*/8285tests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 addToWhiteListExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createCollectionExpectSuccess,8import privateKey from '../substrate/privateKey';9 setMintPermissionExpectSuccess,9import usingApi from '../substrate/substrate-api';10 normalizeAccountId,10import {11 waitNewBlocks,11 addToWhiteListExpectSuccess,12} from '../util/helpers';12 createCollectionExpectSuccess,1313 setMintPermissionExpectSuccess,14chai.use(chaiAsPromised);14 normalizeAccountId,15const expect = chai.expect;15 waitNewBlocks,16let Alice: IKeyringPair;16} from '../util/helpers';17let Ferdie: IKeyringPair;171818chai.use(chaiAsPromised);19before(async () => {19const expect = chai.expect;20 await usingApi(async () => {20let Alice: IKeyringPair;21 Alice = privateKey('//Alice');21let Ferdie: IKeyringPair;22 Ferdie = privateKey('//Ferdie');2223 });23before(async () => {24});24 await usingApi(async () => {2525 Alice = privateKey('//Alice');26describe('Turns off minting mode: ', () => {26 Ferdie = privateKey('//Ferdie');27 // tslint:disable-next-line: max-line-length27 });28 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {28});29 await usingApi(async (api) => {2930 const collectionId = await createCollectionExpectSuccess();30describe('Turns off minting mode: ', () => {31 await setMintPermissionExpectSuccess(Alice, collectionId, true);31 // tslint:disable-next-line: max-line-length32 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);32 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {3333 await usingApi(async (api) => {34 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');34 const collectionId = await createCollectionExpectSuccess();35 const offMinting = api.tx.nft.setMintPermission(collectionId, false);35 await setMintPermissionExpectSuccess(Alice, collectionId, true);36 await Promise.all([36 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);37 mintItem.signAndSend(Ferdie),3738 offMinting.signAndSend(Alice),38 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');39 ]);39 const offMinting = api.tx.nft.setMintPermission(collectionId, false);40 let itemList = false;40 await Promise.all([41 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;41 mintItem.signAndSend(Ferdie),42 // tslint:disable-next-line: no-unused-expression42 offMinting.signAndSend(Alice),43 expect(itemList).to.be.null;43 ]);44 await waitNewBlocks(2);44 let itemList = false;45 });45 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;46 });46 // tslint:disable-next-line: no-unused-expression47});47 expect(itemList).to.be.null;4848 await waitNewBlocks(2);49 });50 });51});52*/