From 076b5dc181efba926408e186aea1b55719d598d5 Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 26 Sep 2022 12:23:03 +0000 Subject: [PATCH] transferFromEvent migrated --- --- a/tests/src/check-event/transferFromEvent.test.ts +++ b/tests/src/check-event/transferFromEvent.test.ts @@ -15,38 +15,33 @@ // along with Unique Network. If not, see . // https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits -import {ApiPromise} from '@polkadot/api'; import {IKeyringPair} from '@polkadot/types/types'; -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import usingApi, {submitTransactionAsync} from '../substrate/substrate-api'; -import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers'; - -chai.use(chaiAsPromised); -const expect = chai.expect; +import {executeTransaction} from '../substrate/substrate-api'; +import {uniqueEventMessage, normalizeAccountId} from '../util/helpers'; +import {usingPlaygrounds, expect, itSub} from '../util/playgrounds'; -describe('Transfer from event ', () => { +describe('Transfer event ', () => { let alice: IKeyringPair; let bob: IKeyringPair; const checkSection = 'Transfer'; const checkTreasury = 'Deposit'; const checkSystem = 'ExtrinsicSuccess'; + before(async () => { - await usingApi(async (api, privateKeyWrapper) => { - alice = privateKeyWrapper('//Alice'); - bob = privateKeyWrapper('//Bob'); + await usingPlaygrounds(async (helper, privateKey) => { + const donor = privateKey('//Alice'); + [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor); }); }); - it('Check event from transferFrom(): ', async () => { - await usingApi(async (api: ApiPromise) => { - const collectionID = await createCollectionExpectSuccess(); - const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT'); - const transferFrom = api.tx.unique.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collectionID, itemID, 1); - const events = await submitTransactionAsync(alice, transferFrom); - const msg = JSON.stringify(uniqueEventMessage(events)); - expect(msg).to.be.contain(checkSection); - expect(msg).to.be.contain(checkTreasury); - expect(msg).to.be.contain(checkSystem); - }); + + itSub('Check event from transfer(): ', async ({helper}) => { + const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}); + const {tokenId} = await collection.mintToken(alice, {Substrate: alice.address}); + const transferTx = helper.api!.tx.unique.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collection.collectionId, tokenId, 1); + const events = await executeTransaction(helper.api!, alice, transferTx); + const msg = JSON.stringify(uniqueEventMessage(events)); + expect(msg).to.be.contain(checkSection); + expect(msg).to.be.contain(checkTreasury); + expect(msg).to.be.contain(checkSystem); }); }); -- gitstuff