Add two new zombienet tests for bridges (manual run) (#3072)

extracted useful code from #2982 

This PR:
- adds test 2 for Rococo <> Westend bridge: checks that relayer doesn't
submit any extra headers while there are no any messages;
- adds test 3 for Rococo <> Westend bridge: checks that relayer doesn't
submit any extra headers when there are messages;
- fixes most of comments from #2439 (like: log names, ability to run
specify test number when calling `run-tests.sh`).

Right now of all our tests, only test 2 is working (until BHs will be
upgraded to use async backing), so you can test it with
`./bridges/zombienet/run-tests.sh --test 2` locally.
This commit is contained in:
Svyatoslav Nikolsky
2024-01-29 14:56:48 +03:00
committed by GitHub
parent 008e0fe45e
commit 2e6067d768
16 changed files with 421 additions and 53 deletions
@@ -2,31 +2,36 @@ Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset
Network: ../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml
Creds: config
# step 0: start relayer
# (started by sibling 0001-asset-transfer-works-westend-to-rococo.zndsl test)
# step 1: initialize Westend AH
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-westend-local" within 240 seconds
asset-hub-westend-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1002" within 400 seconds
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-westend-local" within 60 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
bridge-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-westend-local" within 60 seconds
# step 3: relay is started elsewhere - let's wait until with-Rococo GRANPDA pallet is initialized at Westend
# step 3: ensure that initialization has completed
asset-hub-westend-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds
# step 4: relay is already started - let's wait until with-Rococo GRANPDA pallet is initialized at Westend
bridge-hub-westend-collator1: js-script ../helpers/best-finalized-header-at-bridged-chain.js with "Rococo,0" within 400 seconds
# step 4: send WND to //Alice on Rococo AH
# step 5: send WND to //Alice on Rococo AH
# (that's a required part of a sibling 0001-asset-transfer-works-westend-to-rococo.zndsl test)
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "reserve-transfer-assets-from-asset-hub-westend-local" within 120 seconds
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "reserve-transfer-assets-from-asset-hub-westend-local" within 60 seconds
# step 5: elsewhere Rococo has sent ROC to //Alice - let's wait for it
# step 6: elsewhere Rococo has sent ROC to //Alice - let's wait for it
asset-hub-westend-collator1: js-script ../helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Rococo" within 600 seconds
# step 6: check that the relayer //Charlie is rewarded by both our AH and target AH
# step 7: check that the relayer //Charlie is rewarded by both our AH and target AH
bridge-hub-westend-collator1: js-script ../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726f,BridgedChain,0" within 300 seconds
bridge-hub-westend-collator1: js-script ../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726F,ThisChain,0" within 300 seconds
# step 7: send wROC back to Alice at Rococo AH
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "withdraw-reserve-assets-from-asset-hub-westend-local" within 120 seconds
# step 8: send wROC back to Alice at Rococo AH
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "withdraw-reserve-assets-from-asset-hub-westend-local" within 60 seconds
# step 8: elsewhere Rococo has sent wWND to //Alice - let's wait for it
# step 9: elsewhere Rococo has sent wWND to //Alice - let's wait for it
# (we wait until //Alice account increases here - there are no other transactionc that may increase it)
asset-hub-westend-collator1: js-script ../helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 600 seconds
@@ -2,31 +2,36 @@ Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset
Network: ../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml
Creds: config
# step 0: start relayer
bridge-hub-rococo-collator1: run ../scripts/start-relayer.sh within 60 seconds
# step 1: initialize Rococo AH
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-rococo-local" within 240 seconds
asset-hub-rococo-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1013" within 400 seconds
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-rococo-local" within 60 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
bridge-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-rococo-local" within 60 seconds
# step 3: relay is started elsewhere - let's wait until with-Westend GRANPDA pallet is initialized at Rococo
# step 3: ensure that initialization has completed
asset-hub-rococo-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1013" within 600 seconds
# step 4: relay is already started - let's wait until with-Westend GRANPDA pallet is initialized at Rococo
bridge-hub-rococo-collator1: js-script ../helpers/best-finalized-header-at-bridged-chain.js with "Westend,0" within 400 seconds
# step 4: send ROC to //Alice on Westend AH
# step 5: send ROC to //Alice on Westend AH
# (that's a required part of a sibling 0001-asset-transfer-works-rococo-to-westend.zndsl test)
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "reserve-transfer-assets-from-asset-hub-rococo-local" within 120 seconds
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "reserve-transfer-assets-from-asset-hub-rococo-local" within 60 seconds
# step 5: elsewhere Westend has sent WND to //Alice - let's wait for it
# step 6: elsewhere Westend has sent WND to //Alice - let's wait for it
asset-hub-rococo-collator1: js-script ../helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Westend" within 600 seconds
# step 6: check that the relayer //Charlie is rewarded by both our AH and target AH
# step 7: check that the relayer //Charlie is rewarded by both our AH and target AH
bridge-hub-rococo-collator1: js-script ../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,BridgedChain,0" within 300 seconds
bridge-hub-rococo-collator1: js-script ../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,ThisChain,0" within 300 seconds
# step 7: send wWND back to Alice at Westend AH
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "withdraw-reserve-assets-from-asset-hub-rococo-local" within 120 seconds
# step 8: send wWND back to Alice at Westend AH
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "withdraw-reserve-assets-from-asset-hub-rococo-local" within 60 seconds
# step 8: elsewhere Westend has sent wROC to //Alice - let's wait for it
# step 9: elsewhere Westend has sent wROC to //Alice - let's wait for it
# (we wait until //Alice account increases here - there are no other transactionc that may increase it)
asset-hub-rococo-collator1: js-script ../helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 600 seconds
@@ -1,5 +0,0 @@
#!/bin/bash
pushd $POLKADOT_SDK_FOLDER/cumulus/scripts
./bridges_rococo_westend.sh run-relay
popd
@@ -0,0 +1,26 @@
Description: While relayer is idle, we only sync mandatory Rococo (and a single Rococo BH) headers to Westend BH.
Network: ../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml
Creds: config
# step 1: initialize Westend bridge hub
bridge-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-westend-local" within 60 seconds
# step 2: sleep some time before starting relayer. We want to sleep for at least 1 session, which is expected to
# be 60 seconds for test environment.
sleep 120 seconds
# step 3: start relayer
# (it is started by the sibling 0002-mandatory-headers-synced-while-idle-westend-to-rococo.zndsl test file)
# it also takes some time for relayer to initialize bridge, so let's sleep for 5 minutes to be sure that parachain
# header has been synced
# step 4: ensure that relayer is only syncing mandatory headers while idle. This includes both headers that were
# born while relay was offline and those in the next 100 seconds while script is active.
bridge-hub-westend-collator1: js-script ../helpers/only-mandatory-headers-synced-when-idle.js with "300,rococo-at-westend" within 600 seconds
# wait until other network test has completed OR exit with an error too
asset-hub-westend-collator1: run ../scripts/sync-exit.sh within 600 seconds
# wait until other network test has completed OR exit with an error too
asset-hub-westend-collator1: run ../scripts/sync-exit.sh within 600 seconds
@@ -0,0 +1,26 @@
Description: While relayer is idle, we only sync mandatory Westend (and a single Westend BH) headers to Rococo BH.
Network: ../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml
Creds: config
# step 1: initialize Rococo bridge hub
bridge-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-rococo-local" within 60 seconds
# step 2: sleep some time before starting relayer. We want to sleep for at least 1 session, which is expected to
# be 60 seconds for test environment.
sleep 120 seconds
# step 3: start relayer
bridge-hub-rococo-collator1: run ../scripts/start-relayer.sh within 60 seconds
# it also takes some time for relayer to initialize bridge, so let's sleep for 5 minutes to be sure that parachain
# header has been synced
# step 4: ensure that relayer is only syncing mandatory headers while idle. This includes both headers that were
# born while relay was offline and those in the next 100 seconds while script is active.
bridge-hub-rococo-collator1: js-script ../helpers/only-mandatory-headers-synced-when-idle.js with "300,westend-at-rococo" within 600 seconds
# wait until other network test has completed OR exit with an error too
asset-hub-rococo-collator1: run ../scripts/sync-exit.sh within 600 seconds
# wait until other network test has completed OR exit with an error too
asset-hub-rococo-collator1: run ../scripts/sync-exit.sh within 600 seconds
@@ -0,0 +1,26 @@
Description: While relayer is active, we only sync mandatory and required Rococo (and Rococo BH) headers to Westend BH.
Network: ../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml
Creds: config
# step 1: initialize Westend AH
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-westend-local" within 60 seconds
# step 2: initialize Westend bridge hub
bridge-hub-westend-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-westend-local" within 60 seconds
# step 3: ensure that initialization has completed
asset-hub-westend-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds
# step 4: send message from Westend to Rococo
asset-hub-westend-collator1: run ../scripts/invoke-script.sh with "reserve-transfer-assets-from-asset-hub-westend-local" within 60 seconds
# step 5: start relayer
# (we are starting it after sending the message to be sure that relayer won't relay messages before our js script
# will be started at step 6)
# (it is started by sibling 0003-required-headers-synced-while-active-westend-to-rococo.zndsl)
# step 6: ensure that relayer won't sync any extra headers while delivering messages and confirmations
bridge-hub-westend-collator1: js-script ../helpers/only-required-headers-synced-when-active.js with "500,rococo-at-westend" within 600 seconds
# wait until other network test has completed OR exit with an error too
asset-hub-westend-collator1: run ../scripts/sync-exit.sh within 600 seconds
@@ -0,0 +1,26 @@
Description: While relayer is active, we only sync mandatory and required Westend (and Westend BH) headers to Rococo BH.
Network: ../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml
Creds: config
# step 1: initialize Rococo AH
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-asset-hub-rococo-local" within 60 seconds
# step 2: initialize Rococo bridge hub
bridge-hub-rococo-collator1: run ../scripts/invoke-script.sh with "init-bridge-hub-rococo-local" within 60 seconds
# step 3: ensure that initialization has completed
asset-hub-rococo-collator1: js-script ../helpers/wait-hrmp-channel-opened.js with "1013" within 600 seconds
# step 4: send message from Rococo to Westend
asset-hub-rococo-collator1: run ../scripts/invoke-script.sh with "reserve-transfer-assets-from-asset-hub-rococo-local" within 60 seconds
# step 5: start relayer
# (we are starting it after sending the message to be sure that relayer won't relay messages before our js script
# will be started at step 6)
bridge-hub-rococo-collator1: run ../scripts/start-relayer.sh within 60 seconds
# step 6: ensure that relayer won't sync any extra headers while delivering messages and confirmations
bridge-hub-rococo-collator1: js-script ../helpers/only-required-headers-synced-when-active.js with "500,westend-at-rococo" within 600 seconds
# wait until other network test has completed OR exit with an error too
asset-hub-rococo-collator1: run ../scripts/sync-exit.sh within 600 seconds