mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 15:47:07 +00:00
python fixes, tests
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
|
||||
ROOT=$GOPATH/src/github.com/tendermint/tmsp
|
||||
cd $ROOT
|
||||
|
||||
# test golang dummy
|
||||
bash tests/test_dummy.sh
|
||||
|
||||
# test golang counter
|
||||
bash tests/test_counter.sh
|
||||
|
||||
# test python counter
|
||||
cd example/python
|
||||
COUNTER_APP="python app.py" bash $ROOT/tests/test_counter.sh
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
# so we can test other languages
|
||||
if [[ "$COUNTER_APP" == "" ]]; then
|
||||
COUNTER_APP="counter"
|
||||
fi
|
||||
|
||||
echo "Testing counter app for: $COUNTER_APP"
|
||||
|
||||
# run the counter app
|
||||
$COUNTER_APP &> /dev/null &
|
||||
PID=`echo $!`
|
||||
|
||||
if [[ "$?" != 0 ]]; then
|
||||
echo "Error running tmsp command"
|
||||
echo $OUTPUT
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
OUTPUT=`(tmsp batch) <<STDIN
|
||||
set_option serial on
|
||||
get_hash
|
||||
append_tx abc
|
||||
STDIN`
|
||||
|
||||
if [[ "$?" != 0 ]]; then
|
||||
echo "Error running tmsp command"
|
||||
echo $OUTPUT
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# why can't we pick up the non-zero exit code here?
|
||||
# echo $?
|
||||
|
||||
HASH1=`echo "$OUTPUT" | tail -n +2 | head -n 1`
|
||||
if [[ "${HASH1}" != "" ]]; then
|
||||
echo "Expected opening hash to be empty. Got $HASH1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUTPUT=`(tmsp batch) <<STDIN
|
||||
set_option serial on
|
||||
append_tx 0x00
|
||||
get_hash
|
||||
append_tx 0x01
|
||||
get_hash
|
||||
STDIN`
|
||||
|
||||
if [[ "$?" != 0 ]]; then
|
||||
echo "Error running tmsp command"
|
||||
echo $OUTPUT
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HASH1=`echo "$OUTPUT" | tail -n +3 | head -n 1`
|
||||
HASH2=`echo "$OUTPUT" | tail -n +5 | head -n 1`
|
||||
|
||||
if [[ "${HASH1:0:2}" != "01" ]]; then
|
||||
echo "Expected hash to lead with 01. Got $HASH1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${HASH2:0:2}" != "02" ]]; then
|
||||
echo "Expected hash to lead with 02. Got $HASH2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "... Pass!"
|
||||
echo ""
|
||||
|
||||
ps -p $PID > /dev/null
|
||||
if [[ "$?" == "0" ]]; then
|
||||
kill -9 $PID
|
||||
fi
|
||||
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Make sure the tmsp cli can connect to the dummy
|
||||
echo "Dummy test ..."
|
||||
dummy &> /dev/null &
|
||||
PID=`echo $!`
|
||||
sleep 1
|
||||
RESULT_HASH=`tmsp get_hash`
|
||||
if [[ "$RESULT_HASH" != "" ]]; then
|
||||
echo "Expected nothing but got: $RESULT_HASH"
|
||||
exit 1
|
||||
fi
|
||||
echo "... Pass!"
|
||||
echo ""
|
||||
|
||||
# Add a tx, get hash, commit, get hash
|
||||
# hashes should be non-empty and identical
|
||||
echo "Dummy batch test ..."
|
||||
OUTPUT=`(tmsp batch) <<STDIN
|
||||
append_tx abc
|
||||
get_hash
|
||||
commit
|
||||
get_hash
|
||||
STDIN`
|
||||
|
||||
HASH1=`echo "$OUTPUT" | tail -n 3 | head -n 1`
|
||||
HASH2=`echo "$OUTPUT" | tail -n 1`
|
||||
|
||||
if [[ "$HASH1" == "" ]]; then
|
||||
echo "Expected non empty hash!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$HASH1" != "$HASH2" ]]; then
|
||||
echo "Expected hashes before and after commit to match: $HASH1, $HASH2"
|
||||
exit 1
|
||||
fi
|
||||
echo "... Pass!"
|
||||
echo ""
|
||||
|
||||
# Start a new connection and ensure the hash is the same
|
||||
echo "New connection test ..."
|
||||
RESULT_HASH=`tmsp get_hash`
|
||||
if [[ "$HASH1" != "$RESULT_HASH" ]]; then
|
||||
echo "Expected hash to persist as $HASH1 for new connection. Got $RESULT_HASH"
|
||||
exit 1
|
||||
fi
|
||||
echo "... Pass!"
|
||||
echo ""
|
||||
|
||||
|
||||
kill $PID
|
||||
sleep 1
|
||||
Reference in New Issue
Block a user