Skip to content

Commit

Permalink
Bridge zombienet tests: remove old command (#5434)
Browse files Browse the repository at this point in the history
Related to: #3176

This PR:
- migrates test 0003 to the new bridges zombienet tests command
**This test didn't work before and it still doesn't work. It was added
at a time when we couldn't run it because we didn't have the scafolding.
It needs to be fixed. For the moment we keep it in the repo as it is
since the idea has value. But we don't run it in the CI. We can also
decide to remove it in the future**
- removes the old command for running bridge zombienet tests
- updates the README
  • Loading branch information
serban300 authored Aug 28, 2024
1 parent c4ced11 commit edd6f71
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .gitlab/pipeline/zombienet/bridges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ zombienet-bridges-0001-asset-transfer-works:
extends:
- .zombienet-bridges-common
script:
- /home/nonroot/bridges-polkadot-sdk/bridges/testing/run-new-test.sh 0001-asset-transfer --docker
- /home/nonroot/bridges-polkadot-sdk/bridges/testing/run-test.sh 0001-asset-transfer --docker
- echo "Done"

zombienet-bridges-0002-free-headers-synced-while-idle:
extends:
- .zombienet-bridges-common
script:
- /home/nonroot/bridges-polkadot-sdk/bridges/testing/run-new-test.sh 0002-free-headers-synced-while-idle --docker
- /home/nonroot/bridges-polkadot-sdk/bridges/testing/run-test.sh 0002-free-headers-synced-while-idle --docker
- echo "Done"
22 changes: 10 additions & 12 deletions bridges/testing/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# Bridges Tests for Local Rococo <> Westend Bridge

This folder contains [zombienet](https://github.com/paritytech/zombienet/) based integration tests for both
onchain and offchain bridges code. Due to some
[technical difficulties](https://github.com/paritytech/parity-bridges-common/pull/2649#issue-1965339051), we
are using native zombienet provider, which means that you need to build some binaries locally.
onchain and offchain bridges code.

To start those tests, you need to:
Prerequisites for running the tests locally:

- download latest [zombienet release](https://github.com/paritytech/zombienet/releases);

- build Polkadot binary by running `cargo build -p polkadot --release --features fast-runtime` command in the
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;

- build Polkadot Parachain binary by running `cargo build -p polkadot-parachain-bin --release` command in the
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;

- ensure that you have [`node`](https://nodejs.org/en) installed. Additionally, we'll need globally installed
`polkadot/api-cli` package (use `npm install -g @polkadot/api-cli@beta` to install it);
`polkadot/api-cli` package (use `npm install -g @polkadot/api-cli@beta` to install it);

- build Substrate relay by running `cargo build -p substrate-relay --release` command in the
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone.
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone;

- copy fresh `substrate-relay` binary, built in previous point, to the `~/local_bridge_testing/bin/substrate-relay`;
- copy the `substrate-relay` binary, built in the previous step, to `~/local_bridge_testing/bin/substrate-relay`;

- change the `POLKADOT_SDK_PATH` and `ZOMBIENET_BINARY_PATH` (and ensure that the nearby variables
have correct values) in the `./run-tests.sh`.
After that, any test can be run using the `run-test.sh` command.
Example: `./run-new-test.sh 0001-asset-transfer`

After that, you could run tests with the `./run-tests.sh` command. Hopefully, it'll show the
Hopefully, it'll show the
"All tests have completed successfully" message in the end. Otherwise, it'll print paths to zombienet
process logs, which, in turn, may be used to track locations of all spinned relay and parachain nodes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ async function run(nodeName, networkInfo, args) {
// wait until we have received + delivered messages OR until timeout
await utils.pollUntil(
exitAfterSeconds,
() => { return atLeastOneMessageReceived && atLeastOneMessageDelivered; },
() => { unsubscribe(); },
() => {
return atLeastOneMessageReceived && atLeastOneMessageDelivered;
},
() => {
unsubscribe();
},
() => {
if (!atLeastOneMessageReceived) {
throw new Error("No messages received from bridged chain");
Expand All @@ -78,4 +82,4 @@ async function run(nodeName, networkInfo, args) {
);
}

module.exports = { run }
module.exports = {run}
File renamed without changes.
138 changes: 0 additions & 138 deletions bridges/testing/run-tests.sh

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Description: While relayer is active, we only sync mandatory and required Rococo (and Rococo BH) headers to Westend BH.
Network: {{ENV_PATH}}/bridge_hub_westend_local_network.toml
Creds: config

# ensure that relayer won't sync any extra headers while delivering messages and confirmations
bridge-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/only-required-headers-synced-when-active.js with "500,rococo-at-westend" within 600 seconds

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

set -e

# TODO: This test doesn't work. It was added at a time when we couldn't run it because we didn't have the scafolding.
# It needs to be fixed. For the moment we keep it in the repo as it is since the idea has value.
# But we don't run it in the CI.

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

export ENV_PATH=`realpath ${BASH_SOURCE%/*}/../../environments/rococo-westend`

logs_dir=$TEST_DIR/logs

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

ensure_process_file $env_pid $TEST_DIR/rococo.env 600
rococo_dir=`cat $TEST_DIR/rococo.env`
echo

ensure_process_file $env_pid $TEST_DIR/westend.env 300
westend_dir=`cat $TEST_DIR/westend.env`
echo

echo "Sending message from Rococo to Westend"
$ENV_PATH/helper.sh auto-log reserve-transfer-assets-from-asset-hub-rococo-local 5000000000000
echo

echo "Sending message from Westend to Rococo"
$ENV_PATH/helper.sh auto-log reserve-transfer-assets-from-asset-hub-westend-local 5000000000000
echo


# Start the relayer with a 30s delay
# We want to be sure that the messages won't be relayed before starting the js script in `rococo-to-westend.zndsl`
start_relayer_log=$logs_dir/start_relayer.log
echo -e "The rococo-westend relayer will be started in 30s. Logs will be available at: $start_relayer_log\n"
(sleep 30 && $ENV_PATH/start_relayer.sh \
$rococo_dir $westend_dir finality_relayer_pid parachains_relayer_pid messages_relayer_pid > $start_relayer_log)&

run_zndsl ${BASH_SOURCE%/*}/rococo-to-westend.zndsl $westend_dir

0 comments on commit edd6f71

Please sign in to comment.