git.delta.rocks / unique-network / refs/commits / ce82ba0680fd

difftreelog

tests(parallel): fix phantom errors

Fahrrader2022-10-11parent: #d52c8f5.patch.diff
in: master

7 files changed

modifiedtests/src/approve.test.tsdiffbeforeafterboth
--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -227,7 +227,7 @@
   });
 });
 
-describe('Approved amount decreases by the transferred amount.:', () => {
+describe('Approved amount decreases by the transferred amount:', () => {
   let alice: IKeyringPair;
   let bob: IKeyringPair;
   let charlie: IKeyringPair;
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -73,7 +73,7 @@
   });
 
   itSub('Fungible: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {
-    const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+    const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.setSponsor(alice, bob.address);
     await collection.confirmSponsorship(bob);
     const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
@@ -163,7 +163,10 @@
   });
 
   itSub('NFT: Sponsoring of createItem is rate limited', async ({helper}) => {
-    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL', limits: {
+      sponsoredDataRateLimit: {blocks: 1000},
+      sponsorTransferTimeout: 1000,
+    }});
     await collection.setSponsor(alice, bob.address);
     await collection.confirmSponsorship(bob);
     await collection.setPermissions(alice, {mintMode: true, access: 'AllowList'});
@@ -195,7 +198,7 @@
   });
 
   itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {
-    const collectionId = 1_000_000;
+    const collectionId = (1 << 32) - 1;
     const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
   });
modifiedtests/src/deprecated-helpers/helpers.tsdiffbeforeafterboth
--- a/tests/src/deprecated-helpers/helpers.ts
+++ b/tests/src/deprecated-helpers/helpers.ts
@@ -1764,11 +1764,11 @@
   return (await api.rpc.unique.collectionById(collectionId)).unwrap();
 }
 
-/*export const describe_xcm = (
+export const describeXCM = (
   process.env.RUN_XCM_TESTS
     ? describe
     : describe.skip
-);*/
+);
 
 export async function waitNewBlocks(blocksCount = 1): Promise<void> {
   await usingApi(async (api) => {
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -62,7 +62,7 @@
       .to.eventually.be.rejectedWith(/refungible\.WrongRefungiblePieces/);
   });
   
-  itSub('RPC method tokenOnewrs for refungible collection and token', async ({helper}) => {
+  itSub('RPC method tokenOwners for refungible collection and token', async ({helper}) => {
     const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
     const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
 
@@ -212,7 +212,8 @@
     const token = await collection.mintToken(alice, 100n);
     await token.repartition(alice, 200n);
     const chainEvents = helper.chainLog.slice(-1)[0].events;
-    expect(chainEvents).to.deep.include({
+    const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemCreated');
+    expect(event).to.deep.include({
       section: 'common',
       method: 'ItemCreated',
       index: [66, 2],
@@ -222,7 +223,6 @@
         {substrate: alice.address}, 
         100n,
       ],
-      phase: {applyExtrinsic: 2},
     });
   });
 
@@ -231,9 +231,10 @@
     const token = await collection.mintToken(alice, 100n);
     await token.repartition(alice, 50n);
     const chainEvents = helper.chainLog.slice(-1)[0].events;
-    expect(chainEvents).to.deep.include({
+    const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemDestroyed');
+    expect(event).to.deep.include({
+      section: 'common',
       method: 'ItemDestroyed',
-      section: 'common',
       index: [66, 3],
       data: [
         collection.collectionId,
@@ -241,7 +242,6 @@
         {substrate: alice.address}, 
         50n,
       ],
-      phase: {applyExtrinsic: 2},
     });
   });
   
modifiedtests/src/xcm/xcmOpal.test.tsdiffbeforeafterboth
before · tests/src/xcm/xcmOpal.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';1920import {WsProvider} from '@polkadot/api';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {executeTransaction} from './../substrate/substrate-api';24import {bigIntToDecimals, describe_xcm, getGenericResult, paraSiblingSovereignAccount, normalizeAccountId} from './../deprecated-helpers/helpers';25import waitNewBlocks from './../substrate/wait-new-blocks';26import getBalance from './../substrate/get-balance';272829chai.use(chaiAsPromised);30const expect = chai.expect;3132const STATEMINE_CHAIN = 1000;33const UNIQUE_CHAIN = 2095;3435const RELAY_PORT = '9844';36const UNIQUE_PORT = '9944';37const STATEMINE_PORT = '9948';38const STATEMINE_PALLET_INSTANCE = 50;39const ASSET_ID = 100;40const ASSET_METADATA_DECIMALS = 18;41const ASSET_METADATA_NAME = 'USDT';42const ASSET_METADATA_DESCRIPTION = 'USDT';43const ASSET_METADATA_MINIMAL_BALANCE = 1;4445const WESTMINT_DECIMALS = 12;4647const TRANSFER_AMOUNT = 1_000_000_000_000_000_000n;4849// 10,000.00 (ten thousands) USDT50const ASSET_AMOUNT = 1_000_000_000_000_000_000_000n; 5152describe_xcm('[XCM] Integration test: Exchanging USDT with Westmint', () => {53  let alice: IKeyringPair;54  let bob: IKeyringPair;55  56  let balanceStmnBefore: bigint;57  let balanceStmnAfter: bigint;5859  let balanceOpalBefore: bigint;60  let balanceOpalAfter: bigint;61  let balanceOpalFinal: bigint;6263  let balanceBobBefore: bigint;64  let balanceBobAfter: bigint;65  let balanceBobFinal: bigint;6667  let balanceBobRelayTokenBefore: bigint;68  let balanceBobRelayTokenAfter: bigint;697071  before(async () => {72    await usingApi(async (api, privateKeyWrapper) => {73      alice = privateKeyWrapper('//Alice');74      bob = privateKeyWrapper('//Bob'); // funds donor75    });7677    const statemineApiOptions: ApiOptions = {78      provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),79    };8081    const uniqueApiOptions: ApiOptions = {82      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),83    };8485    const relayApiOptions: ApiOptions = {86      provider: new WsProvider('ws://127.0.0.1:' + RELAY_PORT),87    };8889    await usingApi(async (api) => {9091      // 350.00 (three hundred fifty) DOT92      const fundingAmount = 3_500_000_000_000; 9394      const tx = api.tx.assets.create(ASSET_ID, alice.addressRaw, ASSET_METADATA_MINIMAL_BALANCE);95      const events = await executeTransaction(api, alice, tx);96      const result = getGenericResult(events);97      expect(result.success).to.be.true;9899      // set metadata100      const tx2 = api.tx.assets.setMetadata(ASSET_ID, ASSET_METADATA_NAME, ASSET_METADATA_DESCRIPTION, ASSET_METADATA_DECIMALS);101      const events2 = await executeTransaction(api, alice, tx2);102      const result2 = getGenericResult(events2);103      expect(result2.success).to.be.true;104105      // mint some amount of asset106      const tx3 = api.tx.assets.mint(ASSET_ID, alice.addressRaw, ASSET_AMOUNT);107      const events3 = await executeTransaction(api, alice, tx3);108      const result3 = getGenericResult(events3);109      expect(result3.success).to.be.true;110111      // funding parachain sovereing account (Parachain: 2095)112      const parachainSovereingAccount = await paraSiblingSovereignAccount(UNIQUE_CHAIN);113      const tx4 = api.tx.balances.transfer(parachainSovereingAccount, fundingAmount);114      const events4 = await executeTransaction(api, bob, tx4);115      const result4 = getGenericResult(events4);116      expect(result4.success).to.be.true;117118    }, statemineApiOptions);119120121    await usingApi(async (api) => {122123      const location = {124        V1: {125          parents: 1,126          interior: {X3: [127            {128              Parachain: STATEMINE_CHAIN,129            },130            {131              PalletInstance: STATEMINE_PALLET_INSTANCE,132            },133            {134              GeneralIndex: ASSET_ID,135            },136          ]},137        },138      };139140      const metadata =141      {142        name: ASSET_ID,143        symbol: ASSET_METADATA_NAME,144        decimals: ASSET_METADATA_DECIMALS,145        minimalBalance: ASSET_METADATA_MINIMAL_BALANCE,146      };147      //registerForeignAsset(owner, location, metadata)148      const tx = api.tx.foreignAssets.registerForeignAsset(alice.addressRaw, location, metadata);149      const sudoTx = api.tx.sudo.sudo(tx as any);150      const events = await executeTransaction(api, alice, sudoTx);151      const result = getGenericResult(events);152      expect(result.success).to.be.true;153154      [balanceOpalBefore] = await getBalance(api, [alice.address]);155156    }, uniqueApiOptions);157158159    // Providing the relay currency to the unique sender account160    await usingApi(async (api) => {161      const destination = {162        V1: {163          parents: 0,164          interior: {X1: {165            Parachain: UNIQUE_CHAIN,166          },167          },168        }};169170      const beneficiary = {171        V1: {172          parents: 0,173          interior: {X1: {174            AccountId32: {175              network: 'Any',176              id: alice.addressRaw,177            },178          }},179        },180      };181182      const assets = {183        V1: [184          {185            id: {186              Concrete: {187                parents: 0,188                interior: 'Here',189              },190            },191            fun: {192              Fungible: 50_000_000_000_000_000n,193            },194          },195        ],196      };197198      const feeAssetItem = 0;199200      const weightLimit = {201        Limited: 5_000_000_000,202      };203204      const tx = api.tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);205      const events = await executeTransaction(api, alice, tx);206      const result = getGenericResult(events);207      expect(result.success).to.be.true;208    }, relayApiOptions);209  210  });211212  it('Should connect and send USDT from Westmint to Opal', async () => {213    214    const statemineApiOptions: ApiOptions = {215      provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),216    };217218    const uniqueApiOptions: ApiOptions = {219      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),220    };221222    await usingApi(async (api) => {223224      const dest = {225        V1: {226          parents: 1,227          interior: {X1: {228            Parachain: UNIQUE_CHAIN,229          },230          },231        }};232233      const beneficiary = {234        V1: {235          parents: 0,236          interior: {X1: {237            AccountId32: {238              network: 'Any',239              id: alice.addressRaw,240            },241          }},242        },243      };244245      const assets = {246        V1: [247          {248            id: {249              Concrete: {250                parents: 0,251                interior: {252                  X2: [253                    {254                      PalletInstance: STATEMINE_PALLET_INSTANCE,255                    },256                    {257                      GeneralIndex: ASSET_ID,258                    }, 259                  ]},260              },261            },262            fun: {263              Fungible: TRANSFER_AMOUNT,264            },265          },266        ],267      };268269      const feeAssetItem = 0;270271      const weightLimit = {272        Limited: 5000000000,273      };274275      [balanceStmnBefore] = await getBalance(api, [alice.address]);276277      const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(dest, beneficiary, assets, feeAssetItem, weightLimit);278      const events = await executeTransaction(api, alice, tx);279      const result = getGenericResult(events);280      expect(result.success).to.be.true;281282      [balanceStmnAfter] = await getBalance(api, [alice.address]);283284      // common good parachain take commission in it native token285      console.log(286        'Opal to Westmint transaction fees on Westmint: %s WND',287        bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, WESTMINT_DECIMALS),288      );289      expect(balanceStmnBefore > balanceStmnAfter).to.be.true;290291    }, statemineApiOptions);292293294    // ensure that asset has been delivered295    await usingApi(async (api) => {296      await waitNewBlocks(api, 3);297      // expext collection id will be with id 1298      const free = (await api.query.fungible.balance(1, normalizeAccountId(alice.address))).toBigInt();299300      [balanceOpalAfter] = await getBalance(api, [alice.address]);301302      // commission has not paid in USDT token303      expect(free == TRANSFER_AMOUNT).to.be.true;304      console.log(305        'Opal to Westmint transaction fees on Opal: %s USDT',306        bigIntToDecimals(TRANSFER_AMOUNT - free),307      );308      // ... and parachain native token309      expect(balanceOpalAfter == balanceOpalBefore).to.be.true;310      console.log(311        'Opal to Westmint transaction fees on Opal: %s WND',312        bigIntToDecimals(balanceOpalAfter - balanceOpalBefore, WESTMINT_DECIMALS),313      );314315    }, uniqueApiOptions);316    317  });318319  it('Should connect and send USDT from Unique to Statemine back', async () => {320321    const uniqueApiOptions: ApiOptions = {322      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),323    };324325    const statemineApiOptions: ApiOptions = {326      provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),327    };328329    await usingApi(async (api) => {330      const destination = {331        V1: {332          parents: 1,333          interior: {X2: [334            {335              Parachain: STATEMINE_CHAIN,336            },337            {338              AccountId32: {339                network: 'Any',340                id: alice.addressRaw,341              },342            },343          ]},344        },345      };346347      const currencies: [any, bigint][] = [348        [349          {350            ForeignAssetId: 0,351          },352          //10_000_000_000_000_000n,353          TRANSFER_AMOUNT,354        ], 355        [356          {357            NativeAssetId: 'Parent',358          },359          400_000_000_000_000n,360        ],361      ];362363      const feeItem = 1;364      const destWeight = 500000000000;365366      const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);367      const events = await executeTransaction(api, alice, tx);368      const result = getGenericResult(events);369      expect(result.success).to.be.true;370      371      // the commission has been paid in parachain native token372      [balanceOpalFinal] = await getBalance(api, [alice.address]);373      expect(balanceOpalAfter > balanceOpalFinal).to.be.true;374    }, uniqueApiOptions);375376    await usingApi(async (api) => {377      await waitNewBlocks(api, 3);378      379      // The USDT token never paid fees. Its amount not changed from begin value.380      // Also check that xcm transfer has been succeeded 381      const free = ((await api.query.assets.account(100, alice.address)).toHuman()) as any;382      expect(BigInt(free.balance.replace(/,/g, '')) == ASSET_AMOUNT).to.be.true;383    }, statemineApiOptions);384  });385386  it('Should connect and send Relay token to Unique', async () => {387388    const uniqueApiOptions: ApiOptions = {389      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),390    };391392    const uniqueApiOptions2: ApiOptions = {393      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),394    };395396    const relayApiOptions: ApiOptions = {397      provider: new WsProvider('ws://127.0.0.1:' + RELAY_PORT),398    };399400    const TRANSFER_AMOUNT_RELAY = 50_000_000_000_000_000n;401402    await usingApi(async (api) => {403      [balanceBobBefore] = await getBalance(api, [bob.address]);404      balanceBobRelayTokenBefore = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);405406    }, uniqueApiOptions);407408    // Providing the relay currency to the unique sender account409    await usingApi(async (api) => {410      const destination = {411        V1: {412          parents: 0,413          interior: {X1: {414            Parachain: UNIQUE_CHAIN,415          },416          },417        }};418419      const beneficiary = {420        V1: {421          parents: 0,422          interior: {X1: {423            AccountId32: {424              network: 'Any',425              id: bob.addressRaw,426            },427          }},428        },429      };430431      const assets = {432        V1: [433          {434            id: {435              Concrete: {436                parents: 0,437                interior: 'Here',438              },439            },440            fun: {441              Fungible: TRANSFER_AMOUNT_RELAY,442            },443          },444        ],445      };446447      const feeAssetItem = 0;448449      const weightLimit = {450        Limited: 5_000_000_000,451      };452453      const tx = api.tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);454      const events = await executeTransaction(api, bob, tx);455      const result = getGenericResult(events);456      expect(result.success).to.be.true;457    }, relayApiOptions);458  459460    await usingApi(async (api) => {461      await waitNewBlocks(api, 3);462463      [balanceBobAfter] = await getBalance(api, [bob.address]);464      balanceBobRelayTokenAfter = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);465      const wndFee = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore; 466      console.log(467        'Relay (Westend) to Opal transaction fees: %s OPL',468        bigIntToDecimals(balanceBobAfter - balanceBobBefore),469      );470      console.log(471        'Relay (Westend) to Opal transaction fees: %s WND',472        bigIntToDecimals(wndFee, WESTMINT_DECIMALS),473      );474      expect(balanceBobBefore == balanceBobAfter).to.be.true;475      expect(balanceBobRelayTokenBefore < balanceBobRelayTokenAfter).to.be.true;476    }, uniqueApiOptions2);477478  });479480  it('Should connect and send Relay token back', async () => {481    const uniqueApiOptions: ApiOptions = {482      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),483    };484485    await usingApi(async (api) => {486      const destination = {487        V1: {488          parents: 1,489          interior: {X2: [490            {491              Parachain: STATEMINE_CHAIN,492            },493            {494              AccountId32: {495                network: 'Any',496                id: bob.addressRaw,497              },498            },499          ]},500        },501      };502503      const currencies: any = [504        [505          {506            NativeAssetId: 'Parent',507          },508          50_000_000_000_000_000n,509        ],510      ];511512      const feeItem = 0;513      const destWeight = 500000000000;514515      const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);516      const events = await executeTransaction(api, bob, tx);517      const result = getGenericResult(events);518      expect(result.success).to.be.true;519520      [balanceBobFinal] = await getBalance(api, [bob.address]);521      console.log('Relay (Westend) to Opal transaction fees: %s OPL', balanceBobAfter - balanceBobFinal);522523    }, uniqueApiOptions);524  });525526});
after · tests/src/xcm/xcmOpal.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';1920import {WsProvider} from '@polkadot/api';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {executeTransaction} from './../substrate/substrate-api';24import {bigIntToDecimals, describeXCM, getGenericResult, paraSiblingSovereignAccount, normalizeAccountId} from './../deprecated-helpers/helpers';25import waitNewBlocks from './../substrate/wait-new-blocks';26import getBalance from './../substrate/get-balance';272829chai.use(chaiAsPromised);30const expect = chai.expect;3132const STATEMINE_CHAIN = 1000;33const UNIQUE_CHAIN = 2095;3435const RELAY_PORT = '9844';36const UNIQUE_PORT = '9944';37const STATEMINE_PORT = '9948';38const STATEMINE_PALLET_INSTANCE = 50;39const ASSET_ID = 100;40const ASSET_METADATA_DECIMALS = 18;41const ASSET_METADATA_NAME = 'USDT';42const ASSET_METADATA_DESCRIPTION = 'USDT';43const ASSET_METADATA_MINIMAL_BALANCE = 1;4445const WESTMINT_DECIMALS = 12;4647const TRANSFER_AMOUNT = 1_000_000_000_000_000_000n;4849// 10,000.00 (ten thousands) USDT50const ASSET_AMOUNT = 1_000_000_000_000_000_000_000n; 5152describeXCM('[XCM] Integration test: Exchanging USDT with Westmint', () => {53  let alice: IKeyringPair;54  let bob: IKeyringPair;55  56  let balanceStmnBefore: bigint;57  let balanceStmnAfter: bigint;5859  let balanceOpalBefore: bigint;60  let balanceOpalAfter: bigint;61  let balanceOpalFinal: bigint;6263  let balanceBobBefore: bigint;64  let balanceBobAfter: bigint;65  let balanceBobFinal: bigint;6667  let balanceBobRelayTokenBefore: bigint;68  let balanceBobRelayTokenAfter: bigint;697071  before(async () => {72    await usingApi(async (api, privateKeyWrapper) => {73      alice = privateKeyWrapper('//Alice');74      bob = privateKeyWrapper('//Bob'); // funds donor75    });7677    const statemineApiOptions: ApiOptions = {78      provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),79    };8081    const uniqueApiOptions: ApiOptions = {82      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),83    };8485    const relayApiOptions: ApiOptions = {86      provider: new WsProvider('ws://127.0.0.1:' + RELAY_PORT),87    };8889    await usingApi(async (api) => {9091      // 350.00 (three hundred fifty) DOT92      const fundingAmount = 3_500_000_000_000; 9394      const tx = api.tx.assets.create(ASSET_ID, alice.addressRaw, ASSET_METADATA_MINIMAL_BALANCE);95      const events = await executeTransaction(api, alice, tx);96      const result = getGenericResult(events);97      expect(result.success).to.be.true;9899      // set metadata100      const tx2 = api.tx.assets.setMetadata(ASSET_ID, ASSET_METADATA_NAME, ASSET_METADATA_DESCRIPTION, ASSET_METADATA_DECIMALS);101      const events2 = await executeTransaction(api, alice, tx2);102      const result2 = getGenericResult(events2);103      expect(result2.success).to.be.true;104105      // mint some amount of asset106      const tx3 = api.tx.assets.mint(ASSET_ID, alice.addressRaw, ASSET_AMOUNT);107      const events3 = await executeTransaction(api, alice, tx3);108      const result3 = getGenericResult(events3);109      expect(result3.success).to.be.true;110111      // funding parachain sovereing account (Parachain: 2095)112      const parachainSovereingAccount = await paraSiblingSovereignAccount(UNIQUE_CHAIN);113      const tx4 = api.tx.balances.transfer(parachainSovereingAccount, fundingAmount);114      const events4 = await executeTransaction(api, bob, tx4);115      const result4 = getGenericResult(events4);116      expect(result4.success).to.be.true;117118    }, statemineApiOptions);119120121    await usingApi(async (api) => {122123      const location = {124        V1: {125          parents: 1,126          interior: {X3: [127            {128              Parachain: STATEMINE_CHAIN,129            },130            {131              PalletInstance: STATEMINE_PALLET_INSTANCE,132            },133            {134              GeneralIndex: ASSET_ID,135            },136          ]},137        },138      };139140      const metadata =141      {142        name: ASSET_ID,143        symbol: ASSET_METADATA_NAME,144        decimals: ASSET_METADATA_DECIMALS,145        minimalBalance: ASSET_METADATA_MINIMAL_BALANCE,146      };147      //registerForeignAsset(owner, location, metadata)148      const tx = api.tx.foreignAssets.registerForeignAsset(alice.addressRaw, location, metadata);149      const sudoTx = api.tx.sudo.sudo(tx as any);150      const events = await executeTransaction(api, alice, sudoTx);151      const result = getGenericResult(events);152      expect(result.success).to.be.true;153154      [balanceOpalBefore] = await getBalance(api, [alice.address]);155156    }, uniqueApiOptions);157158159    // Providing the relay currency to the unique sender account160    await usingApi(async (api) => {161      const destination = {162        V1: {163          parents: 0,164          interior: {X1: {165            Parachain: UNIQUE_CHAIN,166          },167          },168        }};169170      const beneficiary = {171        V1: {172          parents: 0,173          interior: {X1: {174            AccountId32: {175              network: 'Any',176              id: alice.addressRaw,177            },178          }},179        },180      };181182      const assets = {183        V1: [184          {185            id: {186              Concrete: {187                parents: 0,188                interior: 'Here',189              },190            },191            fun: {192              Fungible: 50_000_000_000_000_000n,193            },194          },195        ],196      };197198      const feeAssetItem = 0;199200      const weightLimit = {201        Limited: 5_000_000_000,202      };203204      const tx = api.tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);205      const events = await executeTransaction(api, alice, tx);206      const result = getGenericResult(events);207      expect(result.success).to.be.true;208    }, relayApiOptions);209  210  });211212  it('Should connect and send USDT from Westmint to Opal', async () => {213    214    const statemineApiOptions: ApiOptions = {215      provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),216    };217218    const uniqueApiOptions: ApiOptions = {219      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),220    };221222    await usingApi(async (api) => {223224      const dest = {225        V1: {226          parents: 1,227          interior: {X1: {228            Parachain: UNIQUE_CHAIN,229          },230          },231        }};232233      const beneficiary = {234        V1: {235          parents: 0,236          interior: {X1: {237            AccountId32: {238              network: 'Any',239              id: alice.addressRaw,240            },241          }},242        },243      };244245      const assets = {246        V1: [247          {248            id: {249              Concrete: {250                parents: 0,251                interior: {252                  X2: [253                    {254                      PalletInstance: STATEMINE_PALLET_INSTANCE,255                    },256                    {257                      GeneralIndex: ASSET_ID,258                    }, 259                  ]},260              },261            },262            fun: {263              Fungible: TRANSFER_AMOUNT,264            },265          },266        ],267      };268269      const feeAssetItem = 0;270271      const weightLimit = {272        Limited: 5000000000,273      };274275      [balanceStmnBefore] = await getBalance(api, [alice.address]);276277      const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(dest, beneficiary, assets, feeAssetItem, weightLimit);278      const events = await executeTransaction(api, alice, tx);279      const result = getGenericResult(events);280      expect(result.success).to.be.true;281282      [balanceStmnAfter] = await getBalance(api, [alice.address]);283284      // common good parachain take commission in it native token285      console.log(286        'Opal to Westmint transaction fees on Westmint: %s WND',287        bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, WESTMINT_DECIMALS),288      );289      expect(balanceStmnBefore > balanceStmnAfter).to.be.true;290291    }, statemineApiOptions);292293294    // ensure that asset has been delivered295    await usingApi(async (api) => {296      await waitNewBlocks(api, 3);297      // expext collection id will be with id 1298      const free = (await api.query.fungible.balance(1, normalizeAccountId(alice.address))).toBigInt();299300      [balanceOpalAfter] = await getBalance(api, [alice.address]);301302      // commission has not paid in USDT token303      expect(free == TRANSFER_AMOUNT).to.be.true;304      console.log(305        'Opal to Westmint transaction fees on Opal: %s USDT',306        bigIntToDecimals(TRANSFER_AMOUNT - free),307      );308      // ... and parachain native token309      expect(balanceOpalAfter == balanceOpalBefore).to.be.true;310      console.log(311        'Opal to Westmint transaction fees on Opal: %s WND',312        bigIntToDecimals(balanceOpalAfter - balanceOpalBefore, WESTMINT_DECIMALS),313      );314315    }, uniqueApiOptions);316    317  });318319  it('Should connect and send USDT from Unique to Statemine back', async () => {320321    const uniqueApiOptions: ApiOptions = {322      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),323    };324325    const statemineApiOptions: ApiOptions = {326      provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),327    };328329    await usingApi(async (api) => {330      const destination = {331        V1: {332          parents: 1,333          interior: {X2: [334            {335              Parachain: STATEMINE_CHAIN,336            },337            {338              AccountId32: {339                network: 'Any',340                id: alice.addressRaw,341              },342            },343          ]},344        },345      };346347      const currencies: [any, bigint][] = [348        [349          {350            ForeignAssetId: 0,351          },352          //10_000_000_000_000_000n,353          TRANSFER_AMOUNT,354        ], 355        [356          {357            NativeAssetId: 'Parent',358          },359          400_000_000_000_000n,360        ],361      ];362363      const feeItem = 1;364      const destWeight = 500000000000;365366      const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);367      const events = await executeTransaction(api, alice, tx);368      const result = getGenericResult(events);369      expect(result.success).to.be.true;370      371      // the commission has been paid in parachain native token372      [balanceOpalFinal] = await getBalance(api, [alice.address]);373      expect(balanceOpalAfter > balanceOpalFinal).to.be.true;374    }, uniqueApiOptions);375376    await usingApi(async (api) => {377      await waitNewBlocks(api, 3);378      379      // The USDT token never paid fees. Its amount not changed from begin value.380      // Also check that xcm transfer has been succeeded 381      const free = ((await api.query.assets.account(100, alice.address)).toHuman()) as any;382      expect(BigInt(free.balance.replace(/,/g, '')) == ASSET_AMOUNT).to.be.true;383    }, statemineApiOptions);384  });385386  it('Should connect and send Relay token to Unique', async () => {387388    const uniqueApiOptions: ApiOptions = {389      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),390    };391392    const uniqueApiOptions2: ApiOptions = {393      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),394    };395396    const relayApiOptions: ApiOptions = {397      provider: new WsProvider('ws://127.0.0.1:' + RELAY_PORT),398    };399400    const TRANSFER_AMOUNT_RELAY = 50_000_000_000_000_000n;401402    await usingApi(async (api) => {403      [balanceBobBefore] = await getBalance(api, [bob.address]);404      balanceBobRelayTokenBefore = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);405406    }, uniqueApiOptions);407408    // Providing the relay currency to the unique sender account409    await usingApi(async (api) => {410      const destination = {411        V1: {412          parents: 0,413          interior: {X1: {414            Parachain: UNIQUE_CHAIN,415          },416          },417        }};418419      const beneficiary = {420        V1: {421          parents: 0,422          interior: {X1: {423            AccountId32: {424              network: 'Any',425              id: bob.addressRaw,426            },427          }},428        },429      };430431      const assets = {432        V1: [433          {434            id: {435              Concrete: {436                parents: 0,437                interior: 'Here',438              },439            },440            fun: {441              Fungible: TRANSFER_AMOUNT_RELAY,442            },443          },444        ],445      };446447      const feeAssetItem = 0;448449      const weightLimit = {450        Limited: 5_000_000_000,451      };452453      const tx = api.tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);454      const events = await executeTransaction(api, bob, tx);455      const result = getGenericResult(events);456      expect(result.success).to.be.true;457    }, relayApiOptions);458  459460    await usingApi(async (api) => {461      await waitNewBlocks(api, 3);462463      [balanceBobAfter] = await getBalance(api, [bob.address]);464      balanceBobRelayTokenAfter = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);465      const wndFee = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore; 466      console.log(467        'Relay (Westend) to Opal transaction fees: %s OPL',468        bigIntToDecimals(balanceBobAfter - balanceBobBefore),469      );470      console.log(471        'Relay (Westend) to Opal transaction fees: %s WND',472        bigIntToDecimals(wndFee, WESTMINT_DECIMALS),473      );474      expect(balanceBobBefore == balanceBobAfter).to.be.true;475      expect(balanceBobRelayTokenBefore < balanceBobRelayTokenAfter).to.be.true;476    }, uniqueApiOptions2);477478  });479480  it('Should connect and send Relay token back', async () => {481    const uniqueApiOptions: ApiOptions = {482      provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),483    };484485    await usingApi(async (api) => {486      const destination = {487        V1: {488          parents: 1,489          interior: {X2: [490            {491              Parachain: STATEMINE_CHAIN,492            },493            {494              AccountId32: {495                network: 'Any',496                id: bob.addressRaw,497              },498            },499          ]},500        },501      };502503      const currencies: any = [504        [505          {506            NativeAssetId: 'Parent',507          },508          50_000_000_000_000_000n,509        ],510      ];511512      const feeItem = 0;513      const destWeight = 500000000000;514515      const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);516      const events = await executeTransaction(api, bob, tx);517      const result = getGenericResult(events);518      expect(result.success).to.be.true;519520      [balanceBobFinal] = await getBalance(api, [bob.address]);521      console.log('Relay (Westend) to Opal transaction fees: %s OPL', balanceBobAfter - balanceBobFinal);522523    }, uniqueApiOptions);524  });525526});
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -21,7 +21,7 @@
 import {ApiOptions} from '@polkadot/api/types';
 import {IKeyringPair} from '@polkadot/types/types';
 import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../deprecated-helpers/helpers';
+import {getGenericResult, generateKeyringPair, waitEvent, describeXCM, bigIntToDecimals} from '../deprecated-helpers/helpers';
 import {MultiLocation} from '@polkadot/types/interfaces';
 import {blake2AsHex} from '@polkadot/util-crypto';
 import waitNewBlocks from '../substrate/wait-new-blocks';
@@ -61,7 +61,7 @@
   return parachainApiOptions(RELAY_PORT);
 }
 
-describe_xcm('[XCM] Integration test: Exchanging tokens with Karura', () => {
+describeXCM('[XCM] Integration test: Exchanging tokens with Karura', () => {
   let alice: IKeyringPair;
   let randomAccount: IKeyringPair;
 
@@ -292,7 +292,7 @@
 });
 
 // These tests are relevant only when the foreign asset pallet is disabled
-describe_xcm('[XCM] Integration test: Quartz rejects non-native tokens', () => {
+describeXCM('[XCM] Integration test: Quartz rejects non-native tokens', () => {
   let alice: IKeyringPair;
 
   before(async () => {
@@ -433,7 +433,7 @@
   });
 });
 
-describe_xcm('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
+describeXCM('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
 
   // Quartz constants
   let quartzAlice: IKeyringPair;
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -21,7 +21,7 @@
 import {ApiOptions} from '@polkadot/api/types';
 import {IKeyringPair} from '@polkadot/types/types';
 import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../deprecated-helpers/helpers';
+import {getGenericResult, generateKeyringPair, waitEvent, describeXCM, bigIntToDecimals} from '../deprecated-helpers/helpers';
 import {MultiLocation} from '@polkadot/types/interfaces';
 import {blake2AsHex} from '@polkadot/util-crypto';
 import waitNewBlocks from '../substrate/wait-new-blocks';
@@ -61,7 +61,7 @@
   return parachainApiOptions(RELAY_PORT);
 }
 
-describe_xcm('[XCM] Integration test: Exchanging tokens with Acala', () => {
+describeXCM('[XCM] Integration test: Exchanging tokens with Acala', () => {
   let alice: IKeyringPair;
   let randomAccount: IKeyringPair;
 
@@ -292,7 +292,7 @@
 });
 
 // These tests are relevant only when the foreign asset pallet is disabled
-describe_xcm('[XCM] Integration test: Unique rejects non-native tokens', () => {
+describeXCM('[XCM] Integration test: Unique rejects non-native tokens', () => {
   let alice: IKeyringPair;
 
   before(async () => {
@@ -433,7 +433,7 @@
   });
 });
 
-describe_xcm('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {
+describeXCM('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {
 
   // Unique constants
   let uniqueAlice: IKeyringPair;