-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bridge zombienet tests refactoring #3260
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7d58c54
Remove unneeded paths
serban300 3a32cc4
Rename some variables
serban300 f51360c
Bridge zombienets and scripts adjustments
serban300 375c5fb
Naive bridge testing framework
serban300 121b69e
Address CR comments
serban300 363b22e
Fix paths
serban300 851d18c
prepare CI run
serban300 a2d2640
Merge branch 'master' into bridge-zombienet
serban300 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
$POLKADOT_SDK_PATH/cumulus/scripts/bridges_rococo_westend.sh "$@" |
8 changes: 8 additions & 0 deletions
8
bridges/zombienet/environments/rococo-westend/rococo-init.zndsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml | ||
Creds: config | ||
|
||
# ensure that initialization has completed | ||
asset-hub-rococo-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1013" within 300 seconds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml | ||
Creds: config | ||
|
||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT | ||
|
||
source "${BASH_SOURCE%/*}/../../utils/common.sh" | ||
source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" | ||
|
||
# whether to init the chains (open HRMP channels, set XCM version, create reserve assets, etc) | ||
init=0 | ||
while [ $# -ne 0 ] | ||
do | ||
arg="$1" | ||
case "$arg" in | ||
--init) | ||
init=1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
logs_dir=$TEST_DIR/logs | ||
helper_script="${BASH_SOURCE%/*}/helper.sh" | ||
|
||
rococo_def=$POLKADOT_SDK_PATH/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml | ||
start_zombienet $TEST_DIR $rococo_def rococo_dir rococo_pid | ||
echo | ||
|
||
westend_def=$POLKADOT_SDK_PATH/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml | ||
start_zombienet $TEST_DIR $westend_def westend_dir westend_pid | ||
echo | ||
|
||
if [[ $init -eq 1 ]]; then | ||
rococo_init_log=$logs_dir/rococo-init.log | ||
echo -e "Setting up the rococo side of the bridge. Logs available at: $rococo_init_log\n" | ||
|
||
westend_init_log=$logs_dir/westend-init.log | ||
echo -e "Setting up the westend side of the bridge. Logs available at: $westend_init_log\n" | ||
|
||
$helper_script init-asset-hub-rococo-local >> $rococo_init_log 2>&1 & | ||
rococo_init_pid=$! | ||
$helper_script init-asset-hub-westend-local >> $westend_init_log 2>&1 & | ||
westend_init_pid=$! | ||
wait -n $rococo_init_pid $westend_init_pid | ||
|
||
|
||
$helper_script init-bridge-hub-rococo-local >> $rococo_init_log 2>&1 & | ||
rococo_init_pid=$! | ||
$helper_script init-bridge-hub-westend-local >> $westend_init_log 2>&1 & | ||
westend_init_pid=$! | ||
wait -n $rococo_init_pid $westend_init_pid | ||
|
||
run_zndsl ${BASH_SOURCE%/*}/rococo-init.zndsl $rococo_dir | ||
run_zndsl ${BASH_SOURCE%/*}/westend-init.zndsl $westend_dir | ||
fi | ||
|
||
relay_log=$logs_dir/relay.log | ||
echo -e "Starting rococo-westend relay. Logs available at: $relay_log\n" | ||
start_background_process "$helper_script run-relay" $relay_log relay_pid | ||
|
||
run_zndsl ${BASH_SOURCE%/*}/rococo.zndsl $rococo_dir | ||
echo $rococo_dir > $TEST_DIR/rococo.env | ||
echo | ||
|
||
run_zndsl ${BASH_SOURCE%/*}/westend.zndsl $westend_dir | ||
echo $westend_dir > $TEST_DIR/westend.env | ||
echo | ||
|
||
wait -n $rococo_pid $westend_pid $relay_pid | ||
kill -9 -$$ |
7 changes: 7 additions & 0 deletions
7
bridges/zombienet/environments/rococo-westend/westend-init.zndsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml | ||
Creds: config | ||
|
||
# ensure that initialization has completed | ||
asset-hub-westend-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml | ||
Creds: config | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
test=$1 | ||
shift | ||
|
||
# whether to use paths for zombienet+bridges tests container or for local testing | ||
ZOMBIENET_DOCKER_PATHS=0 | ||
while [ $# -ne 0 ] | ||
do | ||
arg="$1" | ||
case "$arg" in | ||
--docker) | ||
ZOMBIENET_DOCKER_PATHS=1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
export POLKADOT_SDK_PATH=`realpath ${BASH_SOURCE%/*}/../..` | ||
|
||
# set path to binaries | ||
if [ "$ZOMBIENET_DOCKER_PATHS" -eq 1 ]; then | ||
# otherwise zombienet uses some hardcoded paths | ||
unset RUN_IN_CONTAINER | ||
unset ZOMBIENET_IMAGE | ||
|
||
export POLKADOT_BINARY=/usr/local/bin/polkadot | ||
export POLKADOT_PARACHAIN_BINARY=/usr/local/bin/polkadot-parachain | ||
|
||
export ZOMBIENET_BINARY=/usr/local/bin/zombie | ||
export SUBSTRATE_RELAY_BINARY=/usr/local/bin/substrate-relay | ||
else | ||
export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot | ||
export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain | ||
|
||
export ZOMBIENET_BINARY=~/local_bridge_testing/bin/zombienet-linux-x64 | ||
export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay | ||
fi | ||
|
||
export TEST_DIR=`mktemp -d /tmp/bridges-tests-run-XXXXX` | ||
echo -e "Test folder: $TEST_DIR\n" | ||
|
||
${BASH_SOURCE%/*}/tests/$test/run.sh | ||
|
||
kill -9 -$$ || echo "Environment already teared down" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
bridges/zombienet/tests/0001-asset-transfer/roc-reaches-westend.zndsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml | ||
Creds: config | ||
|
||
# send ROC to //Alice from Rococo AH to Westend AH | ||
asset-hub-westend-collator1: run ../../environments/rococo-westend/helper.sh with "reserve-transfer-assets-from-asset-hub-rococo-local" within 120 seconds | ||
|
||
# check that //Alice received the ROC on Westend AH | ||
asset-hub-westend-collator1: js-script ../../helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Rococo" within 300 seconds | ||
|
||
# check that the relayer //Charlie is rewarded by Westend AH | ||
bridge-hub-westend-collator1: js-script ../../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726F,ThisChain,0" within 30 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
source "${BASH_SOURCE%/*}/../../utils/common.sh" | ||
source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" | ||
|
||
${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh --init & | ||
env_pid=$! | ||
|
||
ensure_process_file $env_pid $TEST_DIR/rococo.env 400 | ||
rococo_dir=`cat $TEST_DIR/rococo.env` | ||
echo | ||
|
||
ensure_process_file $env_pid $TEST_DIR/westend.env 180 | ||
westend_dir=`cat $TEST_DIR/westend.env` | ||
echo | ||
|
||
run_zndsl ${BASH_SOURCE%/*}/roc-reaches-westend.zndsl $westend_dir | ||
run_zndsl ${BASH_SOURCE%/*}/wnd-reaches-rococo.zndsl $rococo_dir | ||
|
||
run_zndsl ${BASH_SOURCE%/*}/wroc-reaches-rococo.zndsl $rococo_dir | ||
run_zndsl ${BASH_SOURCE%/*}/wwnd-reaches-westend.zndsl $westend_dir |
12 changes: 12 additions & 0 deletions
12
bridges/zombienet/tests/0001-asset-transfer/wnd-reaches-rococo.zndsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml | ||
Creds: config | ||
|
||
# send WND to //Alice from Westend AH to Rococo AH | ||
asset-hub-rococo-collator1: run ../../environments/rococo-westend/helper.sh with "reserve-transfer-assets-from-asset-hub-westend-local" within 120 seconds | ||
|
||
# check that //Alice received the WND on Rococo AH | ||
asset-hub-rococo-collator1: js-script ../../helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Westend" within 300 seconds | ||
|
||
# check that the relayer //Charlie is rewarded by Rococo AH | ||
bridge-hub-rococo-collator1: js-script ../../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,ThisChain,0" within 30 seconds |
10 changes: 10 additions & 0 deletions
10
bridges/zombienet/tests/0001-asset-transfer/wroc-reaches-rococo.zndsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml | ||
Creds: config | ||
|
||
# send wROC back to Alice from Westend AH to Rococo AH | ||
asset-hub-rococo-collator1: run ../../environments/rococo-westend/helper.sh with "withdraw-reserve-assets-from-asset-hub-westend-local" within 120 seconds | ||
|
||
# check that //Alice received the wROC on Rococo AH | ||
# (we wait until //Alice account increases here - there are no other transactions that may increase it) | ||
asset-hub-rococo-collator1: js-script ../../helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds |
10 changes: 10 additions & 0 deletions
10
bridges/zombienet/tests/0001-asset-transfer/wwnd-reaches-westend.zndsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back | ||
Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml | ||
Creds: config | ||
|
||
# send wWND back to Alice from Rococo AH to Westend AH | ||
asset-hub-westend-collator1: run ../../environments/rococo-westend/helper.sh with "withdraw-reserve-assets-from-asset-hub-rococo-local" within 120 seconds | ||
|
||
# check that //Alice received the wWND on Westend AH | ||
# (we wait until //Alice account increases here - there are no other transactions that may increase it) | ||
asset-hub-westend-collator1: js-script ../../helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
function start_background_process() { | ||
local command=$1 | ||
local log_file=$2 | ||
local __pid=$3 | ||
|
||
$command > $log_file 2>&1 & | ||
eval $__pid="'$!'" | ||
} | ||
|
||
function wait_for_process_file() { | ||
local pid=$1 | ||
local file=$2 | ||
local timeout=$3 | ||
local __found=$4 | ||
|
||
local time=0 | ||
until [ -e $file ]; do | ||
if ! kill -0 $pid; then | ||
echo "Process finished unsuccessfully" | ||
return | ||
fi | ||
if (( time++ >= timeout )); then | ||
echo "Timeout waiting for file $file: $timeout seconds" | ||
eval $__found=0 | ||
return | ||
fi | ||
sleep 1 | ||
done | ||
|
||
echo "File $file found after $time seconds" | ||
eval $__found=1 | ||
} | ||
|
||
function ensure_process_file() { | ||
local pid=$1 | ||
local file=$2 | ||
local timeout=$3 | ||
|
||
wait_for_process_file $pid $file $timeout file_found | ||
if [ "$file_found" != "1" ]; then | ||
exit 1 | ||
fi | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it shouldn't be a part of "environment", but rather the test. E.g. in other tests, relayer is starting after bridge is initialized - to make sure that some mandatory headers are generated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also makes sense to have this modular, but I would keep it as part of the environment as well. Not just for the zombienet tests, but even if we just want to spawn the environment and run some tests manually, would be nice to have the possibility of also start the relayer. For the moment didn't modify this, but in the future we can add a flag like
--init
for this too if necessary. But so far I think that we need the relayer to start for all the tests that we have. WDYT ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need to start relayers for all our tests. But OTOH we need to start it at different points - in test1 we start it early. In test2 and test3 it needs to be started later, after at least one session is completed at relay chain. But since you're only modifying first test here, it is ok to leave it for a follow-up PR