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

difftreelog

refactor xcm Unq tests

PraetorP2023-09-26parent: #10b8180.patch.diff
in: master

3 files changed

modifiedtests/src/xcm/lowLevelXcmUnique.test.tsdiffbeforeafterboth
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import config from '../config';18import config from '../config';
19import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingMoonbeamPlaygrounds, usingAstarPlaygrounds, usingPolkadexPlaygrounds} from '../util';19import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingMoonbeamPlaygrounds, usingAstarPlaygrounds, usingPolkadexPlaygrounds} from '../util';
20import {DevUniqueHelper, Event} from '../util/playgrounds/unique.dev';20import {Event} from '../util/playgrounds/unique.dev';
21import {nToBigInt} from '@polkadot/util';21import {nToBigInt} from '@polkadot/util';
22import {hexToString} from '@polkadot/util';22import {hexToString} from '@polkadot/util';
23
24const UNIQUE_CHAIN = +(process.env.RELAY_UNIQUE_ID || 2037);23import {ASTAR_DECIMALS, NETWORKS, SAFE_XCM_VERSION, UNIQUE_CHAIN, UNQ_DECIMALS, acalaUrl, astarUrl, expectFailedToTransact, expectUntrustedReserveLocationFail, getDevPlayground, mapToChainId, mapToChainUrl, maxWaitBlocks, moonbeamUrl, polkadexUrl, uniqueAssetId, uniqueVersionedMultilocation} from './xcm.types';
25const ACALA_CHAIN = +(process.env.RELAY_ACALA_ID || 2000);24
26const MOONBEAM_CHAIN = +(process.env.RELAY_MOONBEAM_ID || 2004);
27const ASTAR_CHAIN = +(process.env.RELAY_ASTAR_ID || 2006);
28const POLKADEX_CHAIN = +(process.env.RELAY_POLKADEX_ID || 2040);
29
30
31
32const acalaUrl = config.acalaUrl;
33const moonbeamUrl = config.moonbeamUrl;
34const astarUrl = config.astarUrl;
35const polkadexUrl = config.polkadexUrl;
36
37const ASTAR_DECIMALS = 18n;
38const UNQ_DECIMALS = 18n;
3925
40const TRANSFER_AMOUNT = 2000000_000_000_000_000_000_000n;26const TRANSFER_AMOUNT = 2000000_000_000_000_000_000_000n;
41const SENDER_BUDGET = 2n * TRANSFER_AMOUNT;27const SENDER_BUDGET = 2n * TRANSFER_AMOUNT;
42const SENDBACK_AMOUNT = TRANSFER_AMOUNT / 2n;28const SENDBACK_AMOUNT = TRANSFER_AMOUNT / 2n;
43const STAYED_ON_TARGET_CHAIN = TRANSFER_AMOUNT - SENDBACK_AMOUNT;29const STAYED_ON_TARGET_CHAIN = TRANSFER_AMOUNT - SENDBACK_AMOUNT;
44const TARGET_CHAIN_TOKEN_TRANSFER_AMOUNT = 100_000_000_000n;30const TARGET_CHAIN_TOKEN_TRANSFER_AMOUNT = 100_000_000_000n;
45
46const SAFE_XCM_VERSION = 2;
47const maxWaitBlocks = 6;
48
49const uniqueMultilocation = {
50 V2: {
51 parents: 1,
52 interior: {
53 X1: {
54 Parachain: UNIQUE_CHAIN,
55 },
56 },
57 },
58};
5931
60let balanceUniqueTokenInit: bigint;32let balanceUniqueTokenInit: bigint;
61let balanceUniqueTokenMiddle: bigint;33let balanceUniqueTokenMiddle: bigint;
62let balanceUniqueTokenFinal: bigint;34let balanceUniqueTokenFinal: bigint;
63let unqFees: bigint;35let unqFees: bigint;
64
65const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
66 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
67 && event.outcome.isFailedToTransactAsset);
68};
69const expectUntrustedReserveLocationFail = async (helper: DevUniqueHelper, messageSent: any) => {
70 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
71 && event.outcome.isUntrustedReserveLocation);
72};
73
74const NETWORKS = {
75 acala: usingAcalaPlaygrounds,
76 astar: usingAstarPlaygrounds,
77 polkadex: usingPolkadexPlaygrounds,
78 moonbeam: usingMoonbeamPlaygrounds,
79} as const;
80
81function mapToChainId(networkName: keyof typeof NETWORKS) {
82 switch (networkName) {
83 case 'acala':
84 return ACALA_CHAIN;
85 case 'astar':
86 return ASTAR_CHAIN;
87 case 'moonbeam':
88 return MOONBEAM_CHAIN;
89 case 'polkadex':
90 return POLKADEX_CHAIN;
91 }
92}
93
94function mapToChainUrl(networkName: keyof typeof NETWORKS): string {
95 switch (networkName) {
96 case 'acala':
97 return acalaUrl;
98 case 'astar':
99 return astarUrl;
100 case 'moonbeam':
101 return moonbeamUrl;
102 case 'polkadex':
103 return polkadexUrl;
104 }
105}
106
107function getDevPlayground<T extends keyof typeof NETWORKS>(name: T) {
108 return NETWORKS[name];
109}
11036
11137
112async function genericSendUnqTo(38async function genericSendUnqTo(
227153
228 await targetPlayground(networkUrl, async (helper) => {154 await targetPlayground(networkUrl, async (helper) => {
229 if('getSudo' in helper) {155 if('getSudo' in helper) {
230 await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, xcmProgram);156 await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, xcmProgram);
231 xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);157 xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
232 } else if('fastDemocracy' in helper) {158 } else if('fastDemocracy' in helper) {
233 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, xcmProgram]);159 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, xcmProgram]);
234 // Needed to bypass the call filter.160 // Needed to bypass the call filter.
235 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);161 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
236 await helper.fastDemocracy.executeProposal('sending MoonBeam -> Unique via XCM program', batchCall);162 await helper.fastDemocracy.executeProposal(`sending ${networkName} -> Unique via XCM program`, batchCall);
237 xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);163 xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
238 }164 }
239 });165 });
279205
280 await targetPlayground(networkUrl, async (helper) => {206 await targetPlayground(networkUrl, async (helper) => {
281 if('getSudo' in helper) {207 if('getSudo' in helper) {
282 await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, maliciousXcmProgram);208 await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, maliciousXcmProgram);
283 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);209 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
284 } else if('fastDemocracy' in helper) {210 } else if('fastDemocracy' in helper) {
285 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgram]);211 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgram]);
286 // Needed to bypass the call filter.212 // Needed to bypass the call filter.
287 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);213 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
288 await helper.fastDemocracy.executeProposal('sending MoonBeam -> Unique via XCM program', batchCall);214 await helper.fastDemocracy.executeProposal(`sending ${networkName} -> Unique via XCM program`, batchCall);
289 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);215 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
290 }216 }
291 });217 });
338 // Try to trick Unique using full UNQ identification264 // Try to trick Unique using full UNQ identification
339 await targetPlayground(networkUrl, async (helper) => {265 await targetPlayground(networkUrl, async (helper) => {
340 if('getSudo' in helper) {266 if('getSudo' in helper) {
341 await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, maliciousXcmProgramFullId);267 await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, maliciousXcmProgramFullId);
342 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);268 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
343 }269 }
344 // Moonbeam case270 // Moonbeam case
345 else if('fastDemocracy' in helper) {271 else if('fastDemocracy' in helper) {
346 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramFullId]);272 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramFullId]);
347
348 // Needed to bypass the call filter.273 // Needed to bypass the call filter.
349 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);274 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
350 await helper.fastDemocracy.executeProposal('try to act like a reserve location for UNQ using path asset identification', batchCall);275 await helper.fastDemocracy.executeProposal(`${netwokrName} try to act like a reserve location for UNQ using path asset identification`,batchCall);
351276
352 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);277 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
353 }278 }
362 // Try to trick Unique using shortened UNQ identification287 // Try to trick Unique using shortened UNQ identification
363 await targetPlayground(networkUrl, async (helper) => {288 await targetPlayground(networkUrl, async (helper) => {
364 if('getSudo' in helper) {289 if('getSudo' in helper) {
365 await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, maliciousXcmProgramHereId);290 await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, maliciousXcmProgramHereId);
366 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);291 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
367 }292 }
368 else if('fastDemocracy' in helper) {293 else if('fastDemocracy' in helper) {
369 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramHereId]);294 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramHereId]);
370
371 // Needed to bypass the call filter.295 // Needed to bypass the call filter.
372 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);296 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
373 await helper.fastDemocracy.executeProposal('try to act like a reserve location for UNQ using "here" asset identification', batchCall);297 await helper.fastDemocracy.executeProposal(`${netwokrName} try to act like a reserve location for UNQ using "here" asset identification`, batchCall);
374298
375 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);299 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
376 }300 }
405 );329 );
406 await targetPlayground(networkUrl, async (helper) => {330 await targetPlayground(networkUrl, async (helper) => {
407 if('getSudo' in helper) {331 if('getSudo' in helper) {
408 await helper.getSudo().xcm.send(sudoerOnTargetChain, uniqueMultilocation, maliciousXcmProgramFullId);332 await helper.getSudo().xcm.send(sudoerOnTargetChain, uniqueVersionedMultilocation, maliciousXcmProgramFullId);
409 messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);333 messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
410 } else if('fastDemocracy' in helper) {334 } else if('fastDemocracy' in helper) {
411 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramFullId]);335 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramFullId]);
412
413 // Needed to bypass the call filter.336 // Needed to bypass the call filter.
414 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);337 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
415 await helper.fastDemocracy.executeProposal('sending native tokens to the Unique via fast democracy', batchCall);338 await helper.fastDemocracy.executeProposal(`${netwokrName} sending native tokens to the Unique via fast democracy`, batchCall);
416339
417 messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);340 messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
418 }341 }
493 let alice: IKeyringPair;415 let alice: IKeyringPair;
494 let randomAccount: IKeyringPair;416 let randomAccount: IKeyringPair;
495
496 const uniqueAssetId = {
497 Concrete: {
498 parents: 1,
499 interior: {
500 X1: {
501 Parachain: UNIQUE_CHAIN,
502 },
503 },
504 },
505 };
506417
507 before(async () => {418 before(async () => {
508 await usingPlaygrounds(async (helper, privateKey) => {419 await usingPlaygrounds(async (helper, privateKey) => {
523 if it is added again. Needed for debugging434 if it is added again. Needed for debugging
524 when this test is run multiple times.435 when this test is run multiple times.
525 */436 */
526 if(!isWhitelisted) {437 if(isWhitelisted) {
438 console.log('UNQ token is already whitelisted on Polkadex');
439 } else {
527 await helper.getSudo().xcmHelper.whitelistToken(alice, uniqueAssetId);440 await helper.getSudo().xcmHelper.whitelistToken(alice, uniqueAssetId);
528 }441 }
529442
639 const numAssetsWeightHint = 0;552 const numAssetsWeightHint = 0;
640553
641 if((await helper.assetManager.assetTypeId(uniqueAssetLocation)).toJSON()) {554 if((await helper.assetManager.assetTypeId(uniqueAssetLocation)).toJSON()) {
642 console.log('Unique asset already registered');555 console.log('Unique asset already registered on Moonbeam');
643 } else {556 } else {
644 const encodedProposal = helper.assetManager.makeRegisterForeignAssetProposal({557 const encodedProposal = helper.assetManager.makeRegisterForeignAssetProposal({
645 location: uniqueAssetLocation,558 location: uniqueAssetLocation,
750663
751 console.log('3. Set UNQ payment for XCM execution on Astar');664 console.log('3. Set UNQ payment for XCM execution on Astar');
752 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);665 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);
753 }666 } else {
667 console.log('UNQ is already registered on Astar');
668 }
754 console.log('4. Transfer 1 ASTR to recipient to create the account (needed due to existential balance)');669 console.log('4. Transfer 1 ASTR to recipient to create the account (needed due to existential balance)');
755 await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);670 await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);
756 });671 });
addedtests/src/xcm/xcm.types.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/xcm/xcm.types.ts
@@ -0,0 +1,85 @@
+import {usingAcalaPlaygrounds, usingAstarPlaygrounds, usingMoonbeamPlaygrounds, usingPolkadexPlaygrounds} from '../util';
+import {DevUniqueHelper, Event} from '../util/playgrounds/unique.dev';
+import config from '../config';
+
+export const UNIQUE_CHAIN = +(process.env.RELAY_UNIQUE_ID || 2037);
+export const STATEMINT_CHAIN = +(process.env.RELAY_STATEMINT_ID || 1000);
+export const ACALA_CHAIN = +(process.env.RELAY_ACALA_ID || 2000);
+export const MOONBEAM_CHAIN = +(process.env.RELAY_MOONBEAM_ID || 2004);
+export const ASTAR_CHAIN = +(process.env.RELAY_ASTAR_ID || 2006);
+export const POLKADEX_CHAIN = +(process.env.RELAY_POLKADEX_ID || 2040);
+
+export const acalaUrl = config.acalaUrl;
+export const moonbeamUrl = config.moonbeamUrl;
+export const astarUrl = config.astarUrl;
+export const polkadexUrl = config.polkadexUrl;
+
+export const SAFE_XCM_VERSION = 3;
+
+export const maxWaitBlocks = 6;
+
+
+export const ASTAR_DECIMALS = 18n;
+export const UNQ_DECIMALS = 18n;
+
+export const uniqueMultilocation = {
+  parents: 1,
+  interior: {
+    X1: {
+      Parachain: UNIQUE_CHAIN,
+    },
+  },
+};
+export const uniqueVersionedMultilocation = {
+  V3: uniqueMultilocation,
+};
+
+export const uniqueAssetId = {
+  Concrete: uniqueMultilocation,
+};
+
+export const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
+  await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
+        && event.outcome.isFailedToTransactAsset);
+};
+export const expectUntrustedReserveLocationFail = async (helper: DevUniqueHelper, messageSent: any) => {
+  await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
+         && event.outcome.isUntrustedReserveLocation);
+};
+
+export const NETWORKS = {
+  acala: usingAcalaPlaygrounds,
+  astar: usingAstarPlaygrounds,
+  polkadex: usingPolkadexPlaygrounds,
+  moonbeam: usingMoonbeamPlaygrounds,
+} as const;
+
+export function mapToChainId(networkName: keyof typeof NETWORKS) {
+  switch (networkName) {
+    case 'acala':
+      return ACALA_CHAIN;
+    case 'astar':
+      return ASTAR_CHAIN;
+    case 'moonbeam':
+      return MOONBEAM_CHAIN;
+    case 'polkadex':
+      return POLKADEX_CHAIN;
+  }
+}
+
+export function mapToChainUrl(networkName: keyof typeof NETWORKS): string {
+  switch (networkName) {
+    case 'acala':
+      return acalaUrl;
+    case 'astar':
+      return astarUrl;
+    case 'moonbeam':
+      return moonbeamUrl;
+    case 'polkadex':
+      return polkadexUrl;
+  }
+}
+
+export function getDevPlayground<T extends keyof typeof NETWORKS>(name: T) {
+  return NETWORKS[name];
+}
\ No newline at end of file
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -17,15 +17,10 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import config from '../config';
 import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds, usingAstarPlaygrounds, usingPolkadexPlaygrounds} from '../util';
-import {DevUniqueHelper, Event} from '../util/playgrounds/unique.dev';
+import {Event} from '../util/playgrounds/unique.dev';
 import {hexToString, nToBigInt} from '@polkadot/util';
+import {ACALA_CHAIN, ASTAR_CHAIN, MOONBEAM_CHAIN, POLKADEX_CHAIN, SAFE_XCM_VERSION, STATEMINT_CHAIN, UNIQUE_CHAIN, expectFailedToTransact, expectUntrustedReserveLocationFail, uniqueAssetId, uniqueVersionedMultilocation} from './xcm.types';
 
-const UNIQUE_CHAIN = +(process.env.RELAY_UNIQUE_ID || 2037);
-const STATEMINT_CHAIN = +(process.env.RELAY_STATEMINT_ID || 1000);
-const ACALA_CHAIN = +(process.env.RELAY_ACALA_ID || 2000);
-const MOONBEAM_CHAIN = +(process.env.RELAY_MOONBEAM_ID || 2004);
-const ASTAR_CHAIN = +(process.env.RELAY_ASTAR_ID || 2006);
-const POLKADEX_CHAIN = +(process.env.RELAY_POLKADEX_ID || 2040);
 
 const STATEMINT_PALLET_INSTANCE = 50;
 
@@ -54,29 +49,7 @@
 const USDT_ASSET_METADATA_DESCRIPTION = 'USDT';
 const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;
 const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;
-
-const SAFE_XCM_VERSION = 2;
-const maxWaitBlocks = 6;
-
-const uniqueMultilocation = {
-  V2: {
-    parents: 1,
-    interior: {
-      X1: {
-        Parachain: UNIQUE_CHAIN,
-      },
-    },
-  },
-};
 
-const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
-  await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
-        && event.outcome.isFailedToTransactAsset);
-};
-const expectUntrustedReserveLocationFail = async (helper: DevUniqueHelper, messageSent: any) => {
-  await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
-         && event.outcome.isUntrustedReserveLocation);
-};
 describeXCM('[XCM] Integration test: Exchanging USDT with Statemint', () => {
   let alice: IKeyringPair;
   let bob: IKeyringPair;
@@ -704,7 +677,7 @@
 
     // Try to trick Unique
     await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgram);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgram);
 
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
@@ -729,7 +702,7 @@
     );
 
     await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, validXcmProgram);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, validXcmProgram);
     });
 
     await helper.wait.newBlocks(maxWaitBlocks);
@@ -819,17 +792,6 @@
   let balanceUniqueTokenMiddle: bigint;
   let balanceUniqueTokenFinal: bigint;
   const maxWaitBlocks = 6;
-
-  const uniqueAssetId = {
-    Concrete: {
-      parents: 1,
-      interior: {
-        X1: {
-          Parachain: UNIQUE_CHAIN,
-        },
-      },
-    },
-  };
 
   before(async () => {
     await usingPlaygrounds(async (helper, privateKey) => {
@@ -850,7 +812,9 @@
       if it is added again. Needed for debugging
       when this test is run multiple times.
       */
-      if(!isWhitelisted) {
+      if(isWhitelisted) {
+        console.log('UNQ token is already whitelisted on Polkadex');
+      } else {
         await helper.getSudo().xcmHelper.whitelistToken(alice, uniqueAssetId);
       }
 
@@ -951,7 +915,7 @@
 
 
     await usingPolkadexPlaygrounds(polkadexUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, xcmProgram);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, xcmProgram);
 
       xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
@@ -986,7 +950,7 @@
 
 
     await usingPolkadexPlaygrounds(polkadexUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgram);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgram);
 
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
@@ -1465,7 +1429,7 @@
 
     // Try to trick Unique
     await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
-      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgram]);
+      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgram]);
 
       // Needed to bypass the call filter.
       const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
@@ -1494,7 +1458,7 @@
     );
 
     await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
-      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, validXcmProgram]);
+      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, validXcmProgram]);
 
       // Needed to bypass the call filter.
       const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
@@ -1543,7 +1507,7 @@
 
     // Try to trick Unique using full UNQ identification
     await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
-      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramFullId]);
+      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramFullId]);
 
       // Needed to bypass the call filter.
       const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
@@ -1560,7 +1524,7 @@
 
     // Try to trick Unique using shortened UNQ identification
     await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
-      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramHereId]);
+      const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramHereId]);
 
       // Needed to bypass the call filter.
       const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
@@ -1641,6 +1605,8 @@
 
         console.log('3. Set UNQ payment for XCM execution on Astar');
         await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);
+      } else {
+        console.log('UNQ is already registered on Astar');
       }
       console.log('4. Transfer 1 ASTR to recipient to create the account (needed due to existential balance)');
       await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);
@@ -1815,7 +1781,7 @@
 
     // Try to trick Unique
     await usingAstarPlaygrounds(astarUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgram);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgram);
 
       maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
@@ -1840,7 +1806,7 @@
     );
 
     await usingAstarPlaygrounds(astarUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, validXcmProgram);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, validXcmProgram);
     });
 
     await helper.wait.newBlocks(maxWaitBlocks);
@@ -1885,7 +1851,7 @@
 
     // Try to trick Unique using full UNQ identification
     await usingAstarPlaygrounds(astarUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgramFullId);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgramFullId);
 
       maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });
@@ -1898,7 +1864,7 @@
 
     // Try to trick Unique using shortened UNQ identification
     await usingAstarPlaygrounds(astarUrl, async (helper) => {
-      await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgramHereId);
+      await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgramHereId);
 
       maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
     });