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
before · .baedeker/xcm-opal.jsonnet
1local2m = import 'baedeker-library/mixin/spec.libsonnet',3;45function(relay_spec)67local relay = {8	name: 'relay',9	bin: 'bin/polkadot',10	validatorIdAssignment: 'staking',11	spec: {Genesis:{12		chain: relay_spec,13		modify:: m.genericRelay($, hrmp = [14			[$.parachains.opal.paraId, $.parachains.westmint.paraId, 8, 512],15			[$.parachains.westmint.paraId, $.parachains.opal.paraId, 8, 512],16		]),17	}},18	nodes: {19		[name]: {20			bin: $.bin,21			wantedKeys: 'relay',22		},23		for name in ['alice', 'bob', 'charlie', 'dave', 'eve']24	},25};2627local opal = {28	name: 'opal',29	bin: 'bin/unique',30	paraId: 1001,31	spec: {Genesis:{32		modify:: m.genericPara($),33	}},34	nodes: {35		[name]: {36			bin: $.bin,37			wantedKeys: 'para',38		},39		for name in ['alice', 'bob']40	},41};4243local westmint = {44	name: 'westmint',45	bin: 'bin/cumulus',46	paraId: 1002,47	spec: {Genesis:{48		chain: 'westmint-local',49		modify:: m.genericPara($),50	}},51	nodes: {52		[name]: {53			bin: $.bin,54			wantedKeys: 'para',55		},56		for name in ['alice', 'bob']57	},58};5960relay + {61	parachains: {62		[para.name]: para,63		for para in [opal, westmint]64	},65}
after · .baedeker/xcm-opal.jsonnet
1local2m = import 'baedeker-library/mixin/spec.libsonnet',3;45function(relay_spec)67local relay = {8	name: 'relay',9	bin: 'bin/polkadot',10	validatorIdAssignment: 'staking',11	spec: {Genesis:{12		chain: relay_spec,13		modify:: m.genericRelay($, hrmp = [14			// [$.parachains.opal.paraId, $.parachains.westmint.paraId, 8, 512],15			// [$.parachains.westmint.paraId, $.parachains.opal.paraId, 8, 512],16		]),17	}},18	nodes: {19		[name]: {20			bin: $.bin,21			wantedKeys: 'relay',22		},23		for name in ['alice', 'bob', 'charlie', 'dave', 'eve']24	},25};2627local opal = {28	name: 'opal',29	bin: 'bin/unique',30	paraId: 1001,31	spec: {Genesis:{32		modify:: m.genericPara($),33	}},34	nodes: {35		[name]: {36			bin: $.bin,37			wantedKeys: 'para',38		},39		for name in ['alice', 'bob']40	},41};4243local westmint = {44	name: 'westmint',45	bin: 'bin/cumulus',46	paraId: 1002,47	spec: {Genesis:{48		chain: 'westmint-local',49		modify:: m.genericPara($),50	}},51	nodes: {52		[name]: {53			bin: $.bin,54			wantedKeys: 'para',55		},56		for name in ['alice', 'bob']57	},58};5960relay + {61	parachains: {62		[para.name]: para,63		for para in [opal, westmint]64	},65}
modified.baedeker/xcm-quartz.jsonnetdiffbeforeafterboth
--- a/.baedeker/xcm-quartz.jsonnet
+++ b/.baedeker/xcm-quartz.jsonnet
@@ -11,13 +11,13 @@
 	spec: {Genesis:{
 		chain: relay_spec,
 		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 [
-				['quartz', 'karura'],
-				['quartz', 'moonriver'],
-				['quartz', 'statemine'],
-				['quartz', 'shiden'],
-			]
+			// [[$.parachains[a].paraId, $.parachains[b].paraId, 8, 512], [$.parachains[b].paraId, $.parachains[a].paraId, 8, 512]],
+			// for [a, b] in [
+			// 	['quartz', 'karura'],
+			// 	['quartz', 'moonriver'],
+			// 	['quartz', 'statemine'],
+			// 	['quartz', 'shiden'],
+			// ]
 		])),
 	}},
 	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);