Fixed height handling in rest queries
This commit is contained in:
parent
ff0a50a1b3
commit
609600d322
|
@ -15,9 +15,9 @@ oneTimeSetUp() {
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
baseserver serve --port $BPORT >/dev/null &
|
baseserver serve --port $BPORT >/dev/null &
|
||||||
|
sleep 0.1 # for startup
|
||||||
PID_PROXY=$!
|
PID_PROXY=$!
|
||||||
disown
|
disown
|
||||||
sleep 0.1 # for startup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oneTimeTearDown() {
|
oneTimeTearDown() {
|
||||||
|
@ -35,12 +35,16 @@ restAddr() {
|
||||||
echo $ADDR
|
echo $ADDR
|
||||||
}
|
}
|
||||||
|
|
||||||
# XXX Ex Usage: restAccount $ADDR $AMOUNT
|
# XXX Ex Usage: restAccount $ADDR $AMOUNT [$HEIGHT]
|
||||||
# Desc: Assumes just one coin, checks the balance of first coin in any case
|
# Desc: Assumes just one coin, checks the balance of first coin in any case
|
||||||
restAccount() {
|
restAccount() {
|
||||||
assertNotNull "line=${LINENO}, address required" "$1"
|
assertNotNull "line=${LINENO}, address required" "$1"
|
||||||
ACCT=$(curl ${URL}/query/account/sigs:$1 2>/dev/null)
|
QUERY=${URL}/query/account/sigs:$1
|
||||||
if [ -n "$DEBUG" ]; then echo $ACCT; echo; fi
|
if [ -n "$3" ]; then
|
||||||
|
QUERY="${QUERY}?height=${3}"
|
||||||
|
fi
|
||||||
|
ACCT=$(curl ${QUERY} 2>/dev/null)
|
||||||
|
if [ -n "$DEBUG" ]; then echo $QUERY; echo $ACCT; echo; fi
|
||||||
assertEquals "line=${LINENO}, proper money" "$2" $(echo $ACCT | jq .data.coins[0].amount)
|
assertEquals "line=${LINENO}, proper money" "$2" $(echo $ACCT | jq .data.coins[0].amount)
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
@ -76,8 +80,8 @@ test01SendTx() {
|
||||||
HASH=$(echo $TX | jq .hash | tr -d \")
|
HASH=$(echo $TX | jq .hash | tr -d \")
|
||||||
TX_HEIGHT=$(echo $TX | jq .height)
|
TX_HEIGHT=$(echo $TX | jq .height)
|
||||||
|
|
||||||
restAccount $SENDER "9007199254740000"
|
restAccount $SENDER "9007199254740000" "$TX_HEIGHT"
|
||||||
restAccount $RECV "992"
|
restAccount $RECV "992" "$TX_HEIGHT"
|
||||||
|
|
||||||
# Make sure tx is indexed
|
# Make sure tx is indexed
|
||||||
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
|
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
|
||||||
|
|
|
@ -48,7 +48,7 @@ func doQueryAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var h int
|
var h int
|
||||||
qHeight := args["height"]
|
qHeight := r.URL.Query().Get("height")
|
||||||
if qHeight != "" {
|
if qHeight != "" {
|
||||||
h, err = strconv.Atoi(qHeight)
|
h, err = strconv.Atoi(qHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -31,7 +31,7 @@ func doQueryNonce(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var h int
|
var h int
|
||||||
qHeight := args["height"]
|
qHeight := r.URL.Query().Get("height")
|
||||||
if qHeight != "" {
|
if qHeight != "" {
|
||||||
h, err = strconv.Atoi(qHeight)
|
h, err = strconv.Atoi(qHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue