git.delta.rocks / unique-network / refs/commits / 35ede417a4d0

difftreelog

source

tests/src/collision-tests/adminLimitsOff.test.ts2.7 KiBsourcehistory
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  normalizeAccountId,9  waitNewBlocks,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  // tslint:disable-next-line: max-line-length34  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 addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));49      const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));50      await Promise.all([51        addAdmOne.signAndSend(Bob),52        addAdmTwo.signAndSend(Alice),53      ]);54      await waitNewBlocks(2);55      const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));56      await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5758      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));59      expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));60      expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));61      expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));62      await waitNewBlocks(2);63    });64  });65});