git.delta.rocks / unique-network / refs/commits / 076b5dc181ef

difftreelog

transferFromEvent migrated

rkv2022-09-26parent: #508677d.patch.diff
in: master

1 file changed

modifiedtests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits17// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
18import {ApiPromise} from '@polkadot/api';
19import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';
20import chai from 'chai';
21import chaiAsPromised from 'chai-as-promised';
22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';19import {executeTransaction} from '../substrate/substrate-api';
23import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';20import {uniqueEventMessage, normalizeAccountId} from '../util/helpers';
24
25chai.use(chaiAsPromised);
26const expect = chai.expect;21import {usingPlaygrounds, expect, itSub} from '../util/playgrounds';
2722
28describe('Transfer from event ', () => {23describe('Transfer event ', () => {
29 let alice: IKeyringPair;24 let alice: IKeyringPair;
30 let bob: IKeyringPair;25 let bob: IKeyringPair;
31 const checkSection = 'Transfer';26 const checkSection = 'Transfer';
32 const checkTreasury = 'Deposit';27 const checkTreasury = 'Deposit';
33 const checkSystem = 'ExtrinsicSuccess';28 const checkSystem = 'ExtrinsicSuccess';
29
34 before(async () => {30 before(async () => {
35 await usingApi(async (api, privateKeyWrapper) => {31 await usingPlaygrounds(async (helper, privateKey) => {
36 alice = privateKeyWrapper('//Alice');32 const donor = privateKey('//Alice');
37 bob = privateKeyWrapper('//Bob');33 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);
38 });34 });
39 });35 });
36
40 it('Check event from transferFrom(): ', async () => {37 itSub('Check event from transfer(): ', async ({helper}) => {
41 await usingApi(async (api: ApiPromise) => {38 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
39 const {tokenId} = await collection.mintToken(alice, {Substrate: alice.address});
42 const collectionID = await createCollectionExpectSuccess();40 const transferTx = helper.api!.tx.unique.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collection.collectionId, tokenId, 1);
43 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');
44 const transferFrom = api.tx.unique.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collectionID, itemID, 1);
45 const events = await submitTransactionAsync(alice, transferFrom);41 const events = await executeTransaction(helper.api!, alice, transferTx);
46 const msg = JSON.stringify(uniqueEventMessage(events));42 const msg = JSON.stringify(uniqueEventMessage(events));
47 expect(msg).to.be.contain(checkSection);43 expect(msg).to.be.contain(checkSection);
48 expect(msg).to.be.contain(checkTreasury);44 expect(msg).to.be.contain(checkTreasury);
49 expect(msg).to.be.contain(checkSystem);45 expect(msg).to.be.contain(checkSystem);
50 });
51 });46 });
52});47});
5348