Cleanup proof format, complete basic cli tests
This commit is contained in:
parent
66c9010bcb
commit
cfe13e9c13
1
Makefile
1
Makefile
|
@ -20,6 +20,7 @@ clitest/shunit2:
|
|||
-q -O clitest/shunit2
|
||||
|
||||
test_cli: clitest/shunit2
|
||||
# sudo apt-get install jq
|
||||
@./clitest/basictx.sh
|
||||
# @./clitest/ibc.sh
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ oneTimeSetUp() {
|
|||
|
||||
# start basecoin server (with counter)
|
||||
initServer
|
||||
sleep 5
|
||||
PID_SERVER=$!
|
||||
echo pid $PID_SERVER
|
||||
|
||||
initClient
|
||||
|
@ -30,8 +28,10 @@ oneTimeSetUp() {
|
|||
}
|
||||
|
||||
oneTimeTearDown() {
|
||||
echo "stopping basecoin test server"
|
||||
kill -9 $PID_SERVER
|
||||
echo
|
||||
echo
|
||||
echo "stopping basecoin test server..."
|
||||
kill -9 $PID_SERVER >/dev/null 2>&1
|
||||
sleep 1
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ initServer() {
|
|||
|
||||
echo "Starting server..."
|
||||
basecoin start --home=$SERVE_DIR >>$SERVER_LOG 2>&1 &
|
||||
sleep 5
|
||||
PID_SERVER=$!
|
||||
}
|
||||
|
||||
initClient() {
|
||||
|
@ -86,22 +88,56 @@ getAddr() {
|
|||
echo $RAW | cut -d' ' -f2
|
||||
}
|
||||
|
||||
testGetAccount() {
|
||||
test00GetAccount() {
|
||||
SENDER=$(getAddr $RICH)
|
||||
RECV=$(getAddr $POOR)
|
||||
|
||||
echo sender $RICH
|
||||
echo $SENDER
|
||||
|
||||
echo recipient $POOR
|
||||
echo $RECV
|
||||
|
||||
assertFalse "requires arg" "basecli query account"
|
||||
ACCT=$(basecli query account $SENDER)
|
||||
assertTrue "must have proper genesis account" $?
|
||||
echo $ACCT
|
||||
assertEquals "no tx" "0" $(echo $ACCT | jq .data.sequence)
|
||||
assertEquals "has money" "9007199254740992" $(echo $ACCT | jq .data.coins[0].amount)
|
||||
|
||||
ACCT2=$(basecli query account $RECV)
|
||||
assertFalse "has no genesis account" $?
|
||||
}
|
||||
|
||||
test01SendTx() {
|
||||
SENDER=$(getAddr $RICH)
|
||||
RECV=$(getAddr $POOR)
|
||||
|
||||
assertFalse "missing dest" "basecli tx send --amount=992mycoin --sequence=1 2>/dev/null"
|
||||
assertFalse "bad password" "echo foo | basecli tx send --amount=992mycoin --sequence=1 --to=$RECV --name=$RICH 2>/dev/null"
|
||||
# we have to remove the password request from stdout, to just get the json
|
||||
RES=$(echo qwertyuiop | basecli tx send --amount=992mycoin --sequence=1 --to=$RECV --name=$RICH 2>/dev/null | tail -n +2)
|
||||
assertTrue "sent tx" $?
|
||||
HASH=$(echo $RES | jq .hash | tr -d \")
|
||||
TX_HEIGHT=$(echo $RES | jq .height)
|
||||
assertEquals "good check" "0" $(echo $RES | jq .check_tx.code)
|
||||
assertEquals "good deliver" "0" $(echo $RES | jq .deliver_tx.code)
|
||||
|
||||
# make sure sender goes down
|
||||
ACCT=$(basecli query account $SENDER)
|
||||
assertTrue "must have genesis account" $?
|
||||
assertEquals "one tx" "1" $(echo $ACCT | jq .data.sequence)
|
||||
assertEquals "has money" "9007199254740000" $(echo $ACCT | jq .data.coins[0].amount)
|
||||
|
||||
# make sure recipient goes up
|
||||
ACCT2=$(basecli query account $RECV)
|
||||
assertTrue "must have new account" $?
|
||||
assertEquals "no tx" "0" $(echo $ACCT2 | jq .data.sequence)
|
||||
assertEquals "has money" "992" $(echo $ACCT2 | jq .data.coins[0].amount)
|
||||
|
||||
# make sure tx is indexed
|
||||
TX=$(basecli query tx $HASH)
|
||||
assertTrue "found tx" $?
|
||||
assertEquals "proper height" $TX_HEIGHT $(echo $TX | jq .height)
|
||||
assertEquals "type=send" '"send"' $(echo $TX | jq .data.type)
|
||||
assertEquals "proper sender" "\"$SENDER\"" $(echo $TX | jq .data.data.inputs[0].address)
|
||||
assertEquals "proper out amount" "992" $(echo $TX | jq .data.data.outputs[0].coins[0].amount)
|
||||
}
|
||||
|
||||
|
||||
# load and run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/shunit2
|
||||
|
|
|
@ -127,7 +127,7 @@ imports:
|
|||
- data
|
||||
- data/base58
|
||||
- name: github.com/tendermint/light-client
|
||||
version: 88fb726e779d97acac5f0bd387892bfc541f3701
|
||||
version: a4dbbcacfd2d0a53da1393cbe176c0a81cab42e7
|
||||
subpackages:
|
||||
- certifiers
|
||||
- certifiers/client
|
||||
|
|
Loading…
Reference in New Issue