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

difftreelog

source

tests/src/collision-tests/adminRightsOff.test.ts1.9 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 } from '../substrate/substrate-api';7import {8  createCollectionExpectSuccess,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13let Alice: IKeyringPair;14let Bob: IKeyringPair;1516before(async () => {17  await usingApi(async () => {18    Alice = privateKey('//Alice');19    Bob = privateKey('//Bob');20  });21});2223describe('Deprivation of admin rights: ', () => {24  // tslint:disable-next-line: max-line-length25  it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {26    await usingApi(async (api) => {27      const collectionId = await createCollectionExpectSuccess();28      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);29      await submitTransactionAsync(Alice, changeAdminTx);30      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));31      await timeoutPromise(10000);32      const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];33      const addItemAdm = api.tx.nft.createMultipleItems(collectionId, Bob.address, args);34      const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);35      await Promise.all([36        addItemAdm.signAndSend(Bob),37        removeAdm.signAndSend(Alice),38      ]);39      await timeoutPromise(10000);40      const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;41      expect(itemsListIndex.toNumber()).to.be.equal(0);42      const adminList: any = (await api.query.nft.adminList(collectionId));43      expect(adminList).not.to.be.contains(Bob.address);44      await timeoutPromise(20000);45    });46  });47});