git.delta.rocks / unique-network / refs/commits / b7be484eee9b

difftreelog

source

tests/src/collision-tests/adminLimitsOff.test.ts2.7 KiBsourcehistory
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  // tslint:disable-next-line: max-line-length33  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 chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();38      expect(chainAdminLimit).to.be.equal(5);3940      const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, Eve.address);41      await submitTransactionAsync(Alice, changeAdminTx1);42      const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, Dave.address);43      await submitTransactionAsync(Alice, changeAdminTx2);44      const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);45      await submitTransactionAsync(Alice, changeAdminTx3);4647      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));48      const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);49      const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);50      await Promise.all([51        addAdmOne.signAndSend(Bob),52        addAdmTwo.signAndSend(Alice),53      ]);54      await timeoutPromise(10000);55      const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, Alice.address);56      // tslint:disable-next-line: no-unused-expression57      expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5859      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));60      expect(adminListAfterAddAdmin).to.be.contains(Eve.address);61      expect(adminListAfterAddAdmin).to.be.contains(Ferdie.address);62      expect(adminListAfterAddAdmin).not.to.be.contains(Alice.address);63      await timeoutPromise(20000);64    });65  });66});