This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
creating a local testnet with multiple nodes fails using only flags (#…
- Loading branch information
Showing
4 changed files
with
101 additions
and
7 deletions.
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
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,61 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Function to kill background processes | ||
cleanup() { | ||
echo "Stopping background processes and removing files..." | ||
find . -type f -name "validator_output.txt" -delete | ||
find . -type f -name "node_output.txt" -delete | ||
kill "$validator_pid" "$node_pid" 2>/dev/null | ||
} | ||
|
||
# Trap EXIT signal to ensure cleanup runs on script exit | ||
trap cleanup EXIT | ||
|
||
# build release | ||
cargo build --release | ||
|
||
# copy configs from dev | ||
./target/release/madara setup --from-local ./configs/ --chain=dev --base-path /tmp/alice | ||
|
||
# copy configs over from dev | ||
./target/release/madara setup --from-local ./configs/ --chain=dev --base-path /tmp/node1 | ||
|
||
# purge validator chain | ||
./target/release/madara purge-chain --base-path /tmp/alice --chain dev -y | ||
|
||
# purge node chain | ||
./target/release/madara purge-chain --base-path /tmp/node1 --chain dev -y | ||
|
||
# run validator in background instance | ||
./target/release/madara \ | ||
--base-path=/tmp/alice \ | ||
--chain=dev \ | ||
--alice \ | ||
--node-key=0000000000000000000000000000000000000000000000000000000000000001 \ | ||
--validator > validator_output.txt 2>&1 & | ||
validator_pid=$! | ||
|
||
|
||
# run node in another background instance | ||
./target/release/madara \ | ||
--chain=dev \ | ||
--bootnodes=/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp \ | ||
--base-path=/tmp/node1 \ | ||
--rpc-port=9946 > node_output.txt 2>&1 & | ||
node_pid=$! | ||
|
||
# Give some time for the services to start and produce output | ||
sleep 20 | ||
|
||
# look for the 1 peer message | ||
specific_message="1 peers" | ||
|
||
# Check if the message is there in the file and fail if not | ||
if ! grep -q "$specific_message" validator_output.txt; then | ||
echo "Node failed to connect to validator" | ||
cat validator_output.txt | ||
cat node_output.txt | ||
exit 1 | ||
fi | ||
|
||
echo "Validator successfully connected." |