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
--- a/tests/src/xcm/lowLevelXcmUnique.test.ts
+++ b/tests/src/xcm/lowLevelXcmUnique.test.ts
@@ -17,98 +17,24 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import config from '../config';
 import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingMoonbeamPlaygrounds, usingAstarPlaygrounds, usingPolkadexPlaygrounds} from '../util';
-import {DevUniqueHelper, Event} from '../util/playgrounds/unique.dev';
+import {Event} from '../util/playgrounds/unique.dev';
 import {nToBigInt} from '@polkadot/util';
 import {hexToString} from '@polkadot/util';
-
-const UNIQUE_CHAIN = +(process.env.RELAY_UNIQUE_ID || 2037);
-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);
-
-
+import {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';
 
-const acalaUrl = config.acalaUrl;
-const moonbeamUrl = config.moonbeamUrl;
-const astarUrl = config.astarUrl;
-const polkadexUrl = config.polkadexUrl;
 
-const ASTAR_DECIMALS = 18n;
-const UNQ_DECIMALS = 18n;
-
 const TRANSFER_AMOUNT = 2000000_000_000_000_000_000_000n;
 const SENDER_BUDGET = 2n * TRANSFER_AMOUNT;
 const SENDBACK_AMOUNT = TRANSFER_AMOUNT / 2n;
 const STAYED_ON_TARGET_CHAIN = TRANSFER_AMOUNT - SENDBACK_AMOUNT;
 const TARGET_CHAIN_TOKEN_TRANSFER_AMOUNT = 100_000_000_000n;
-
-const SAFE_XCM_VERSION = 2;
-const maxWaitBlocks = 6;
-
-const uniqueMultilocation = {
-  V2: {
-    parents: 1,
-    interior: {
-      X1: {
-        Parachain: UNIQUE_CHAIN,
-      },
-    },
-  },
-};
 
 let balanceUniqueTokenInit: bigint;
 let balanceUniqueTokenMiddle: bigint;
 let balanceUniqueTokenFinal: bigint;
 let unqFees: bigint;
-
-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);
-};
 
-const NETWORKS = {
-  acala: usingAcalaPlaygrounds,
-  astar: usingAstarPlaygrounds,
-  polkadex: usingPolkadexPlaygrounds,
-  moonbeam: usingMoonbeamPlaygrounds,
-} as const;
 
-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;
-  }
-}
-
-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;
-  }
-}
-
-function getDevPlayground<T extends keyof typeof NETWORKS>(name: T) {
-  return NETWORKS[name];
-}
-
-
 async function genericSendUnqTo(
   networkName: keyof typeof NETWORKS,
   randomAccount: IKeyringPair,
@@ -227,13 +153,13 @@
 
     await targetPlayground(networkUrl, async (helper) => {
       if('getSudo' in helper) {
-        await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, xcmProgram);
+        await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, xcmProgram);
         xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       } else if('fastDemocracy' in helper) {
-        const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, xcmProgram]);
+        const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, xcmProgram]);
         // Needed to bypass the call filter.
         const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
-        await helper.fastDemocracy.executeProposal('sending MoonBeam -> Unique via XCM program', batchCall);
+        await helper.fastDemocracy.executeProposal(`sending ${networkName} -> Unique via XCM program`, batchCall);
         xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
     });
@@ -279,13 +205,13 @@
 
     await targetPlayground(networkUrl, async (helper) => {
       if('getSudo' in helper) {
-        await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, maliciousXcmProgram);
+        await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, maliciousXcmProgram);
         maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       } else if('fastDemocracy' in 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]]);
-        await helper.fastDemocracy.executeProposal('sending MoonBeam -> Unique via XCM program', batchCall);
+        await helper.fastDemocracy.executeProposal(`sending ${networkName} -> Unique via XCM program`, batchCall);
         maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
     });
@@ -338,16 +264,15 @@
     // Try to trick Unique using full UNQ identification
     await targetPlayground(networkUrl, async (helper) => {
       if('getSudo' in helper) {
-        await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, maliciousXcmProgramFullId);
+        await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, maliciousXcmProgramFullId);
         maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
       // Moonbeam case
       else if('fastDemocracy' in 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]]);
-        await helper.fastDemocracy.executeProposal('try to act like a reserve location for UNQ using path asset identification', batchCall);
+        await helper.fastDemocracy.executeProposal(`${netwokrName} try to act like a reserve location for UNQ using path asset identification`,batchCall);
 
         maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
@@ -362,15 +287,14 @@
     // Try to trick Unique using shortened UNQ identification
     await targetPlayground(networkUrl, async (helper) => {
       if('getSudo' in helper) {
-        await helper.getSudo().xcm.send(sudoer, uniqueMultilocation, maliciousXcmProgramHereId);
+        await helper.getSudo().xcm.send(sudoer, uniqueVersionedMultilocation, maliciousXcmProgramHereId);
         maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
       else if('fastDemocracy' in 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]]);
-        await helper.fastDemocracy.executeProposal('try to act like a reserve location for UNQ using "here" asset identification', batchCall);
+        await helper.fastDemocracy.executeProposal(`${netwokrName} try to act like a reserve location for UNQ using "here" asset identification`, batchCall);
 
         maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
@@ -405,19 +329,17 @@
     );
     await targetPlayground(networkUrl, async (helper) => {
       if('getSudo' in helper) {
-        await helper.getSudo().xcm.send(sudoerOnTargetChain, uniqueMultilocation, maliciousXcmProgramFullId);
+        await helper.getSudo().xcm.send(sudoerOnTargetChain, uniqueVersionedMultilocation, maliciousXcmProgramFullId);
         messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       } else if('fastDemocracy' in 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]]);
-        await helper.fastDemocracy.executeProposal('sending native tokens to the Unique via fast democracy', batchCall);
+        await helper.fastDemocracy.executeProposal(`${netwokrName} sending native tokens to the Unique via fast democracy`, batchCall);
 
         messageSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
       }
     });
-
     await expectFailedToTransact(helper, messageSent);
   });
 }
@@ -492,17 +414,6 @@
 describeXCM('[XCMLL] Integration test: Exchanging tokens with Polkadex', () => {
   let alice: IKeyringPair;
   let randomAccount: IKeyringPair;
-
-  const uniqueAssetId = {
-    Concrete: {
-      parents: 1,
-      interior: {
-        X1: {
-          Parachain: UNIQUE_CHAIN,
-        },
-      },
-    },
-  };
 
   before(async () => {
     await usingPlaygrounds(async (helper, privateKey) => {
@@ -523,7 +434,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);
       }
 
@@ -639,7 +552,7 @@
       const numAssetsWeightHint = 0;
 
       if((await helper.assetManager.assetTypeId(uniqueAssetLocation)).toJSON()) {
-        console.log('Unique asset already registered');
+        console.log('Unique asset already registered on Moonbeam');
       } else {
         const encodedProposal = helper.assetManager.makeRegisterForeignAssetProposal({
           location: uniqueAssetLocation,
@@ -750,6 +663,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);
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
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, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds, usingAstarPlaygrounds, usingPolkadexPlaygrounds} from '../util';19import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds, usingAstarPlaygrounds, usingPolkadexPlaygrounds} from '../util';
20import {DevUniqueHelper, Event} from '../util/playgrounds/unique.dev';20import {Event} from '../util/playgrounds/unique.dev';
21import {hexToString, nToBigInt} from '@polkadot/util';21import {hexToString, nToBigInt} from '@polkadot/util';
22
23const UNIQUE_CHAIN = +(process.env.RELAY_UNIQUE_ID || 2037);22import {ACALA_CHAIN, ASTAR_CHAIN, MOONBEAM_CHAIN, POLKADEX_CHAIN, SAFE_XCM_VERSION, STATEMINT_CHAIN, UNIQUE_CHAIN, expectFailedToTransact, expectUntrustedReserveLocationFail, uniqueAssetId, uniqueVersionedMultilocation} from './xcm.types';
24const STATEMINT_CHAIN = +(process.env.RELAY_STATEMINT_ID || 1000);23
25const ACALA_CHAIN = +(process.env.RELAY_ACALA_ID || 2000);
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);
2924
30const STATEMINT_PALLET_INSTANCE = 50;25const STATEMINT_PALLET_INSTANCE = 50;
3126
55const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;50const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;
56const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;51const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;
5752
58const SAFE_XCM_VERSION = 2;
59const maxWaitBlocks = 6;
60
61const uniqueMultilocation = {
62 V2: {
63 parents: 1,
64 interior: {
65 X1: {
66 Parachain: UNIQUE_CHAIN,
67 },
68 },
69 },
70};
71
72const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
73 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
74 && event.outcome.isFailedToTransactAsset);
75};
76const expectUntrustedReserveLocationFail = async (helper: DevUniqueHelper, messageSent: any) => {
77 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
78 && event.outcome.isUntrustedReserveLocation);
79};
80describeXCM('[XCM] Integration test: Exchanging USDT with Statemint', () => {53describeXCM('[XCM] Integration test: Exchanging USDT with Statemint', () => {
81 let alice: IKeyringPair;54 let alice: IKeyringPair;
82 let bob: IKeyringPair;55 let bob: IKeyringPair;
704677
705 // Try to trick Unique678 // Try to trick Unique
706 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {679 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
707 await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgram);680 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgram);
708681
709 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);682 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
710 });683 });
729 );702 );
730703
731 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {704 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
732 await helper.getSudo().xcm.send(alice, uniqueMultilocation, validXcmProgram);705 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, validXcmProgram);
733 });706 });
734707
735 await helper.wait.newBlocks(maxWaitBlocks);708 await helper.wait.newBlocks(maxWaitBlocks);
820 let balanceUniqueTokenFinal: bigint;793 let balanceUniqueTokenFinal: bigint;
821 const maxWaitBlocks = 6;794 const maxWaitBlocks = 6;
822
823 const uniqueAssetId = {
824 Concrete: {
825 parents: 1,
826 interior: {
827 X1: {
828 Parachain: UNIQUE_CHAIN,
829 },
830 },
831 },
832 };
833795
834 before(async () => {796 before(async () => {
835 await usingPlaygrounds(async (helper, privateKey) => {797 await usingPlaygrounds(async (helper, privateKey) => {
850 if it is added again. Needed for debugging812 if it is added again. Needed for debugging
851 when this test is run multiple times.813 when this test is run multiple times.
852 */814 */
853 if(!isWhitelisted) {815 if(isWhitelisted) {
816 console.log('UNQ token is already whitelisted on Polkadex');
817 } else {
854 await helper.getSudo().xcmHelper.whitelistToken(alice, uniqueAssetId);818 await helper.getSudo().xcmHelper.whitelistToken(alice, uniqueAssetId);
855 }819 }
856820
951915
952916
953 await usingPolkadexPlaygrounds(polkadexUrl, async (helper) => {917 await usingPolkadexPlaygrounds(polkadexUrl, async (helper) => {
954 await helper.getSudo().xcm.send(alice, uniqueMultilocation, xcmProgram);918 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, xcmProgram);
955919
956 xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);920 xcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
957 });921 });
986950
987951
988 await usingPolkadexPlaygrounds(polkadexUrl, async (helper) => {952 await usingPolkadexPlaygrounds(polkadexUrl, async (helper) => {
989 await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgram);953 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgram);
990954
991 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);955 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
992 });956 });
14651429
1466 // Try to trick Unique1430 // Try to trick Unique
1467 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {1431 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
1468 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgram]);1432 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgram]);
14691433
1470 // Needed to bypass the call filter.1434 // Needed to bypass the call filter.
1471 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);1435 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
1494 );1458 );
14951459
1496 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {1460 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
1497 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, validXcmProgram]);1461 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, validXcmProgram]);
14981462
1499 // Needed to bypass the call filter.1463 // Needed to bypass the call filter.
1500 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);1464 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
15431507
1544 // Try to trick Unique using full UNQ identification1508 // Try to trick Unique using full UNQ identification
1545 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {1509 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
1546 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramFullId]);1510 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramFullId]);
15471511
1548 // Needed to bypass the call filter.1512 // Needed to bypass the call filter.
1549 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);1513 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
15601524
1561 // Try to trick Unique using shortened UNQ identification1525 // Try to trick Unique using shortened UNQ identification
1562 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {1526 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
1563 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueMultilocation, maliciousXcmProgramHereId]);1527 const xcmSend = helper.constructApiCall('api.tx.polkadotXcm.send', [uniqueVersionedMultilocation, maliciousXcmProgramHereId]);
15641528
1565 // Needed to bypass the call filter.1529 // Needed to bypass the call filter.
1566 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);1530 const batchCall = helper.encodeApiCall('api.tx.utility.batch', [[xcmSend]]);
16411605
1642 console.log('3. Set UNQ payment for XCM execution on Astar');1606 console.log('3. Set UNQ payment for XCM execution on Astar');
1643 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);1607 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);
1644 }1608 } else {
1609 console.log('UNQ is already registered on Astar');
1610 }
1645 console.log('4. Transfer 1 ASTR to recipient to create the account (needed due to existential balance)');1611 console.log('4. Transfer 1 ASTR to recipient to create the account (needed due to existential balance)');
1646 await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);1612 await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);
1647 });1613 });
18151781
1816 // Try to trick Unique1782 // Try to trick Unique
1817 await usingAstarPlaygrounds(astarUrl, async (helper) => {1783 await usingAstarPlaygrounds(astarUrl, async (helper) => {
1818 await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgram);1784 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgram);
18191785
1820 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1786 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1821 });1787 });
1840 );1806 );
18411807
1842 await usingAstarPlaygrounds(astarUrl, async (helper) => {1808 await usingAstarPlaygrounds(astarUrl, async (helper) => {
1843 await helper.getSudo().xcm.send(alice, uniqueMultilocation, validXcmProgram);1809 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, validXcmProgram);
1844 });1810 });
18451811
1846 await helper.wait.newBlocks(maxWaitBlocks);1812 await helper.wait.newBlocks(maxWaitBlocks);
18851851
1886 // Try to trick Unique using full UNQ identification1852 // Try to trick Unique using full UNQ identification
1887 await usingAstarPlaygrounds(astarUrl, async (helper) => {1853 await usingAstarPlaygrounds(astarUrl, async (helper) => {
1888 await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgramFullId);1854 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgramFullId);
18891855
1890 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1856 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1891 });1857 });
18981864
1899 // Try to trick Unique using shortened UNQ identification1865 // Try to trick Unique using shortened UNQ identification
1900 await usingAstarPlaygrounds(astarUrl, async (helper) => {1866 await usingAstarPlaygrounds(astarUrl, async (helper) => {
1901 await helper.getSudo().xcm.send(alice, uniqueMultilocation, maliciousXcmProgramHereId);1867 await helper.getSudo().xcm.send(alice, uniqueVersionedMultilocation, maliciousXcmProgramHereId);
19021868
1903 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1869 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1904 });1870 });