tendermint/test/app/dummy_test.sh

85 lines
1.8 KiB
Bash
Raw Normal View History

#! /bin/bash
2016-07-24 14:08:47 -04:00
set -e
function toHex() {
2017-01-12 10:58:44 -05:00
echo -n $1 | hexdump -ve '1/1 "%.2X"' | awk '{print "0x" $0}'
}
#####################
# dummy with curl
#####################
TESTNAME=$1
# store key value pair
KEY="abcd"
VALUE="dcba"
2017-01-12 10:58:44 -05:00
echo $(toHex $KEY=$VALUE)
curl -s 127.0.0.1:46657/broadcast_tx_commit?tx=$(toHex $KEY=$VALUE)
2016-07-24 14:08:47 -04:00
echo $?
echo ""
2016-09-10 17:42:12 -04:00
###########################
# test using the tmsp-cli
###########################
2017-01-12 10:58:44 -05:00
echo "... testing query with tmsp-cli"
# we should be able to look up the key
2017-01-12 10:58:44 -05:00
RESPONSE=`tmsp-cli query \"$KEY\"`
2016-07-24 14:08:47 -04:00
set +e
2016-11-22 21:50:54 -05:00
A=`echo $RESPONSE | grep '"exists":true'`
if [[ $? != 0 ]]; then
echo "Failed to find 'exists=true' for $KEY. Response:"
echo "$RESPONSE"
2016-07-24 14:08:47 -04:00
exit 1
fi
2016-07-24 14:08:47 -04:00
set -e
# we should not be able to look up the value
2017-01-12 10:58:44 -05:00
RESPONSE=`tmsp-cli query \"$VALUE\"`
2016-07-24 14:08:47 -04:00
set +e
2016-11-22 21:50:54 -05:00
A=`echo $RESPONSE | grep '"exists":true'`
if [[ $? == 0 ]]; then
echo "Found 'exists=true' for $VALUE when we should not have. Response:"
echo "$RESPONSE"
2016-07-24 14:08:47 -04:00
exit 1
fi
2016-07-24 14:08:47 -04:00
set -e
2016-09-10 17:42:12 -04:00
#############################
# test using the /tmsp_query
#############################
2017-01-12 10:58:44 -05:00
echo "... testing query with /tmsp_query"
2016-09-10 17:42:12 -04:00
# we should be able to look up the key
2017-01-12 10:58:44 -05:00
RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=$(toHex $KEY)`
2016-09-10 17:42:12 -04:00
RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p`
set +e
2016-11-22 21:50:54 -05:00
A=`echo $RESPONSE | grep '"exists":true'`
2016-09-10 17:42:12 -04:00
if [[ $? != 0 ]]; then
echo "Failed to find 'exists=true' for $KEY. Response:"
echo "$RESPONSE"
exit 1
fi
set -e
# we should not be able to look up the value
RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=\"$(toHex $VALUE)\"`
RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p`
set +e
2016-11-22 21:50:54 -05:00
A=`echo $RESPONSE | grep '"exists":true'`
2016-09-10 17:42:12 -04:00
if [[ $? == 0 ]]; then
echo "Found 'exists=true' for $VALUE when we should not have. Response:"
echo "$RESPONSE"
exit 1
fi
set -e
echo "Passed Test: $TESTNAME"