git.delta.rocks / unique-network / refs/commits / 2b9fe52ee469

difftreelog

source

tests/src/.outdated/collision-tests/adminLimitsOff.test.ts3.6 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617/* broken by design18// substrate transactions are sequential, not parallel19// the order of execution is indeterminate2021import { IKeyringPair } from '@polkadot/types/types';22import chai from 'chai';23import chaiAsPromised from 'chai-as-promised';24import privateKey from '../substrate/privateKey';25import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';26import {27  createCollectionExpectSuccess,28  normalizeAccountId,29  waitNewBlocks,30} from '../util/helpers';3132chai.use(chaiAsPromised);33const expect = chai.expect;34let Alice: IKeyringPair;35let Bob: IKeyringPair;36let Ferdie: IKeyringPair;37let Charlie: IKeyringPair;38let Eve: IKeyringPair;39let Dave: IKeyringPair;4041before(async () => {42  await usingApi(async () => {43    Alice = privateKey('//Alice');44    Bob = privateKey('//Bob');45    Ferdie = privateKey('//Ferdie');46    Charlie = privateKey('//Charlie');47    Eve = privateKey('//Eve');48    Dave = privateKey('//Dave');49  });50});5152describe('Admin limit exceeded collection: ', () => {53  // tslint:disable-next-line: max-line-length54  it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {55    await usingApi(async (api) => {56      const collectionId = await createCollectionExpectSuccess();5758      const chainAdminLimit = (api.consts.unique.collectionAdminsLimit as any).toNumber();59      expect(chainAdminLimit).to.be.equal(5);6061      const changeAdminTx1 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));62      await submitTransactionAsync(Alice, changeAdminTx1);63      const changeAdminTx2 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));64      await submitTransactionAsync(Alice, changeAdminTx2);65      const changeAdminTx3 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));66      await submitTransactionAsync(Alice, changeAdminTx3);6768      const addAdmOne = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));69      const addAdmTwo = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));70      await Promise.all([71        addAdmOne.signAndSend(Bob),72        addAdmTwo.signAndSend(Alice),73      ]);74      await waitNewBlocks(2);75      const changeAdminTx4 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));76      await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;7778      const adminListAfterAddAdmin: any = (await api.query.unique.adminList(collectionId));79      expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));80      expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));81      expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));82      await waitNewBlocks(2);83    });84  });85});86*/