Fix cli tests to explicitly pass height when querying results of tx
This commit is contained in:
parent
5714b101b5
commit
ff0a50a1b3
|
@ -184,7 +184,7 @@ test04SendIBCPacket() {
|
|||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
# Make sure balance went down and tx is indexed
|
||||
checkAccount $SENDER "9007199254720990"
|
||||
checkAccount $SENDER "9007199254720990" "$TX_HEIGHT"
|
||||
checkSendTx $HASH $TX_HEIGHT $SENDER "20002"
|
||||
|
||||
# look, we wrote a packet
|
||||
|
@ -211,7 +211,7 @@ test05ReceiveIBCPacket() {
|
|||
# make some credit, so we can accept the packet
|
||||
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=60006mycoin --to=$CHAIN_ID_1:: --name=$RICH)
|
||||
txSucceeded $? "$TX" "${CHAIN_ID_1}::"
|
||||
checkAccount $CHAIN_ID_1:: "60006"
|
||||
checkAccount $CHAIN_ID_1:: "60006" "$TX_HEIGHT"
|
||||
|
||||
# now, we try to post it.... (this is PACKET from last test)
|
||||
|
||||
|
@ -279,7 +279,7 @@ assertNewHeight() {
|
|||
# TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
# # Make sure balance went down and tx is indexed
|
||||
# checkAccount $SENDER "1" "9007199254720990"
|
||||
# checkAccount $SENDER "1" "9007199254720990" "$TX_HEIGHT"
|
||||
# checkSendTx $HASH $TX_HEIGHT $SENDER "20002"
|
||||
|
||||
# # Make sure nothing arrived - yet
|
||||
|
|
|
@ -126,8 +126,8 @@ test04CreateRoleInvalid() {
|
|||
# TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
# # deduct 100 from sender, add 90 to receiver... fees "vanish"
|
||||
# checkAccount $SENDER "9007199254739900"
|
||||
# checkAccount $RECV "1082"
|
||||
# checkAccount $SENDER "9007199254739900" "$TX_HEIGHT"
|
||||
# checkAccount $RECV "1082" "$TX_HEIGHT"
|
||||
|
||||
# # Make sure tx is indexed
|
||||
# checkSendFeeTx $HASH $TX_HEIGHT $SENDER "90" "10"
|
||||
|
@ -135,8 +135,8 @@ test04CreateRoleInvalid() {
|
|||
# # assert replay protection
|
||||
# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90mycoin --fee=10mycoin --sequence=2 --to=$RECV --name=$RICH 2>/dev/null)
|
||||
# assertFalse "line=${LINENO}, replay: $TX" $?
|
||||
# checkAccount $SENDER "9007199254739900"
|
||||
# checkAccount $RECV "1082"
|
||||
# checkAccount $SENDER "9007199254739900" "$TX_HEIGHT"
|
||||
# checkAccount $RECV "1082" "$TX_HEIGHT"
|
||||
|
||||
# # make sure we can query the proper nonce
|
||||
# NONCE=$(${CLIENT_EXE} query nonce $SENDER)
|
||||
|
|
|
@ -26,8 +26,8 @@ test00PreRestart() {
|
|||
HASH=$(echo $TX | jq .hash | tr -d \")
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
checkAccount $SENDER "9007199254740000"
|
||||
checkAccount $RECV "992"
|
||||
checkAccount $SENDER "9007199254740000" "$TX_HEIGHT"
|
||||
checkAccount $RECV "992" "$TX_HEIGHT"
|
||||
|
||||
# make sure tx is indexed
|
||||
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
|
||||
|
|
|
@ -35,7 +35,7 @@ test01SetupRole() {
|
|||
HASH=$(echo $TX | jq .hash | tr -d \")
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
checkRole "${ROLE}" $SIGS 3
|
||||
checkRole "${ROLE}" $SIGS 3 "$TX_HEIGHT"
|
||||
|
||||
# Make sure tx is indexed
|
||||
checkRoleTx $HASH $TX_HEIGHT "${ROLE}" 3
|
||||
|
@ -51,8 +51,8 @@ test02SendTxToRole() {
|
|||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
# reduce by 10090
|
||||
checkAccount $SENDER "9007199254730902"
|
||||
checkAccount $RECV "10000"
|
||||
checkAccount $SENDER "9007199254730902" "$TX_HEIGHT"
|
||||
checkAccount $RECV "10000" "$TX_HEIGHT"
|
||||
|
||||
checkSendFeeTx $HASH $TX_HEIGHT $SENDER "10000" "90"
|
||||
}
|
||||
|
@ -82,9 +82,10 @@ test03SendMultiFromRole() {
|
|||
# and get some dude to sign it for the full access
|
||||
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx --in=$TX_FILE --name=$DUDE)
|
||||
txSucceeded $? "$TX" "multi-bank"
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
checkAccount $TWO "6000"
|
||||
checkAccount $BANK "4000"
|
||||
checkAccount $TWO "6000" "$TX_HEIGHT"
|
||||
checkAccount $BANK "4000" "$TX_HEIGHT"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ test01SendTx() {
|
|||
HASH=$(echo $TX | jq .hash | tr -d \")
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
checkAccount $SENDER "9007199254740000"
|
||||
checkAccount $RECV "992"
|
||||
checkAccount $SENDER "9007199254740000" "$TX_HEIGHT"
|
||||
checkAccount $RECV "992" "$TX_HEIGHT"
|
||||
|
||||
# make sure tx is indexed
|
||||
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
|
||||
|
@ -53,11 +53,15 @@ test02GetCounter() {
|
|||
assertFalse "Line=${LINENO}, no default count" $?
|
||||
}
|
||||
|
||||
# checkCounter $COUNT $BALANCE
|
||||
# checkCounter $COUNT $BALANCE [$HEIGHT]
|
||||
# Assumes just one coin, checks the balance of first coin in any case
|
||||
# pass optional height to query which block to query
|
||||
checkCounter() {
|
||||
# default height of 0, but accept an argument
|
||||
HEIGHT=${3:-0}
|
||||
|
||||
# make sure sender goes down
|
||||
ACCT=$(${CLIENT_EXE} query counter)
|
||||
ACCT=$(${CLIENT_EXE} query counter --height=$HEIGHT)
|
||||
if assertTrue "Line=${LINENO}, count is set" $?; then
|
||||
assertEquals "Line=${LINENO}, proper count" "$1" $(echo $ACCT | jq .data.counter)
|
||||
assertEquals "Line=${LINENO}, proper money" "$2" $(echo $ACCT | jq .data.total_fees[0].amount)
|
||||
|
@ -74,10 +78,10 @@ test03AddCount() {
|
|||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
# make sure the counter was updated
|
||||
checkCounter "1" "10"
|
||||
checkCounter "1" "10" "$TX_HEIGHT"
|
||||
|
||||
# make sure the account was debited
|
||||
checkAccount $SENDER "9007199254739990"
|
||||
checkAccount $SENDER "9007199254739990" "$TX_HEIGHT"
|
||||
|
||||
# make sure tx is indexed
|
||||
TX=$(${CLIENT_EXE} query tx $HASH --trace)
|
||||
|
@ -96,18 +100,20 @@ test03AddCount() {
|
|||
# test again with fees...
|
||||
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=7mycoin --fee=4mycoin --sequence=3 --name=${RICH} --valid)
|
||||
txSucceeded $? "$TX" "counter"
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
# make sure the counter was updated, added 7
|
||||
checkCounter "2" "17"
|
||||
|
||||
checkCounter "2" "17" "$TX_HEIGHT"
|
||||
# make sure the account was debited 11
|
||||
checkAccount $SENDER "9007199254739979"
|
||||
checkAccount $SENDER "9007199254739979" "$TX_HEIGHT"
|
||||
|
||||
# make sure we cannot replay the counter, no state change
|
||||
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=10mycoin --sequence=2 --name=${RICH} --valid 2>/dev/null)
|
||||
assertFalse "line=${LINENO}, replay: $TX" $?
|
||||
checkCounter "2" "17"
|
||||
checkAccount $SENDER "9007199254739979"
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
checkCounter "2" "17" "$TX_HEIGHT"
|
||||
checkAccount $SENDER "9007199254739979" "$TX_HEIGHT"
|
||||
}
|
||||
|
||||
# Load common then run these tests with shunit2!
|
||||
|
|
|
@ -49,7 +49,7 @@ test00SetGetRemove() {
|
|||
TX_HEIGHT=$(echo $TXRES | jq .height)
|
||||
|
||||
# make sure it is set
|
||||
DATA=$(${CLIENT_EXE} query eyes ${KEY})
|
||||
DATA=$(${CLIENT_EXE} query eyes ${KEY} --height=$TX_HEIGHT)
|
||||
assertTrue "line=${LINENO} data not set" $?
|
||||
assertEquals "line=${LINENO}" "\"${VALUE}\"" $(echo $DATA | jq .data.value)
|
||||
|
||||
|
|
|
@ -142,11 +142,14 @@ checkAccount() {
|
|||
return $?
|
||||
}
|
||||
|
||||
# XXX Ex Usage: checkRole $ROLE $SIGS $NUM_SIGNERS
|
||||
# XXX Ex Usage: checkRole $ROLE $SIGS $NUM_SIGNERS [$HEIGHT]
|
||||
# Desc: Ensures this named role exists, and has the number of members and required signatures as above
|
||||
checkRole() {
|
||||
# default height of 0, but accept an argument
|
||||
HEIGHT=${4:-0}
|
||||
|
||||
# make sure sender goes down
|
||||
QROLE=$(${CLIENT_EXE} query role $1)
|
||||
QROLE=$(${CLIENT_EXE} query role $1 --height=$HEIGHT)
|
||||
if ! assertTrue "line=${LINENO}, role must exist" $?; then
|
||||
return 1
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue