git.delta.rocks / unique-network / refs/commits / 73817f448a72

difftreelog

source

tests/src/collision-tests/adminLimitsOff.test.ts2.9 KiBsourcehistory
1/* broken by design2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate45import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';10import {11  createCollectionExpectSuccess,12  normalizeAccountId,13  waitNewBlocks,14} from '../util/helpers';1516chai.use(chaiAsPromised);17const expect = chai.expect;18let Alice: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;21let Charlie: IKeyringPair;22let Eve: IKeyringPair;23let Dave: IKeyringPair;2425before(async () => {26  await usingApi(async () => {27    Alice = privateKey('//Alice');28    Bob = privateKey('//Bob');29    Ferdie = privateKey('//Ferdie');30    Charlie = privateKey('//Charlie');31    Eve = privateKey('//Eve');32    Dave = privateKey('//Dave');33  });34});3536describe('Admin limit exceeded collection: ', () => {37  // tslint:disable-next-line: max-line-length38  it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {39    await usingApi(async (api) => {40      const collectionId = await createCollectionExpectSuccess();4142      const chainAdminLimit = (api.consts.unique.collectionAdminsLimit as any).toNumber();43      expect(chainAdminLimit).to.be.equal(5);4445      const changeAdminTx1 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));46      await submitTransactionAsync(Alice, changeAdminTx1);47      const changeAdminTx2 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));48      await submitTransactionAsync(Alice, changeAdminTx2);49      const changeAdminTx3 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));50      await submitTransactionAsync(Alice, changeAdminTx3);5152      const addAdmOne = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));53      const addAdmTwo = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));54      await Promise.all([55        addAdmOne.signAndSend(Bob),56        addAdmTwo.signAndSend(Alice),57      ]);58      await waitNewBlocks(2);59      const changeAdminTx4 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));60      await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;6162      const adminListAfterAddAdmin: any = (await api.query.unique.adminList(collectionId));63      expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));64      expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));65      expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));66      await waitNewBlocks(2);67    });68  });69});70*/