1import { IKeyringPair } from '@polkadot/types/types';2import chai from 'chai';3import chaiAsPromised from 'chai-as-promised';4import privateKey from '../substrate/privateKey';5import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';6import {7 createCollectionExpectSuccess,8} from '../util/helpers';910chai.use(chaiAsPromised);11const expect = chai.expect;12let Alice: IKeyringPair;13let Bob: IKeyringPair;14let Ferdie: IKeyringPair;15let Charlie: IKeyringPair;16let Eve: IKeyringPair;17let Dave: IKeyringPair;1819before(async () => {20 await usingApi(async () => {21 Alice = privateKey('//Alice');22 Bob = privateKey('//Bob');23 Ferdie = privateKey('//Ferdie');24 Charlie = privateKey('//Charlie');25 Eve = privateKey('//Eve');26 Dave = privateKey('//Dave');27 });28});2930describe('Admin limit exceeded collection: ', () => {31 32 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {33 await usingApi(async (api) => {34 const collectionId = await createCollectionExpectSuccess();3536 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();37 expect(chainAdminLimit).to.be.equal(5);3839 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, Eve.address);40 await submitTransactionAsync(Alice, changeAdminTx1);41 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, Dave.address);42 await submitTransactionAsync(Alice, changeAdminTx2);43 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);44 await submitTransactionAsync(Alice, changeAdminTx3);4546 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));47 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);48 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);49 await Promise.all([50 addAdmOne.signAndSend(Bob),51 addAdmTwo.signAndSend(Alice),52 ]);53 await timeoutPromise(10000);54 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, Alice.address);55 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5657 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));58 expect(adminListAfterAddAdmin).to.be.contains(Eve.address);59 expect(adminListAfterAddAdmin).to.be.contains(Ferdie.address);60 expect(adminListAfterAddAdmin).not.to.be.contains(Alice.address);61 await timeoutPromise(20000);62 });63 });64});