laconicd/scripts/integration-test-all.sh

193 lines
6.6 KiB
Bash
Raw Normal View History

#!/bin/bash
# "stable" mode tests assume data is static
# "live" mode tests assume data dynamic
SCRIPT=$(basename ${BASH_SOURCE[0]})
TEST=""
QTD=1
SLEEP_TIMEOUT=5
TEST_QTD=1
2021-04-17 10:00:07 +00:00
## remove test data dir after
REMOVE_DATA_DIR=false
#PORT AND RPC_PORT 3 initial digits, to be concat with a suffix later when node is initialized
RPC_PORT="854"
IP_ADDR="0.0.0.0"
KEY="mykey"
CHAINID="ethermint_9000-1"
MONIKER="mymoniker"
2020-08-05 15:17:50 +00:00
## default port prefixes for ethermintd
NODE_P2P_PORT="2660"
NODE_PORT="2663"
NODE_RPC_PORT="2666"
usage() {
echo "Usage: $SCRIPT"
echo "Optional command line arguments"
echo "-t <string> -- Test to run. eg: rpc"
echo "-q <number> -- Quantity of nodes to run. eg: 3"
echo "-z <number> -- Quantity of nodes to run tests against eg: 3"
echo "-s <number> -- Sleep between operations in secs. eg: 5"
2022-05-12 12:26:04 +00:00
echo "-m <string> -- Mode for testing. eg: rpc"
2021-04-17 10:00:07 +00:00
echo "-r <string> -- Remove test dir after, eg: true, default is false"
exit 1
}
2021-04-17 10:00:07 +00:00
while getopts "h?t:q:z:s:m:r:" args; do
case $args in
h|\?)
usage;
exit;;
t ) TEST=${OPTARG};;
q ) QTD=${OPTARG};;
z ) TEST_QTD=${OPTARG};;
s ) SLEEP_TIMEOUT=${OPTARG};;
Pending (#571) * add PendingBlockNumber -1 * increase block times * update bn * get pending balance * additional logic to check for pending state * add multiple balance query * pending state for getTransactionCount * fix lint * add getBlockTransactionCountByNumber code - commented * cleanup test * GetBlockTransactionCountByNumber * cleanup * getBlockByNumber * GetTransactionByBlockNumberAndIndex * conform to namespace changes * exportable FormatBlock method * eth_getTransactionByHash * eth_getTransactionByBlockNumberAndIndex * pending nonce * set nonce for pending and check for invalid * WIP: doCall * add pending tx test * cleanup + refactor * push first tests and init pending * pending changes (#600) * cleanup * updates * more fixes * lint * update call and send * comments and minor changes * add pending tests into sep package * fix latest case for eth_GetBlockTransactionCountByNumber * fix repeating null transactions in queue * remove repeated structs * latestblock case * revert init script back * fix to exportable method * automate pending tests; add make cmd * move and comment out pending call test * fix some golint * fix unlock issue * wip: linter stringer fix? * stringer lint * set arr instead of append * instantiate with length * sep if statement * edit pendingblocknumber note * switch statement * fix and update tests * move tests-pending into tests dir * remove commented test * revert to appending pendingtx * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * require no err * rename var * check result for eth_sendTransaction * update changelog * update * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/tests-pending/rpc_pending_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * changelog * remove redundant check Co-authored-by: noot <elizabethjbinks@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-12-15 19:52:09 +00:00
m ) MODE=${OPTARG};;
2021-04-17 10:00:07 +00:00
r ) REMOVE_DATA_DIR=${OPTARG};;
esac
done
set -euxo pipefail
DATA_DIR=$(mktemp -d -t ethermint-datadir.XXXXX)
if [[ ! "$DATA_DIR" ]]; then
echo "Could not create $DATA_DIR"
exit 1
fi
2022-04-26 14:37:50 +00:00
# Compile chibaclonk
echo "compiling chibaclonk"
make build
# PID array declaration
arr=()
init_func() {
"$PWD"/build/chibaclonkd keys add $KEY"$i" --keyring-backend test --home "$DATA_DIR$i" --no-backup --algo "eth_secp256k1"
"$PWD"/build/chibaclonkd init $MONIKER --chain-id $CHAINID --home "$DATA_DIR$i"
"$PWD"/build/chibaclonkd add-genesis-account \
"$("$PWD"/build/chibaclonkd keys show "$KEY$i" --keyring-backend test -a --home "$DATA_DIR$i")" 1000000000000000000aphoton,1000000000000000000stake \
2021-04-17 10:00:07 +00:00
--keyring-backend test --home "$DATA_DIR$i"
"$PWD"/build/chibaclonkd gentx "$KEY$i" 1000000000000000000stake --chain-id $CHAINID --keyring-backend test --home "$DATA_DIR$i"
"$PWD"/build/chibaclonkd collect-gentxs --home "$DATA_DIR$i"
"$PWD"/build/chibaclonkd validate-genesis --home "$DATA_DIR$i"
Pending (#571) * add PendingBlockNumber -1 * increase block times * update bn * get pending balance * additional logic to check for pending state * add multiple balance query * pending state for getTransactionCount * fix lint * add getBlockTransactionCountByNumber code - commented * cleanup test * GetBlockTransactionCountByNumber * cleanup * getBlockByNumber * GetTransactionByBlockNumberAndIndex * conform to namespace changes * exportable FormatBlock method * eth_getTransactionByHash * eth_getTransactionByBlockNumberAndIndex * pending nonce * set nonce for pending and check for invalid * WIP: doCall * add pending tx test * cleanup + refactor * push first tests and init pending * pending changes (#600) * cleanup * updates * more fixes * lint * update call and send * comments and minor changes * add pending tests into sep package * fix latest case for eth_GetBlockTransactionCountByNumber * fix repeating null transactions in queue * remove repeated structs * latestblock case * revert init script back * fix to exportable method * automate pending tests; add make cmd * move and comment out pending call test * fix some golint * fix unlock issue * wip: linter stringer fix? * stringer lint * set arr instead of append * instantiate with length * sep if statement * edit pendingblocknumber note * switch statement * fix and update tests * move tests-pending into tests dir * remove commented test * revert to appending pendingtx * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * require no err * rename var * check result for eth_sendTransaction * update changelog * update * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/tests-pending/rpc_pending_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * changelog * remove redundant check Co-authored-by: noot <elizabethjbinks@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-12-15 19:52:09 +00:00
if [[ $MODE == "pending" ]]; then
2021-04-17 10:00:07 +00:00
ls $DATA_DIR$i
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "2s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "120s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "2s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "2s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $DATA_DIR$i/config/config.toml
sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $DATA_DIR$i/config/config.toml
else
sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $DATA_DIR$i/config/config.toml
Pending (#571) * add PendingBlockNumber -1 * increase block times * update bn * get pending balance * additional logic to check for pending state * add multiple balance query * pending state for getTransactionCount * fix lint * add getBlockTransactionCountByNumber code - commented * cleanup test * GetBlockTransactionCountByNumber * cleanup * getBlockByNumber * GetTransactionByBlockNumberAndIndex * conform to namespace changes * exportable FormatBlock method * eth_getTransactionByHash * eth_getTransactionByBlockNumberAndIndex * pending nonce * set nonce for pending and check for invalid * WIP: doCall * add pending tx test * cleanup + refactor * push first tests and init pending * pending changes (#600) * cleanup * updates * more fixes * lint * update call and send * comments and minor changes * add pending tests into sep package * fix latest case for eth_GetBlockTransactionCountByNumber * fix repeating null transactions in queue * remove repeated structs * latestblock case * revert init script back * fix to exportable method * automate pending tests; add make cmd * move and comment out pending call test * fix some golint * fix unlock issue * wip: linter stringer fix? * stringer lint * set arr instead of append * instantiate with length * sep if statement * edit pendingblocknumber note * switch statement * fix and update tests * move tests-pending into tests dir * remove commented test * revert to appending pendingtx * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * require no err * rename var * check result for eth_sendTransaction * update changelog * update * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/tests-pending/rpc_pending_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * changelog * remove redundant check Co-authored-by: noot <elizabethjbinks@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-12-15 19:52:09 +00:00
sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $DATA_DIR$i/config/config.toml
sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "2s"/g' $DATA_DIR$i/config/config.toml
sed -i 's/timeout_prevote = "1s"/timeout_prevote = "120s"/g' $DATA_DIR$i/config/config.toml
sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "2s"/g' $DATA_DIR$i/config/config.toml
sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $DATA_DIR$i/config/config.toml
sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "2s"/g' $DATA_DIR$i/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $DATA_DIR$i/config/config.toml
2021-04-17 10:00:07 +00:00
sed -i 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $DATA_DIR$i/config/config.toml
fi
Pending (#571) * add PendingBlockNumber -1 * increase block times * update bn * get pending balance * additional logic to check for pending state * add multiple balance query * pending state for getTransactionCount * fix lint * add getBlockTransactionCountByNumber code - commented * cleanup test * GetBlockTransactionCountByNumber * cleanup * getBlockByNumber * GetTransactionByBlockNumberAndIndex * conform to namespace changes * exportable FormatBlock method * eth_getTransactionByHash * eth_getTransactionByBlockNumberAndIndex * pending nonce * set nonce for pending and check for invalid * WIP: doCall * add pending tx test * cleanup + refactor * push first tests and init pending * pending changes (#600) * cleanup * updates * more fixes * lint * update call and send * comments and minor changes * add pending tests into sep package * fix latest case for eth_GetBlockTransactionCountByNumber * fix repeating null transactions in queue * remove repeated structs * latestblock case * revert init script back * fix to exportable method * automate pending tests; add make cmd * move and comment out pending call test * fix some golint * fix unlock issue * wip: linter stringer fix? * stringer lint * set arr instead of append * instantiate with length * sep if statement * edit pendingblocknumber note * switch statement * fix and update tests * move tests-pending into tests dir * remove commented test * revert to appending pendingtx * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * require no err * rename var * check result for eth_sendTransaction * update changelog * update * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/tests-pending/rpc_pending_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * changelog * remove redundant check Co-authored-by: noot <elizabethjbinks@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-12-15 19:52:09 +00:00
fi
}
start_func() {
2022-04-26 14:37:50 +00:00
echo "starting chibaclonk node $i in background ..."
"$PWD"/build/chibaclonkd start --pruning=nothing --rpc.unsafe \
--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" \
--json-rpc.address=$IP_ADDR:$RPC_PORT"$i" \
--json-rpc.api="eth,txpool,personal,net,debug,web3" \
2022-04-26 14:37:50 +00:00
--keyring-backend test --mode validator --home "$DATA_DIR$i" \
>"$DATA_DIR"/node"$i".log 2>&1 & disown
2021-04-17 10:00:07 +00:00
ETHERMINT_PID=$!
2022-04-26 14:37:50 +00:00
echo "started chibaclonk node, pid=$ETHERMINT_PID"
# add PID to array
arr+=("$ETHERMINT_PID")
2021-04-17 10:00:07 +00:00
if [[ $MODE == "pending" ]]; then
echo "waiting for the first block..."
sleep 300
fi
}
# Run node with static blockchain database
# For loop N times
for i in $(seq 1 "$QTD"); do
init_func "$i"
start_func "$i"
sleep 1
echo "sleeping $SLEEP_TIMEOUT seconds for startup"
sleep "$SLEEP_TIMEOUT"
echo "done sleeping"
done
echo "sleeping $SLEEP_TIMEOUT seconds before running tests ... "
sleep "$SLEEP_TIMEOUT"
echo "done sleeping"
set +e
if [[ -z $TEST || $TEST == "integration" ]] ; then
time_out=300s
2021-04-17 10:00:07 +00:00
for i in $(seq 1 "$TEST_QTD"); do
HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i"
2022-04-28 07:43:39 +00:00
echo "going to test chibaclonk node $HOST_RPC ..."
MODE=$MODE HOST=$HOST_RPC go test ./tests/e2e/... -timeout=$time_out -v -short
TEST_FAIL=$?
done
fi
if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
2021-04-17 10:00:07 +00:00
time_out=300s
if [[ $TEST == "pending" ]]; then
time_out=60m0s
fi
Pending (#571) * add PendingBlockNumber -1 * increase block times * update bn * get pending balance * additional logic to check for pending state * add multiple balance query * pending state for getTransactionCount * fix lint * add getBlockTransactionCountByNumber code - commented * cleanup test * GetBlockTransactionCountByNumber * cleanup * getBlockByNumber * GetTransactionByBlockNumberAndIndex * conform to namespace changes * exportable FormatBlock method * eth_getTransactionByHash * eth_getTransactionByBlockNumberAndIndex * pending nonce * set nonce for pending and check for invalid * WIP: doCall * add pending tx test * cleanup + refactor * push first tests and init pending * pending changes (#600) * cleanup * updates * more fixes * lint * update call and send * comments and minor changes * add pending tests into sep package * fix latest case for eth_GetBlockTransactionCountByNumber * fix repeating null transactions in queue * remove repeated structs * latestblock case * revert init script back * fix to exportable method * automate pending tests; add make cmd * move and comment out pending call test * fix some golint * fix unlock issue * wip: linter stringer fix? * stringer lint * set arr instead of append * instantiate with length * sep if statement * edit pendingblocknumber note * switch statement * fix and update tests * move tests-pending into tests dir * remove commented test * revert to appending pendingtx * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * require no err * rename var * check result for eth_sendTransaction * update changelog * update * Update tests/utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update tests/tests-pending/rpc_pending_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * changelog * remove redundant check Co-authored-by: noot <elizabethjbinks@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-12-15 19:52:09 +00:00
for i in $(seq 1 "$TEST_QTD"); do
HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i"
2022-04-28 07:43:39 +00:00
echo "going to test chibaclonk node $HOST_RPC ..."
MODE=$MODE HOST=$HOST_RPC go test ./tests/rpc/... -timeout=$time_out -v -short
2021-04-17 10:00:07 +00:00
TEST_FAIL=$?
done
2021-04-17 10:00:07 +00:00
fi
stop_func() {
ETHERMINT_PID=$i
echo "shutting down node, pid=$ETHERMINT_PID ..."
2021-04-17 10:00:07 +00:00
# Shutdown ethermint node
kill -9 "$ETHERMINT_PID"
wait "$ETHERMINT_PID"
2021-04-17 10:00:07 +00:00
if [ $REMOVE_DATA_DIR == "true" ]
then
rm -rf $DATA_DIR*
fi
}
for i in "${arr[@]}"; do
stop_func "$i"
done
if [[ (-z $TEST || $TEST == "rpc" || $TEST == "integration" ) && $TEST_FAIL -ne 0 ]]; then
exit $TEST_FAIL
else
exit 0
fi