From 814ef37f752bc81ce7cf630c363ef12bd3a979a2 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 12 Jan 2017 10:58:44 -0500 Subject: [PATCH] fix tests --- consensus/replay_test.go | 6 ++++++ rpc/core/mempool.go | 2 +- test/app/clean.sh | 1 + test/app/counter_test.sh | 2 +- test/app/dummy_test.sh | 16 +++++++++++----- test/p2p/atomic_broadcast/test.sh | 4 ++-- test/persist/test_failure_indices.sh | 2 +- test/persist/test_simple.sh | 2 +- 8 files changed, 24 insertions(+), 11 deletions(-) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 2d3d131dd..823b74a89 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -9,11 +9,17 @@ import ( "testing" "time" + "github.com/tendermint/tendermint/config/tendermint_test" + . "github.com/tendermint/go-common" "github.com/tendermint/go-wire" "github.com/tendermint/tendermint/types" ) +func init() { + config = tendermint_test.ResetConfig("consensus_replay_test") +} + // TODO: these tests ensure we can always recover from any state of the wal, // assuming it comes with a correct related state for the priv_validator.json. // It would be better to verify explicitly which states we can recover from without the wal diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 3ce9d32c6..a15fe0ccc 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -82,7 +82,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { Data: appendTxRes.Data, Log: appendTxRes.Log, } - log.Error("appendtx passed ", "r", appendTxR) + log.Notice("AppendTx passed ", "tx", []byte(tx), "response", appendTxR) return &ctypes.ResultBroadcastTxCommit{ CheckTx: checkTxR, AppendTx: appendTxR, diff --git a/test/app/clean.sh b/test/app/clean.sh index 1b34033f2..8c5562239 100644 --- a/test/app/clean.sh +++ b/test/app/clean.sh @@ -1,3 +1,4 @@ killall tendermint killall dummy killall counter +rm -rf ~/.tendermint_app diff --git a/test/app/counter_test.sh b/test/app/counter_test.sh index 24f4fb618..37f65b90e 100644 --- a/test/app/counter_test.sh +++ b/test/app/counter_test.sh @@ -29,7 +29,7 @@ function getCode() { function sendTx() { TX=$1 if [[ "$GRPC_BROADCAST_TX" == "" ]]; then - RESPONSE=`curl -s localhost:46657/broadcast_tx_commit?tx=\"$TX\"` + RESPONSE=`curl -s localhost:46657/broadcast_tx_commit?tx=0x$TX` ERROR=`echo $RESPONSE | jq .error` ERROR=$(echo "$ERROR" | tr -d '"') # remove surrounding quotes diff --git a/test/app/dummy_test.sh b/test/app/dummy_test.sh index c0907bd4d..58c705b48 100644 --- a/test/app/dummy_test.sh +++ b/test/app/dummy_test.sh @@ -2,7 +2,8 @@ set -e function toHex() { - echo -n $1 | hexdump -ve '1/1 "%.2X"' + echo -n $1 | hexdump -ve '1/1 "%.2X"' | awk '{print "0x" $0}' + } ##################### @@ -13,7 +14,8 @@ TESTNAME=$1 # store key value pair KEY="abcd" VALUE="dcba" -curl -s 127.0.0.1:46657/broadcast_tx_commit?tx=\"$(toHex $KEY=$VALUE)\" +echo $(toHex $KEY=$VALUE) +curl -s 127.0.0.1:46657/broadcast_tx_commit?tx=$(toHex $KEY=$VALUE) echo $? echo "" @@ -22,8 +24,10 @@ echo "" # test using the tmsp-cli ########################### +echo "... testing query with tmsp-cli" + # we should be able to look up the key -RESPONSE=`tmsp-cli query $KEY` +RESPONSE=`tmsp-cli query \"$KEY\"` set +e A=`echo $RESPONSE | grep '"exists":true'` @@ -35,7 +39,7 @@ fi set -e # we should not be able to look up the value -RESPONSE=`tmsp-cli query $VALUE` +RESPONSE=`tmsp-cli query \"$VALUE\"` set +e A=`echo $RESPONSE | grep '"exists":true'` if [[ $? == 0 ]]; then @@ -49,8 +53,10 @@ set -e # test using the /tmsp_query ############################# +echo "... testing query with /tmsp_query" + # we should be able to look up the key -RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=\"$(toHex $KEY)\"` +RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=$(toHex $KEY)` RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p` set +e diff --git a/test/p2p/atomic_broadcast/test.sh b/test/p2p/atomic_broadcast/test.sh index 3eef2d5eb..8e0633c8a 100644 --- a/test/p2p/atomic_broadcast/test.sh +++ b/test/p2p/atomic_broadcast/test.sh @@ -20,9 +20,9 @@ for i in `seq 1 $N`; do HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash` # - send a tx - TX=\"aadeadbeefbeefbeef0$i\" + TX=aadeadbeefbeefbeef0$i echo "Broadcast Tx $TX" - curl -s $addr/broadcast_tx_commit?tx=$TX + curl -s $addr/broadcast_tx_commit?tx=0x$TX echo "" # we need to wait another block to get the new app_hash diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index d6012fbec..d828afe3f 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -46,7 +46,7 @@ function send_txs(){ for i in `seq 1 5`; do for j in `seq 1 100`; do tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` - curl -s $addr/broadcast_tx_async?tx=\"$tx\" &> /dev/null + curl -s $addr/broadcast_tx_async?tx=0x$tx &> /dev/null done sleep 1 done diff --git a/test/persist/test_simple.sh b/test/persist/test_simple.sh index 1a94a0938..a483145b7 100644 --- a/test/persist/test_simple.sh +++ b/test/persist/test_simple.sh @@ -27,7 +27,7 @@ function send_txs(){ for i in `seq 1 5`; do for j in `seq 1 100`; do tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` - curl -s 127.0.0.1:46657/broadcast_tx_async?tx=\"$tx\" &> /dev/null + curl -s 127.0.0.1:46657/broadcast_tx_async?tx=0x$tx &> /dev/null done sleep 1 done