git.delta.rocks / unique-network / refs/commits / 70da175fb9fe

difftreelog

source

tests/src/collision-tests/admVsOwnerTake.test.ts1.8 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 } from '../substrate/substrate-api';6import {7  createCollectionExpectSuccess,8  createItemExpectSuccess,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13let Alice: IKeyringPair;14let Bob: IKeyringPair;15let Ferdie: IKeyringPair;1617before(async () => {18  await usingApi(async () => {19    Alice = privateKey('//Alice');20    Bob = privateKey('//Bob');21    Ferdie = privateKey('//Ferdie');22  });23});2425describe('Admin vs Owner take token: ', () => {26  // tslint:disable-next-line: max-line-length27  it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {28    await usingApi(async (api) => {29      const collectionId = await createCollectionExpectSuccess();30      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);31      await submitTransactionAsync(Alice, changeAdminTx);32      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));33      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');34      //35      const sendItem = api.tx.nft.transfer(Ferdie.address, collectionId, itemId, 1);36      const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);37      await Promise.all([38        sendItem.signAndSend(Bob),39        burnItem.signAndSend(Alice),40      ]);41      await timeoutPromise(10000);42      let itemBurn = false;43      itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;44      // tslint:disable-next-line: no-unused-expression45      expect(itemBurn).to.be.null;46      await timeoutPromise(20000);47    });48  });49});