Skip to content

Commit

Permalink
test: xcm nft with karura
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshiposha committed Oct 27, 2023
1 parent 4e0f363 commit 29310e8
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions tests/src/xcm/xcmQuartz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,125 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Karura', () => {
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
Expand Down

0 comments on commit 29310e8

Please sign in to comment.