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

difftreelog

test(xcm) manually initialize HRMP

Yaroslav Bolyukin2023-10-19parent: #b423b29.patch.diff
in: master

5 files changed

modified.baedeker/xcm-opal.jsonnetdiffbeforeafterboth
--- a/.baedeker/xcm-opal.jsonnet
+++ b/.baedeker/xcm-opal.jsonnet
@@ -11,8 +11,8 @@
 	spec: {Genesis:{
 		chain: relay_spec,
 		modify:: m.genericRelay($, hrmp = [
-			[$.parachains.opal.paraId, $.parachains.westmint.paraId, 8, 512],
-			[$.parachains.westmint.paraId, $.parachains.opal.paraId, 8, 512],
+			// [$.parachains.opal.paraId, $.parachains.westmint.paraId, 8, 512],
+			// [$.parachains.westmint.paraId, $.parachains.opal.paraId, 8, 512],
 		]),
 	}},
 	nodes: {
modified.baedeker/xcm-quartz.jsonnetdiffbeforeafterboth
11 spec: {Genesis:{11 spec: {Genesis:{
12 chain: relay_spec,12 chain: relay_spec,
13 modify:: m.genericRelay($, hrmp = std.join([], [13 modify:: m.genericRelay($, hrmp = std.join([], [
14 [[$.parachains[a].paraId, $.parachains[b].paraId, 8, 512], [$.parachains[b].paraId, $.parachains[a].paraId, 8, 512]],14 // [[$.parachains[a].paraId, $.parachains[b].paraId, 8, 512], [$.parachains[b].paraId, $.parachains[a].paraId, 8, 512]],
15 for [a, b] in [15 // for [a, b] in [
16 ['quartz', 'karura'],16 // ['quartz', 'karura'],
17 ['quartz', 'moonriver'],17 // ['quartz', 'moonriver'],
18 ['quartz', 'statemine'],18 // ['quartz', 'statemine'],
19 ['quartz', 'shiden'],19 // ['quartz', 'shiden'],
20 ]20 // ]
21 ])),21 ])),
22 }},22 }},
23 nodes: {23 nodes: {
modified.baedeker/xcm-unique.jsonnetdiffbeforeafterboth
--- a/.baedeker/xcm-unique.jsonnet
+++ b/.baedeker/xcm-unique.jsonnet
@@ -13,11 +13,11 @@
 		modify:: m.genericRelay($, hrmp = std.join([], [
 			[[$.parachains[a].paraId, $.parachains[b].paraId, 8, 512], [$.parachains[b].paraId, $.parachains[a].paraId, 8, 512]],
 			for [a, b] in [
-				['unique', 'acala'],
-				['unique', 'moonbeam'],
-				['unique', 'statemint'],
-				['unique', 'astar'],
-				['unique', 'polkadex'],
+				// ['unique', 'acala'],
+				// ['unique', 'moonbeam'],
+				// ['unique', 'statemint'],
+				// ['unique', 'astar'],
+				// ['unique', 'polkadex'],
 			]
 		])),
 	}},
modified.github/workflows/xcm.ymldiffbeforeafterboth
--- a/.github/workflows/xcm.yml
+++ b/.github/workflows/xcm.yml
@@ -326,11 +326,20 @@
           path: ${{ steps.bdk.outputs.composeProject }}
           retention-days: 2
 
-      - name: Run XCM tests
+      - name: Yarn install
         working-directory: tests
         run: |
           yarn install
           yarn add mochawesome
+
+      - name: Call HRMP initialization
+        working-directory: tests
+        run: |
+          yarn ts-node --esm src/util/createHrmp.ts ${{matrix.network}}
+
+      - name: Run XCM tests
+        working-directory: tests
+        run: |
           # Wanted by both wait_for_first_block
           export RPC_URL="${RELAY_OPAL_HTTP_URL:-${RELAY_QUARTZ_HTTP_URL:-${RELAY_UNIQUE_HTTP_URL:-}}}"
           ./scripts/wait_for_first_block.sh
addedtests/src/util/createHrmp.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/util/createHrmp.ts
@@ -0,0 +1,30 @@
+import {usingPlaygrounds} from '.';
+import config from '../config';
+
+const profile = process.argv[2];
+if(!profile) throw new Error('missing profile/relay argument');
+
+await usingPlaygrounds(async (helper, privateKey) => {
+  const bidirOpen = async (a: number, b: number) => {
+    console.log(`Opening ${a} <=> ${b}`);
+    await helper.getSudo().executeExtrinsic(alice, 'api.tx.hrmp.forceOpenHrmpChannel', [a, b, 8, 512]);
+    await helper.getSudo().executeExtrinsic(alice, 'api.tx.hrmp.forceOpenHrmpChannel', [b, a, 8, 512]);
+  };
+  const alice = await privateKey('//Alice');
+  switch (profile) {
+    case 'opal':
+      await bidirOpen(1001, 1002);
+      break;
+    case 'quartz':
+    case 'unique':
+      await bidirOpen(1001, 1002);
+      await bidirOpen(1001, 1003);
+      await bidirOpen(1001, 1004);
+      await bidirOpen(1001, 1005);
+      break;
+    default:
+      throw new Error(`unknown hrmp config profile: ${profile}`);
+  }
+}, config.relayUrl);
+// We miss disconnect/unref somewhere.
+process.exit(0);