test script cleanup

This commit is contained in:
Roy Crihfield 2022-05-13 17:53:31 +08:00
parent 8beea8811d
commit 21026234fb

View File

@ -17,10 +17,10 @@ RPC_PORT="854"
IP_ADDR="0.0.0.0" IP_ADDR="0.0.0.0"
KEY="mykey" KEY="mykey"
CHAINID="ethermint_9000-1" CHAINID="chibaclonk_9000-1"
MONIKER="mymoniker" MONIKER="mymoniker"
## default port prefixes for ethermintd ## default port prefixes for chibaclonkd
NODE_P2P_PORT="2660" NODE_P2P_PORT="2660"
NODE_PORT="2663" NODE_PORT="2663"
NODE_RPC_PORT="2666" NODE_RPC_PORT="2666"
@ -55,6 +55,7 @@ set -euxo pipefail
DATA_DIR=$(mktemp -d -t ethermint-datadir.XXXXX) DATA_DIR=$(mktemp -d -t ethermint-datadir.XXXXX)
DATA_DIR=$(mktemp -d -t chibaclonk-datadir.XXXXX)
if [[ ! "$DATA_DIR" ]]; then if [[ ! "$DATA_DIR" ]]; then
echo "Could not create $DATA_DIR" echo "Could not create $DATA_DIR"
exit 1 exit 1
@ -105,17 +106,21 @@ init_func() {
start_func() { start_func() {
echo "starting chibaclonk node $i in background ..." echo "starting chibaclonk node $i in background ..."
"$PWD"/build/chibaclonkd start --pruning=nothing --rpc.unsafe \ "$PWD"/build/chibaclonkd start \
--p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" --address tcp://$IP_ADDR:$NODE_PORT"$i" --rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \ --pruning=nothing --rpc.unsafe \
--json-rpc.address=$IP_ADDR:$RPC_PORT"$i" \ --p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" \
--json-rpc.api="eth,txpool,personal,net,debug,web3" \ --address tcp://$IP_ADDR:$NODE_PORT"$i" \
--keyring-backend test --mode validator --home "$DATA_DIR$i" \ --rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--json-rpc.address=$IP_ADDR:$RPC_PORT"$i" \
--json-rpc.api="eth,txpool,personal,net,debug,web3" \
--keyring-backend test --mode validator --home "$DATA_DIR$i" \
--log_level debug \
>"$DATA_DIR"/node"$i".log 2>&1 & disown >"$DATA_DIR"/node"$i".log 2>&1 & disown
ETHERMINT_PID=$! CHIBACLONK_PID=$!
echo "started chibaclonk node, pid=$ETHERMINT_PID" echo "started chibaclonk node, pid=$CHIBACLONK_PID"
# add PID to array # add PID to array
arr+=("$ETHERMINT_PID") arr+=("$CHIBACLONK_PID")
if [[ $MODE == "pending" ]]; then if [[ $MODE == "pending" ]]; then
echo "waiting for the first block..." echo "waiting for the first block..."
@ -164,16 +169,15 @@ if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
TEST_FAIL=$? TEST_FAIL=$?
done done
fi fi
stop_func() { stop_func() {
ETHERMINT_PID=$i CHIBACLONK_PID=$i
echo "shutting down node, pid=$ETHERMINT_PID ..." echo "shutting down node, pid=$CHIBACLONK_PID ..."
# Shutdown ethermint node # Shutdown chibaclonk node
kill -9 "$ETHERMINT_PID" kill -9 "$CHIBACLONK_PID"
wait "$ETHERMINT_PID" wait "$CHIBACLONK_PID"
if [ $REMOVE_DATA_DIR == "true" ] if [ $REMOVE_DATA_DIR == "true" ]
then then