diff --git a/zombienet/helpers/wait-hrmp-channel-opened.js b/zombienet/helpers/wait-hrmp-channel-opened.js new file mode 100644 index 0000000000000..e700cab1d7481 --- /dev/null +++ b/zombienet/helpers/wait-hrmp-channel-opened.js @@ -0,0 +1,22 @@ +async function run(nodeName, networkInfo, args) { + const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; + const api = await zombie.connect(wsUri, userDefinedTypes); + + const sibling = args[0]; + + while (true) { + const messagingStateAsObj = await api.query.parachainSystem.relevantMessagingState(); + const messagingState = api.createType("Option", messagingStateAsObj); + if (messagingState.isSome) { + const egressChannels = messagingState.unwrap().egressChannels; + if (egressChannels.find(x => x[0] == sibling)) { + return; + } + } + + // else sleep and retry + await new Promise((resolve) => setTimeout(resolve, 12000)); + } +} + +module.exports = { run } diff --git a/zombienet/tests/0001-asset-transfer-works-rococo-to-westend.zndsl b/zombienet/tests/0001-asset-transfer-works-rococo-to-westend.zndsl index cacef088f4272..cbc0e31cacf10 100644 --- a/zombienet/tests/0001-asset-transfer-works-rococo-to-westend.zndsl +++ b/zombienet/tests/0001-asset-transfer-works-rococo-to-westend.zndsl @@ -4,6 +4,7 @@ Creds: config # step 1: initialize Westend asset hub asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-westend-local" within 120 seconds +asset-hub-westend-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1002" within 400 seconds # step 2: initialize Westend bridge hub bridge-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-westend-local" within 120 seconds diff --git a/zombienet/tests/0001-asset-transfer-works-wococo-to-westend.zndsl b/zombienet/tests/0001-asset-transfer-works-westend-to-rococo.zndsl similarity index 94% rename from zombienet/tests/0001-asset-transfer-works-wococo-to-westend.zndsl rename to zombienet/tests/0001-asset-transfer-works-westend-to-rococo.zndsl index be3927433e118..84c326e94ec03 100644 --- a/zombienet/tests/0001-asset-transfer-works-wococo-to-westend.zndsl +++ b/zombienet/tests/0001-asset-transfer-works-westend-to-rococo.zndsl @@ -4,6 +4,7 @@ Creds: config # step 1: initialize Rococo asset hub asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-rococo-local" within 120 seconds +asset-hub-rococo-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1013" within 400 seconds # step 2: initialize Rococo bridge hub bridge-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-rococo-local" within 120 seconds