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

difftreelog

source

tests/src/collision-tests/admVsOwnerChanges.test.ts2.2 KiBsourcehistory
1/* broken by design2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate45import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import {11  createCollectionExpectSuccess,12  createItemExpectSuccess,13  normalizeAccountId,14  waitNewBlocks,15} from '../util/helpers';1617chai.use(chaiAsPromised);18const expect = chai.expect;19let Alice: IKeyringPair;20let Bob: IKeyringPair;21let Ferdie: IKeyringPair;2223before(async () => {24  await usingApi(async () => {25    Alice = privateKey('//Alice');26    Bob = privateKey('//Bob');27    Ferdie = privateKey('//Ferdie');28  });29});3031describe('Admin vs Owner changes token: ', () => {32  // tslint:disable-next-line: max-line-length33  it('The collection admin changes the owner of the token and in the same block the current owner transfers the token to another address ', async () => {3435    await usingApi(async (api) => {36      const collectionId = await createCollectionExpectSuccess();37      const changeAdminTxBob = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));38      await submitTransactionAsync(Alice, changeAdminTxBob);39      const changeAdminTxFerdie = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));40      await submitTransactionAsync(Bob, changeAdminTxFerdie);41      const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');4243      const changeOwner = api.tx.unique.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);44      const approve = api.tx.unique.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);45      const sendItem = api.tx.unique.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46      await Promise.all([47        changeOwner.signAndSend(Alice),48        approve.signAndSend(Bob),49        sendItem.signAndSend(Ferdie),50      ]);51      const itemBefore: any = await api.query.unique.nftItemList(collectionId, itemId);52      expect(itemBefore.owner).not.to.be.eq(Bob.address);53      await waitNewBlocks(2);54    });55  });56});57*/