Skip to content

Commit

Permalink
test: add manual integration test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-da committed Feb 21, 2024
1 parent 1a6cdd1 commit bda1fd1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
37 changes: 37 additions & 0 deletions scripts/linux/run-multiple-instances-from-genesis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
#
# Run three instances where instance 0 and instance 2 are mining but instance 1 is not. The nodes are connected like this:
# (0) <-> (1) <-> (2)
# So whenever a block is found by 0 or by 2, it is propagated through 1.

if ! command -v cpulimit &> /dev/null
then
echo "cpulimit could not be found. Please install it."
echo "For example, on unbuntu: sudo apt-get install cpulimit"
# Add installation instructions for other Linux distributions here.
exit
fi

set -e # Exit on first error.

export RUST_LOG=debug;

LOCAL_STATE_DIR=~/.local/share/neptune-integration-test-from-genesis

EXTRA_ARGS=""

# delete all local state first.
rm -rf $LOCAL_STATE_DIR

RUST_BACKTRACE=1 XDG_DATA_HOME=$LOCAL_STATE_DIR/0/ nice -n 18 -- cargo run -- --network regtest --peer-port 29790 --rpc-port 19790 --mine $EXTRA_ARGS 2>&1 | tee /tmp/integration_test_from_genesis-0.log | sed 's/.*neptune_core:\+\(.*\)/I0: \1/g' &
pid[0]=$!
sleep 5s;
RUST_BACKTRACE=1 XDG_DATA_HOME=$LOCAL_STATE_DIR/1/ nice -n 18 -- cargo run -- --network regtest --peer-port 29791 --rpc-port 19791 --peers 127.0.0.1:29790 $EXTRA_ARGS 2>&1 | tee /tmp/integration_test_from_genesis-1.log | sed 's/.*neptune_core:\+\(.*\)/I1: \1/g' &
pid[1]=$!
sleep 5s;
RUST_BACKTRACE=1 XDG_DATA_HOME=$LOCAL_STATE_DIR/2/ nice -n 18 -- cargo run -- --network regtest --peer-port 29792 --rpc-port 19792 --peers 127.0.0.1:29791 --mine --max-number-of-blocks-before-syncing 1000 $EXTRA_ARGS 2>&1 | tee /tmp/integration_test_from_genesis-2.log | sed 's/.*neptune_core:\+\(.*\)/I2: \1/g' &
pid[2]=$!

# Inspired by https://stackoverflow.com/a/52033580/2574407
trap 'kill -0 ${pid[0]} ${pid[1]} ${pid[2]}; exit 0' SIGINT
wait
7 changes: 7 additions & 0 deletions scripts/linux/shutdown-multiple-instances.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
#
CMD=./target/debug/neptune-cli

$CMD --server-addr 127.0.0.1:19790 shutdown
$CMD --server-addr 127.0.0.1:19791 shutdown
$CMD --server-addr 127.0.0.1:19792 shutdown

0 comments on commit bda1fd1

Please sign in to comment.