tests: fix script (#43)

This commit is contained in:
Thomas Nguy 2021-05-25 17:46:10 +09:00 committed by GitHub
parent 596373dc9d
commit bd89830d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 36 deletions

View File

@ -442,13 +442,13 @@ ifeq ($(OS),Windows_NT)
mkdir build & mkdir build &
@$(MAKE) docker-localnet @$(MAKE) docker-localnet
IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd testnet --v 4 -o /ethermint --starting-ip-address 192.168.10.2 --keyring-backend=test" IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd testnet --v 4 -o /ethermint --keyring-backend=test"
docker-compose up -d docker-compose up -d
else else
mkdir -p ./build/ mkdir -p ./build/
@$(MAKE) docker-localnet @$(MAKE) docker-localnet
if ! [ -f build/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd testnet --v 4 -o /ethermint --starting-ip-address 192.168.10.2 --keyring-backend=test"; fi if ! [ -f build/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd testnet --v 4 -o /ethermint --keyring-backend=test"; fi
docker-compose up -d docker-compose up -d
endif endif

View File

@ -35,7 +35,7 @@ cat $HOME/.ethermint/config/genesis.json | jq '.app_state["mint"]["params"]["min
"$PWD"/build/ethermintd validate-genesis "$PWD"/build/ethermintd validate-genesis
# Start the node (remove the --pruning=nothing flag if historical queries are not needed) in background and log to file # Start the node (remove the --pruning=nothing flag if historical queries are not needed) in background and log to file
"$PWD"/build/ethermintd start --pruning=nothing --rpc.unsafe --rpc-api "web3, eth, personal, net" --keyring-backend test > ethermintd.log 2>&1 & "$PWD"/build/ethermintd start --pruning=nothing --rpc.unsafe --evm-rpc.address="0.0.0.0:8545" --keyring-backend test > ethermintd.log 2>&1 &
# Give ethermintd node enough time to launch # Give ethermintd node enough time to launch
sleep 5 sleep 5
@ -48,8 +48,8 @@ mv "$PWD"/tests/solidity/suites/basic/counter/*.bin "$PWD"/tests/solidity/suites
ACCT=$(curl --fail --silent -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 | grep -o '\0x[^"]*') ACCT=$(curl --fail --silent -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 | grep -o '\0x[^"]*')
echo "$ACCT" echo "$ACCT"
# Start testcases # Start testcases (not supported)
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$ACCT'", ""],"id":1}' -H "Content-Type: application/json" http://localhost:8545 # curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$ACCT'", ""],"id":1}' -H "Content-Type: application/json" http://localhost:8545
#PRIVKEY="$("$PWD"/build/ethermintd keys export $KEY)" #PRIVKEY="$("$PWD"/build/ethermintd keys export $KEY)"

View File

@ -72,7 +72,7 @@ init_func() {
"$PWD"/build/ethermintd add-genesis-account \ "$PWD"/build/ethermintd add-genesis-account \
"$("$PWD"/build/ethermintd keys show "$KEY$i" --keyring-backend test -a --home "$DATA_DIR$i")" 1000000000000000000aphoton,1000000000000000000stake \ "$("$PWD"/build/ethermintd keys show "$KEY$i" --keyring-backend test -a --home "$DATA_DIR$i")" 1000000000000000000aphoton,1000000000000000000stake \
--keyring-backend test --home "$DATA_DIR$i" --keyring-backend test --home "$DATA_DIR$i"
"$PWD"/build/ethermintd gentx "$KEY$i" --amount=1000000000000000000aphoton --chain-id $CHAINID --keyring-backend test --home "$DATA_DIR$i" "$PWD"/build/ethermintd gentx "$KEY$i" 1000000000000000000stake --chain-id $CHAINID --keyring-backend test --home "$DATA_DIR$i"
"$PWD"/build/ethermintd collect-gentxs --home "$DATA_DIR$i" "$PWD"/build/ethermintd collect-gentxs --home "$DATA_DIR$i"
"$PWD"/build/ethermintd validate-genesis --home "$DATA_DIR$i" "$PWD"/build/ethermintd validate-genesis --home "$DATA_DIR$i"
@ -106,9 +106,8 @@ start_func() {
echo "starting ethermint node $i in background ..." echo "starting ethermint node $i in background ..."
"$PWD"/build/ethermintd start --pruning=nothing --rpc.unsafe \ "$PWD"/build/ethermintd 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" \ --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 http://$IP_ADDR:$RPC_PORT"$i" \ --evm-rpc.address $IP_ADDR:$RPC_PORT"$i" \
--keyring-backend test --home "$DATA_DIR$i" \ --keyring-backend test --home "$DATA_DIR$i" \
--rpc-api "web3, eth, personal, net" \
>"$DATA_DIR"/node"$i".log 2>&1 & disown >"$DATA_DIR"/node"$i".log 2>&1 & disown
ETHERMINT_PID=$! ETHERMINT_PID=$!

34
scripts/start.sh Normal file → Executable file
View File

@ -10,7 +10,7 @@ SLEEP_TIMEOUT=5
TEST_QTD=1 TEST_QTD=1
#PORT AND RPC_PORT 3 initial digits, to be concat with a suffix later when node is initialized #PORT AND RPC_PORT 3 initial digits, to be concat with a suffix later when node is initialized
RPC_PORT="8545" RPC_PORT="854"
IP_ADDR="0.0.0.0" IP_ADDR="0.0.0.0"
MODE="rpc" MODE="rpc"
@ -73,21 +73,15 @@ arrcli=()
init_func() { init_func() {
echo "create and add new keys" echo "create and add new keys"
"$PWD"/build/ethermintd config keyring-backend test --home "$DATA_CLI_DIR$i" "$PWD"/build/ethermintd keys add $KEY"$i" --home "$DATA_DIR$i" --no-backup --chain-id $CHAINID --algo "eth_secp256k1" --keyring-backend test
"$PWD"/build/ethermintd keys add $KEY"$i" --home "$DATA_CLI_DIR$i" --no-backup --chain-id $CHAINID --algo "eth_secp256k1"
echo "init Ethermint with moniker=$MONIKER and chain-id=$CHAINID" echo "init Ethermint with moniker=$MONIKER and chain-id=$CHAINID"
"$PWD"/build/ethermintd init $MONIKER --chain-id $CHAINID --home "$DATA_DIR$i" "$PWD"/build/ethermintd init $MONIKER --chain-id $CHAINID --home "$DATA_DIR$i"
echo "init ethermintd with chain-id=$CHAINID and config it trust-node true"
"$PWD"/build/ethermintd config chain-id $CHAINID --home "$DATA_CLI_DIR$i"
"$PWD"/build/ethermintd config output json --home "$DATA_CLI_DIR$i"
"$PWD"/build/ethermintd config indent true --home "$DATA_CLI_DIR$i"
"$PWD"/build/ethermintd config trust-node true --home "$DATA_CLI_DIR$i"
echo "prepare genesis: Allocate genesis accounts" echo "prepare genesis: Allocate genesis accounts"
"$PWD"/build/ethermintd add-genesis-account \ "$PWD"/build/ethermintd add-genesis-account \
"$("$PWD"/build/ethermintd keys show "$KEY$i" -a --home "$DATA_CLI_DIR$i" )" 1000000000000000000aphoton,1000000000000000000stake \ "$("$PWD"/build/ethermintd keys show "$KEY$i" -a --home "$DATA_DIR$i" --keyring-backend test)" 1000000000000000000aphoton,1000000000000000000stake \
--home "$DATA_DIR$i" --home-client "$DATA_CLI_DIR$i" --home "$DATA_DIR$i" --keyring-backend test
echo "prepare genesis: Sign genesis transaction" echo "prepare genesis: Sign genesis transaction"
"$PWD"/build/ethermintd gentx --name $KEY"$i" --keyring-backend test --home "$DATA_DIR$i" --home-client "$DATA_CLI_DIR$i" "$PWD"/build/ethermintd gentx $KEY"$i" 1000000000000000000stake --keyring-backend test --home "$DATA_DIR$i" --keyring-backend test --chain-id $CHAINID
echo "prepare genesis: Collect genesis tx" echo "prepare genesis: Collect genesis tx"
"$PWD"/build/ethermintd collect-gentxs --home "$DATA_DIR$i" "$PWD"/build/ethermintd collect-gentxs --home "$DATA_DIR$i"
echo "prepare genesis: Run validate-genesis to ensure everything worked and that the genesis file is setup correctly" echo "prepare genesis: Run validate-genesis to ensure everything worked and that the genesis file is setup correctly"
@ -98,7 +92,8 @@ start_func() {
echo "starting ethermint node $i in background ..." echo "starting ethermint node $i in background ..."
"$PWD"/build/ethermintd start --pruning=nothing --rpc.unsafe \ "$PWD"/build/ethermintd 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" \ --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" \
--home "$DATA_DIR$i" \ --evm-rpc.address $IP_ADDR:$RPC_PORT"$i" \
--keyring-backend test --home "$DATA_DIR$i" \
>"$DATA_DIR"/node"$i".log 2>&1 & disown >"$DATA_DIR"/node"$i".log 2>&1 & disown
ETHERMINT_PID=$! ETHERMINT_PID=$!
@ -107,27 +102,12 @@ start_func() {
arr+=("$ETHERMINT_PID") arr+=("$ETHERMINT_PID")
} }
start_cli_func() {
echo "starting ethermint node $i in background ..."
"$PWD"/build/ethermintd rest-server --unlock-key $KEY"$i" --chain-id $CHAINID --trace \
--laddr "tcp://localhost:$RPC_PORT$i" --node tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--home "$DATA_CLI_DIR$i" --read-timeout 30 --write-timeout 30 \
--rpc-api "web3, eth, personal, net" \
>"$DATA_CLI_DIR"/cli"$i".log 2>&1 & disown
ETHERMINT_CLI_PID=$!
echo "started ethermintd node, pid=$ETHERMINT_CLI_PID"
# add PID to array
arrcli+=("$ETHERMINT_CLI_PID")
}
# Run node with static blockchain database # Run node with static blockchain database
# For loop N times # For loop N times
for i in $(seq 1 "$QTD"); do for i in $(seq 1 "$QTD"); do
init_func "$i" init_func "$i"
start_func "$i" start_func "$i"
sleep 1 sleep 1
start_cli_func "$i"
echo "sleeping $SLEEP_TIMEOUT seconds for startup" echo "sleeping $SLEEP_TIMEOUT seconds for startup"
sleep "$SLEEP_TIMEOUT" sleep "$SLEEP_TIMEOUT"
echo "done sleeping" echo "done sleeping"

View File

@ -40,4 +40,4 @@ ethermintd collect-gentxs
ethermintd validate-genesis ethermintd validate-genesis
# Start the node (remove the --pruning=nothing flag if historical queries are not needed) # Start the node (remove the --pruning=nothing flag if historical queries are not needed)
ethermintd start --pruning=nothing --rpc.unsafe --rpc-api "web3, eth, personal, net" --keyring-backend test --trace --log_level "info" ethermintd start --pruning=nothing --rpc.unsafe --evm-rpc.address "0.0.0.0:8545" --keyring-backend test --trace --log_level "info"