From fc014abbc85e63193eb70e76d3cbab37b5bc49fe Mon Sep 17 00:00:00 2001 From: tj327 Date: Thu, 23 Nov 2023 09:47:21 -0500 Subject: [PATCH] modify transactions integration test --- .../query-block-by-height-or-hash.sh | 6 ++-- .../Transactions/query-block-transactions.sh | 3 +- .../test-local/Transactions/query-blocks.sh | 3 +- .../Transactions/query-transaction-result.sh | 3 +- .../Transactions/query-transactions.sh | 6 ++-- .../Transactions/transaction-hash.sh | 5 ++-- scripts/test-local/init-localnet.sh | 29 +++++++++++++++++++ 7 files changed, 46 insertions(+), 9 deletions(-) create mode 100755 scripts/test-local/init-localnet.sh diff --git a/scripts/test-local/Transactions/query-block-by-height-or-hash.sh b/scripts/test-local/Transactions/query-block-by-height-or-hash.sh index a61abe2..843ebc1 100755 --- a/scripts/test-local/Transactions/query-block-by-height-or-hash.sh +++ b/scripts/test-local/Transactions/query-block-by-height-or-hash.sh @@ -12,9 +12,11 @@ addAccount testuser2 TESTUSER_ADDRESS=$(showAddress testuser2) TXRESULT=$(sekaid tx bank send validator $TESTUSER_ADDRESS 5ukex --keyring-backend=test --chain-id=$NETWORK_NAME --fees 100ukex --broadcast-mode=async --output=json --yes --home=$SEKAID_HOME 2> /dev/null || exit 1) -BLOCK_HASH=$(echo $TXRESULT | jsonQuickParse "txhash") -TXQUERYRESULT=$(sekaid query tx $TX_ID 2> /dev/null || exit 1) +TX_HASH=$(echo $TXRESULT | jsonQuickParse "txhash") +sleep 5 +TXQUERYRESULT=$(sekaid query tx $TX_HASH --chain-id=$NETWORK_NAME --output=json --home=$SEKAID_HOME 2> /dev/null || exit 1) BLOCK_HEIGHT=$(echo $TXQUERYRESULT | jsonQuickParse "height") +BLOCK_HASH=$(sekaid query block $BLOCK_HEIGHT --chain-id=$NETWORK_NAME --home=$SEKAID_HOME | jq '.block_id.hash' | tr -d '"') INTERX_GATEWAY="127.0.0.1:11000" RESULT_HASH_FROM_INTERX=$(curl --fail $INTERX_GATEWAY/api/blocks/$BLOCK_HEIGHT | jq '.block_id.hash' | tr -d '"' || exit 1) diff --git a/scripts/test-local/Transactions/query-block-transactions.sh b/scripts/test-local/Transactions/query-block-transactions.sh index 8b2fa7b..30321b3 100755 --- a/scripts/test-local/Transactions/query-block-transactions.sh +++ b/scripts/test-local/Transactions/query-block-transactions.sh @@ -13,7 +13,8 @@ TESTUSER_ADDRESS=$(showAddress testuser3) TXRESULT=$(sekaid tx bank send validator $TESTUSER_ADDRESS 5ukex --keyring-backend=test --chain-id=$NETWORK_NAME --fees 100ukex --broadcast-mode=async --output=json --yes --home=$SEKAID_HOME 2> /dev/null || exit 1) TX_HASH=$(echo $TXRESULT | jsonQuickParse "txhash") -TXQUERYRESULT=$(sekaid query tx $TX_ID 2> /dev/null || exit 1) +sleep 5 +TXQUERYRESULT=$(sekaid query tx $TX_HASH --chain-id=$NETWORK_NAME --output=json --home=$SEKAID_HOME 2> /dev/null || exit 1) BLOCK_HEIGHT=$(echo $TXQUERYRESULT | jsonQuickParse "height") INTERX_GATEWAY="127.0.0.1:11000" diff --git a/scripts/test-local/Transactions/query-blocks.sh b/scripts/test-local/Transactions/query-blocks.sh index 316068b..52a9530 100755 --- a/scripts/test-local/Transactions/query-blocks.sh +++ b/scripts/test-local/Transactions/query-blocks.sh @@ -13,7 +13,8 @@ TESTUSER_ADDRESS=$(showAddress testuser4) TXRESULT=$(sekaid tx bank send validator $TESTUSER_ADDRESS 5ukex --keyring-backend=test --chain-id=$NETWORK_NAME --fees 100ukex --broadcast-mode=async --output=json --yes --home=$SEKAID_HOME 2> /dev/null || exit 1) TX_ID=$(echo $TXRESULT | jsonQuickParse "txhash") -TXQUERYRESULT=$(sekaid query tx $TX_ID 2> /dev/null || exit 1) +sleep 5 +TXQUERYRESULT=$(sekaid query tx $TX_ID --chain-id=$NETWORK_NAME --output=json --home=$SEKAID_HOME 2> /dev/null || exit 1) BLOCK_HEIGHT=$(echo $TXQUERYRESULT | jsonQuickParse "height") INTERX_GATEWAY="127.0.0.1:11000" diff --git a/scripts/test-local/Transactions/query-transaction-result.sh b/scripts/test-local/Transactions/query-transaction-result.sh index a799d22..8d51782 100755 --- a/scripts/test-local/Transactions/query-transaction-result.sh +++ b/scripts/test-local/Transactions/query-transaction-result.sh @@ -12,7 +12,8 @@ addAccount testuser5 TESTUSER_ADDRESS=$(showAddress testuser5) RESULT=$(sekaid tx bank send validator $TESTUSER_ADDRESS 5ukex --keyring-backend=test --chain-id=$NETWORK_NAME --fees 100ukex --broadcast-mode=async --output=json --yes --home=$SEKAID_HOME 2> /dev/null || exit 1) -TX_HASH=$(echo $RESULT | jsonQuickParse "txhash" | tr -d '"') +TX_HASH=$(echo $RESULT | jsonQuickParse "txhash") +sleep 5 INTERX_GATEWAY="127.0.0.1:11000" RESULT_FROM_INTERX=$(curl --fail $INTERX_GATEWAY/api/transactions/0x$TX_HASH || exit 1) diff --git a/scripts/test-local/Transactions/query-transactions.sh b/scripts/test-local/Transactions/query-transactions.sh index b9fc75c..2ec590b 100755 --- a/scripts/test-local/Transactions/query-transactions.sh +++ b/scripts/test-local/Transactions/query-transactions.sh @@ -11,10 +11,12 @@ VALIDATOR_ADDRESS=$(showAddress validator) addAccount testuser9 TESTUSER_ADDRESS=$(showAddress testuser9) RESULT=$(sekaid tx bank send validator $TESTUSER_ADDRESS 5ukex --keyring-backend=test --chain-id=$NETWORK_NAME --fees 100ukex --broadcast-mode=async --output=json --yes --home=$SEKAID_HOME 2> /dev/null || exit 1) -TX_HASH=0x$(echo $RESULT | jsonQuickParse "txhash" | tr -d '"') +TX_HASH=0x$(echo $RESULT | jsonQuickParse "txhash") + +sleep 5 INTERX_GATEWAY="127.0.0.1:11000" -RESULT_FROM_INTERX=$(curl --fail $INTERX_GATEWAY/api/transactions?address=$TESTUSER_ADDRESS&type=send || exit 1) +RESULT_FROM_INTERX=$(curl --fail "$INTERX_GATEWAY/api/transactions?address=$TESTUSER_ADDRESS&type=send" || exit 1) RESULT_TOTAL_COUNT=$(echo $RESULT_FROM_INTERX | jq '.total_count' | tr -d '"') RESULT_TX_HASH=$(echo $RESULT_FROM_INTERX | jq '.transactions[0].hash' | tr -d '"') diff --git a/scripts/test-local/Transactions/transaction-hash.sh b/scripts/test-local/Transactions/transaction-hash.sh index 2d8e7b6..1a94d13 100755 --- a/scripts/test-local/Transactions/transaction-hash.sh +++ b/scripts/test-local/Transactions/transaction-hash.sh @@ -12,8 +12,9 @@ addAccount testuser8 TESTUSER_ADDRESS=$(showAddress testuser8) TXRESULT=$(sekaid tx bank send validator $TESTUSER_ADDRESS 5ukex --keyring-backend=test --chain-id=$NETWORK_NAME --fees 100ukex --broadcast-mode=async --output=json --yes --home=$SEKAID_HOME 2> /dev/null || exit 1) -TX_HASH=$(echo $TXRESULT | jsonQuickParse "txhash") -TXQUERYRESULT=$(sekaid query tx $TX_ID 2> /dev/null || exit 1) +TX_ID=$(echo $TXRESULT | jsonQuickParse "txhash") +sleep 5 +TXQUERYRESULT=$(sekaid query tx $TX_ID --chain-id=$NETWORK_NAME --output=json --home=$SEKAID_HOME 2> /dev/null || exit 1) BLOCK_HEIGHT=$(echo $TXQUERYRESULT | jsonQuickParse "height") echo $TX_ID echo $BLOCK_HEIGHT diff --git a/scripts/test-local/init-localnet.sh b/scripts/test-local/init-localnet.sh new file mode 100755 index 0000000..8ed0316 --- /dev/null +++ b/scripts/test-local/init-localnet.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# To run test locally: make network-start && ./scripts/test-local/token-transfers.sh +set -e +set -x +. /etc/profile + +INTERX_VERSION=$(./scripts/version.sh InterxVersion) +SEKAID_VERSION=$(./scripts/version.sh SekaiVersion) +DEFAULT_GRPC_PORT=9090 +DEFAULT_RPC_PORT=26657 +DEFAULT_INTERX_PORT=11000 +PING_TARGET="127.0.0.1" +CFG_grpc="dns:///$PING_TARGET:$DEFAULT_GRPC_PORT" +CFG_rpc="http://$PING_TARGET:$DEFAULT_RPC_PORT" +INTERXD_HOME=$HOME/.interxd + +interxd init --cache_dir="$INTERXD_HOME/cache" --home="$INTERXD_HOME" --grpc="$CFG_grpc" --rpc="$CFG_rpc" --port="$INTERNAL_API_PORT" \ + --signing_mnemonic="$INTERXD_HOME/interx.mnemonic" \ + --faucet_mnemonic="$INTERXD_HOME/faucet.mnemonic" \ + --port="$DEFAULT_INTERX_PORT" \ + --node_type="validator" \ + --seed_node_id="" \ + --sentry_node_id="" \ + --validator_node_id="$(globGet validator_node_id)" \ + --addrbook="$(globFile KIRA_ADDRBOOK)" \ + --faucet_time_limit=30 \ + --faucet_amounts="100000ukex,20000000test,300000000000000000samolean,1lol" \ + --faucet_minimum_amounts="1000ukex,50000test,250000000000000samolean,1lol" \ + --fee_amounts="ukex 1000ukex,test 500ukex,samolean 250ukex,lol 100ukex"