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} from '../util/helpers';1112chai.use(chaiAsPromised);13const expect = chai.expect;14let Alice: IKeyringPair;15let Bob: IKeyringPair;1617before(async () => {18 await usingApi(async () => {19 Alice = privateKey('//Alice');20 Bob = privateKey('//Bob');21 });22});2324describe('Admin vs Owner changes the data in the token: ', () => {25 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 () => {26 await usingApi(async (api) => {27 const AliceData = 1;28 const BobData = 2;29 const collectionId = await createCollectionExpectSuccess();30 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(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 36 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());37 38 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); 45 await timeoutPromise(20000);46 });47 });48});