better testing. cli test for tutorial

This commit is contained in:
Ethan Buchman
2016-07-23 18:57:05 -04:00
parent a263323d5c
commit 3b329039d8
12 changed files with 191 additions and 67 deletions
+10
View File
@@ -0,0 +1,10 @@
echo hello
info
commit
append_tx abc
info
commit
query abc
append_tx def=xyz
commit
query def
+31
View File
@@ -0,0 +1,31 @@
> echo hello
-> data: {hello}
> info
-> data: {size:0}
> commit
> append_tx abc
-> code: OK
> info
-> data: {size:1}
> commit
-> data: {750502FC7E84BBD788ED589624F06CFA871845D1}
> query abc
-> code: OK
-> data: {Index=0 value=abc exists=true}
> append_tx def=xyz
-> code: OK
> commit
-> data: {76393B8A182E450286B0694C629ECB51B286EFD5}
> query def
-> code: OK
-> data: {Index=1 value=xyz exists=true}
+8
View File
@@ -0,0 +1,8 @@
set_option serial on
check_tx 0x00
check_tx 0xff
append_tx 0x00
check_tx 0x00
append_tx 0x01
append_tx 0x04
info
+26
View File
@@ -0,0 +1,26 @@
> set_option serial on
-> data: {serial=on}
> check_tx 0x00
-> code: OK
> check_tx 0xff
-> code: OK
> append_tx 0x00
-> code: OK
> check_tx 0x00
-> code: BadNonce
-> log: Invalid nonce. Expected >= 1, got 0
> append_tx 0x01
-> code: OK
> append_tx 0x04
-> code: BadNonce
-> log: Invalid nonce. Expected 2, got 4
> info
-> data: {hashes:0, txs:2}
+29
View File
@@ -0,0 +1,29 @@
#! /bin/bash
function testExample() {
N=$1
INPUT=$2
APP=$3
echo "Example $N"
$APP &> /dev/null &
sleep 2
tmsp-cli --verbose batch < $INPUT > "${INPUT}.out.new"
killall "$APP" > /dev/null
pre=`shasum < "${INPUT}.out"`
post=`shasum < "${INPUT}.out.new"`
if [[ "$pre" != "$post" ]]; then
echo "You broke the tutorial"
exit 1
fi
rm "${INPUT}".out.new
}
testExample 1 tests/test_cli/ex1.tmsp dummy
testExample 2 tests/test_cli/ex2.tmsp counter
echo ""
echo "PASS"