1import { IKeyringPair } from '@polkadot/types/types';2import BN from 'bn.js';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import privateKey from '../substrate/privateKey';6import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';7import {8 createCollectionExpectSuccess,9 normalizeAccountId,10} from '../util/helpers';1112chai.use(chaiAsPromised);13const expect = chai.expect;14let Alice: IKeyringPair;15let Bob: IKeyringPair;16let Ferdie: IKeyringPair;17let Charlie: IKeyringPair;18let Eve: IKeyringPair;19let Dave: IKeyringPair;2021before(async () => {22 await usingApi(async () => {23 Alice = privateKey('//Alice');24 Bob = privateKey('//Bob');25 Ferdie = privateKey('//Ferdie');26 Charlie = privateKey('//Charlie');27 Eve = privateKey('//Eve');28 Dave = privateKey('//Dave');29 });30});3132describe('Admin limit exceeded collection: ', () => {33 34 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {35 await usingApi(async (api) => {36 const collectionId = await createCollectionExpectSuccess();3738 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();39 expect(chainAdminLimit).to.be.equal(5);4041 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));42 await submitTransactionAsync(Alice, changeAdminTx1);43 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));44 await submitTransactionAsync(Alice, changeAdminTx2);45 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));46 await submitTransactionAsync(Alice, changeAdminTx3);4748 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));49 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));50 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));51 await Promise.all([52 addAdmOne.signAndSend(Bob),53 addAdmTwo.signAndSend(Alice),54 ]);55 await timeoutPromise(20000);56 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));57 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5859 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));60 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));61 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));62 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));63 await timeoutPromise(20000);64 });65 });66});