git.delta.rocks / unique-network / refs/commits / 2203d0f0ed69

difftreelog

source

tests/src/collision-tests/admVsOwnerTake.test.ts2.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 } from '../substrate/substrate-api';26import {27  createCollectionExpectSuccess,28  createItemExpectSuccess,29  normalizeAccountId,30  waitNewBlocks,31} from '../util/helpers';3233chai.use(chaiAsPromised);34const expect = chai.expect;35let Alice: IKeyringPair;36let Bob: IKeyringPair;37let Ferdie: IKeyringPair;3839before(async () => {40  await usingApi(async () => {41    Alice = privateKey('//Alice');42    Bob = privateKey('//Bob');43    Ferdie = privateKey('//Ferdie');44  });45});4647describe('Admin vs Owner take token: ', () => {48  // tslint:disable-next-line: max-line-length49  it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {50    await usingApi(async (api) => {51      const collectionId = await createCollectionExpectSuccess();52      const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));53      await submitTransactionAsync(Alice, changeAdminTx);54      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');55      //56      const sendItem = api.tx.unique.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);57      const burnItem = api.tx.unique.burnItem(collectionId, itemId, 1);58      await Promise.all([59        sendItem.signAndSend(Bob),60        burnItem.signAndSend(Alice),61      ]);62      await waitNewBlocks(2);63      let itemBurn = false;64      itemBurn = (await (api.query.unique.nftItemList(collectionId, itemId))).toJSON() as boolean;65      // tslint:disable-next-line: no-unused-expression66      expect(itemBurn).to.be.null;67      await waitNewBlocks(2);68    });69  });70});71*/