git.delta.rocks / unique-network / refs/commits / 1d12e73b766b

difftreelog

source

tests/src/collision-tests/admVsOwnerData.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  normalizeAccountId,10  waitNewBlocks,11} from '../util/helpers';1213chai.use(chaiAsPromised);14const expect = chai.expect;15let Alice: IKeyringPair;16let Bob: IKeyringPair;1718before(async () => {19  await usingApi(async () => {20    Alice = privateKey('//Alice');21    Bob = privateKey('//Bob');22  });23});2425describe('Admin vs Owner changes the data in the token: ', () => {26  it('The collection admin changes the data in the token and in the same block the token owner also changes the data in it ', async () => {27    await usingApi(async (api) => {28      const AliceData = 1;29      const BobData = 2;30      const collectionId = await createCollectionExpectSuccess();31      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));32      await submitTransactionAsync(Alice, changeAdminTx);33      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');34      //35      // tslint:disable-next-line: max-line-length36      const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());37      // tslint:disable-next-line: max-line-length38      const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());39      await Promise.all([40        AliceTx.signAndSend(Alice),41        BobTx.signAndSend(Bob),42      ]);43      const item: any = await api.query.nft.nftItemList(collectionId, itemId);44      expect(item.VariableData).not.to.be.eq(null); // Pseudo-random selection of one of two values45      await waitNewBlocks(2);46    });47  });48});