From 4eaa88907f7a36ed38b928032291e02b7b327acb Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 27 Oct 2023 00:19:48 +0000 Subject: [PATCH] test: xcm nft with karura --- --- a/js-packages/tests/xcm/xcmQuartz.test.ts +++ b/js-packages/tests/xcm/xcmQuartz.test.ts @@ -782,6 +782,125 @@ accountBalance = await helper.balance.getSubstrate(targetAccount.address); expect(accountBalance).to.be.equal(0n); }); + + itSub.skip('Transfer NFT from Quartz to Karura', async ({helper}) => { + const collection = await helper.nft.mintCollection(alice, { + tokenPrefix: 'xNFT', + }); + + const collectionId = collection.collectionId; + + await usingKaruraPlaygrounds(karuraUrl, async (helper) => { + const uniqueCollectionLocation = { + parents: 1, + interior: { + X2: [ + { + Parachain: QUARTZ_CHAIN, + }, + { + GeneralIndex: collectionId, + }, + ], + }, + }; + + await helper.executeExtrinsic( + alice, + 'api.tx.xnft.registerAsset', + [{ + Concrete: uniqueCollectionLocation, + }], + ); + }); + + const token = await collection.mintToken(alice, {Substrate: alice.address}); + const tokenId = token.tokenId; + + const destination = { + V3: { + parents: 1, + interior: { + X1: { + Parachain: KARURA_CHAIN, + }, + }, + }, + }; + + const beneficiary = { + V3: { + parents: 0, + interior: { + X1: { + AccountId32: { + network: null, + id: randomAccount.addressRaw, + }, + }, + }, + }, + }; + + const buyExecutionFee = 10n * 10n ** QTZ_DECIMALS; + + const assets = { + V3: [ + { + id: { + Concrete: { + parents: 0, + interior: 'Here', + }, + }, + fun: { + Fungible: buyExecutionFee, + }, + }, + { + id: { + Concrete: { + parents: 1, + interior: { + X2: [ + { + Parachain: QUARTZ_CHAIN, + }, + { + GeneralIndex: collectionId, + }, + ], + }, + }, + }, + fun: { + NonFungible: { + Index: tokenId, + }, + }, + }, + ], + }; + + const feeAssetItem = 0; + + await helper.xcm.limitedReserveTransferAssets( + alice, + destination, + beneficiary, + assets, + feeAssetItem, + 'Unlimited', + ); + + const maxWaitBlocks = 3; + const messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent); + + await usingKaruraPlaygrounds(karuraUrl, async (helper) => { + const xcmpSuccess = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Success); + expect(xcmpSuccess.messageHash).to.be.equal(messageSent.messageSent); + }); + }); }); // These tests are relevant only when -- gitstuff