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} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13let Alice: IKeyringPair;14let Bob: IKeyringPair;15let Ferdie: IKeyringPair;16let Charlie: IKeyringPair;17let Eve: IKeyringPair;18let Dave: IKeyringPair;1920before(async () => {21 await usingApi(async () => {22 Alice = privateKey('//Alice');23 Bob = privateKey('//Bob');24 Ferdie = privateKey('//Ferdie');25 Charlie = privateKey('//Charlie');26 Eve = privateKey('//Eve');27 Dave = privateKey('//Dave');28 });29});3031describe('Admin limit exceeded collection: ', () => {32 33 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {34 await usingApi(async (api) => {35 const collectionId = await createCollectionExpectSuccess();3637 const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };38 const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();39 expect(chainAdminLimit).to.be.equal(5);4041 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, Eve.address);42 await submitTransactionAsync(Alice, changeAdminTx1);43 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, Dave.address);44 await submitTransactionAsync(Alice, changeAdminTx2);45 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, 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, Ferdie.address);50 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);51 await Promise.all([52 addAdmOne.signAndSend(Bob),53 addAdmTwo.signAndSend(Alice),54 ]);55 await timeoutPromise(10000);56 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, Alice.address);57 58 expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5960 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));61 expect(adminListAfterAddAdmin).to.be.contains(Eve.address);62 expect(adminListAfterAddAdmin).to.be.contains(Ferdie.address);63 expect(adminListAfterAddAdmin).not.to.be.contains(Alice.address);64 await timeoutPromise(20000);65 });66 });67});