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

difftreelog

source

tests/src/.outdated/collision-tests/adminRightsOff.test.ts2.8 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 BN from 'bn.js';23import chai from 'chai';24import chaiAsPromised from 'chai-as-promised';25import privateKey from '../substrate/privateKey';26import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';27import {28  createCollectionExpectSuccess,29  normalizeAccountId,30  waitNewBlocks,31} from '../util/helpers';3233chai.use(chaiAsPromised);34const expect = chai.expect;35let Alice: IKeyringPair;36let Bob: IKeyringPair;3738before(async () => {39  await usingApi(async () => {40    Alice = privateKey('//Alice');41    Bob = privateKey('//Bob');42  });43});4445describe('Deprivation of admin rights: ', () => {46  // tslint:disable-next-line: max-line-length47  it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {48    await usingApi(async (api) => {49      const collectionId = await createCollectionExpectSuccess();50      const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));51      await submitTransactionAsync(Alice, changeAdminTx);52      await waitNewBlocks(1);53      const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];54      const addItemAdm = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);55      const removeAdm = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));56      await Promise.all([57        addItemAdm.signAndSend(Bob),58        removeAdm.signAndSend(Alice),59      ]);60      await waitNewBlocks(2);61      const itemsListIndex = await api.query.unique.itemListIndex(collectionId) as unknown as BN;62      expect(itemsListIndex.toNumber()).to.be.equal(0);63      const adminList: any = (await api.query.unique.adminList(collectionId));64      expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));65      await waitNewBlocks(2);66    });67  });68});69*/