Skip to content

Commit

Permalink
Bridge zombienet tests: move all "framework" files under one folder (#…
Browse files Browse the repository at this point in the history
…3462)

Related to #3400

Moving all bridges testing "framework" files under one folder in order
to be able to download the entire folder when we want to add tests in
other repos

No significant functional changes
  • Loading branch information
serban300 authored Feb 23, 2024
1 parent 3386377 commit 6fc1d41
Show file tree
Hide file tree
Showing 34 changed files with 45 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# import common functions
source "${BASH_SOURCE%/*}/../../utils/bridges.sh"
source "$FRAMEWORK_PATH/utils/bridges.sh"

# Expected sovereign accounts.
#
Expand Down
2 changes: 1 addition & 1 deletion bridges/testing/environments/rococo-westend/helper.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

$POLKADOT_SDK_PATH/bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh "$@"
$ENV_PATH/bridges_rococo_westend.sh "$@"
4 changes: 2 additions & 2 deletions bridges/testing/environments/rococo-westend/rococo-init.zndsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back
Description: Check if the HRMP channel between Rococo BH and Rococo AH was opened successfully
Network: ./bridge_hub_rococo_local_network.toml
Creds: config

# ensure that initialization has completed
asset-hub-rococo-collator1: js-script ../../js-helpers/wait-hrmp-channel-opened.js with "1013" within 300 seconds
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wait-hrmp-channel-opened.js with "1013" within 300 seconds


4 changes: 2 additions & 2 deletions bridges/testing/environments/rococo-westend/rococo.zndsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back
Description: Check if the with-Westend GRANPDA pallet was initialized at Rococo BH
Network: ./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 ../../js-helpers/best-finalized-header-at-bridged-chain.js with "Westend,0" within 400 seconds
bridge-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/best-finalized-header-at-bridged-chain.js with "Westend,0" within 400 seconds

2 changes: 1 addition & 1 deletion bridges/testing/environments/rococo-westend/spawn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT

source "${BASH_SOURCE%/*}/../../utils/zombienet.sh"
source "$FRAMEWORK_PATH/utils/zombienet.sh"

# whether to init the chains (open HRMP channels, set XCM version, create reserve assets, etc)
init=0
Expand Down
4 changes: 2 additions & 2 deletions bridges/testing/environments/rococo-westend/start_relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -e

source "${BASH_SOURCE%/*}/../../utils/common.sh"
source "${BASH_SOURCE%/*}/../../utils/zombienet.sh"
source "$FRAMEWORK_PATH/utils/common.sh"
source "$FRAMEWORK_PATH/utils/zombienet.sh"

rococo_dir=$1
westend_dir=$2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back
Description: Check if the HRMP channel between Westend BH and Westend AH was opened successfully
Network: ./bridge_hub_westend_local_network.toml
Creds: config

# ensure that initialization has completed
asset-hub-westend-collator1: js-script ../../js-helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds

4 changes: 2 additions & 2 deletions bridges/testing/environments/rococo-westend/westend.zndsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back
Description: Check if the with-Rococo GRANPDA pallet was initialized at Westend BH
Network: ./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 ../../js-helpers/best-finalized-header-at-bridged-chain.js with "Rococo,0" within 400 seconds
bridge-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/best-finalized-header-at-bridged-chain.js with "Rococo,0" within 400 seconds
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function ensure_polkadot_js_api() {
echo ""
echo ""
echo "-------------------"
echo "Installing (nodejs) sub module: $(dirname "$0")/generate_hex_encoded_call"
pushd $(dirname "$0")/generate_hex_encoded_call
echo "Installing (nodejs) sub module: ${BASH_SOURCE%/*}/generate_hex_encoded_call"
pushd ${BASH_SOURCE%/*}/generate_hex_encoded_call
npm install
popd
fi
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions bridges/testing/run-new-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ do
done

export POLKADOT_SDK_PATH=`realpath ${BASH_SOURCE%/*}/../..`
export FRAMEWORK_PATH=`realpath ${BASH_SOURCE%/*}/framework`

# set path to binaries
if [ "$ZOMBIENET_DOCKER_PATHS" -eq 1 ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back
Network: ../../environments/rococo-westend/bridge_hub_westend_local_network.toml
Network: {{ENV_PATH}}/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
asset-hub-westend-collator1: run {{ENV_PATH}}/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 ../../js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Rococo" within 300 seconds
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-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 ../../js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726F,ThisChain,0" within 30 seconds
bridge-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726F,ThisChain,0" within 30 seconds
8 changes: 5 additions & 3 deletions bridges/testing/tests/0001-asset-transfer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

set -e

source "${BASH_SOURCE%/*}/../../utils/common.sh"
source "${BASH_SOURCE%/*}/../../utils/zombienet.sh"
source "${BASH_SOURCE%/*}/../../framework/utils/common.sh"
source "${BASH_SOURCE%/*}/../../framework/utils/zombienet.sh"

${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh --init --start-relayer &
export ENV_PATH=`realpath ${BASH_SOURCE%/*}/../../environments/rococo-westend`

$ENV_PATH/spawn.sh --init --start-relayer &
env_pid=$!

ensure_process_file $env_pid $TEST_DIR/rococo.env 600
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back
Network: ../../environments/rococo-westend/bridge_hub_rococo_local_network.toml
Network: {{ENV_PATH}}/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
asset-hub-rococo-collator1: run {{ENV_PATH}}/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 ../../js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Westend" within 300 seconds
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-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 ../../js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,ThisChain,0" within 30 seconds
bridge-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,ThisChain,0" within 30 seconds
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back
Network: ../../environments/rococo-westend/bridge_hub_westend_local_network.toml
Network: {{ENV_PATH}}/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
asset-hub-rococo-collator1: run {{ENV_PATH}}/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 ../../js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back
Network: ../../environments/rococo-westend/bridge_hub_westend_local_network.toml
Network: {{ENV_PATH}}/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
asset-hub-westend-collator1: run {{ENV_PATH}}/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 ../../js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Description: While relayer is idle, we only sync mandatory Rococo (and a single Rococo BH) headers to Westend BH.
Network: ../../environments/rococo-westend/bridge_hub_westend_local_network.toml
Network: {{ENV_PATH}}/bridge_hub_westend_local_network.toml
Creds: config

# ensure that relayer is only syncing mandatory headers while idle. This includes both headers that were
# generated while relay was offline and those in the next 100 seconds while script is active.
bridge-hub-westend-collator1: js-script ../../js-helpers/only-mandatory-headers-synced-when-idle.js with "300,rococo-at-westend" within 600 seconds
bridge-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/only-mandatory-headers-synced-when-idle.js with "300,rococo-at-westend" within 600 seconds

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -e

source "${BASH_SOURCE%/*}/../../utils/common.sh"
source "${BASH_SOURCE%/*}/../../utils/zombienet.sh"
source "${BASH_SOURCE%/*}/../../framework/utils/common.sh"
source "${BASH_SOURCE%/*}/../../framework/utils/zombienet.sh"

# We use `--relayer-delay` in order to 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.
${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh &
export ENV_PATH=`realpath ${BASH_SOURCE%/*}/../../environments/rococo-westend`

$ENV_PATH/spawn.sh &
env_pid=$!

ensure_process_file $env_pid $TEST_DIR/rococo.env 600
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Description: While relayer is idle, we only sync mandatory Westend (and a single Westend BH) headers to Rococo BH.
Network: ../../environments/rococo-westend/bridge_hub_rococo_local_network.toml
Network: {{ENV_PATH}}/bridge_hub_rococo_local_network.toml
Creds: config

# ensure that relayer is only syncing mandatory headers while idle. This includes both headers that were
# generated while relay was offline and those in the next 100 seconds while script is active.
bridge-hub-rococo-collator1: js-script ../../js-helpers/only-mandatory-headers-synced-when-idle.js with "300,westend-at-rococo" within 600 seconds
bridge-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/only-mandatory-headers-synced-when-idle.js with "300,westend-at-rococo" within 600 seconds
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN mkdir -p /home/nonroot/bridges-polkadot-sdk
COPY ./artifacts/bridges-polkadot-sdk /home/nonroot/bridges-polkadot-sdk
# also prepare `generate_hex_encoded_call` for running
RUN set -eux; \
cd /home/nonroot/bridges-polkadot-sdk/bridges/testing/utils/generate_hex_encoded_call; \
cd /home/nonroot/bridges-polkadot-sdk/bridges/testing/framework/utils/generate_hex_encoded_call; \
npm install

# check if executable works in this container
Expand Down

0 comments on commit 6fc1d41

Please sign in to comment.