From be1c427ba7ff6169f35aa12b23c91cde51a99ec2 Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Sun, 4 Sep 2022 00:59:37 +0000 Subject: [PATCH] more test updates --- tests/test_auction_flow.sh | 12 ++++++++++-- tests/testutil.sh | 13 +++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/test_auction_flow.sh b/tests/test_auction_flow.sh index 822f809..9b2adba 100755 --- a/tests/test_auction_flow.sh +++ b/tests/test_auction_flow.sh @@ -4,7 +4,7 @@ HERE=$(cd $(dirname $BASH_SOURCE) && pwd) source $HERE/testutil.sh -cosmos-testd tx cosmostest new-auction asdf asdf 500 token 1662155879 \ +cosmos-testd tx cosmostest new-auction asdf asdf 500 token $(now + 100) \ -y --from bob \ | expect_success "New auction is created" @@ -12,6 +12,10 @@ cosmos-testd tx cosmostest new-bid $(get_last_auction_index) 100 \ -y --from alice \ | expect_success "New bid is correctly created" +cosmos-testd tx cosmostest new-bid $(get_last_auction_index) 90 \ + -y --from alice \ + | expect_success "Can bid below price ceiling" + cosmos-testd tx cosmostest new-bid $(get_last_auction_index) 100 \ -y --from alice \ | expect_fail "Can't create duplicate bids" @@ -28,9 +32,13 @@ cosmos-testd tx cosmostest new-bid $(get_last_auction_index) 0 \ -y --from alice \ | expect_fail "Can't bid 0 tokens" +cosmos-testd q cosmostest auction-bids $(get_last_auction_index) \ + | jq -M ".bids | length" \ + | assert_eq 2 "Number of auction bids" + log_info "Waiting until auction expires..." sleep 10 -cosmos-testd tx cosmostest new-bid $(get_last_auction_index) 100 \ +cosmos-testd tx cosmostest new-bid $(get_last_auction_index) 50 \ -y --from alice \ | expect_fail "Can't add bids after auction expiry" diff --git a/tests/testutil.sh b/tests/testutil.sh index f28f4ed..dcc1ffc 100644 --- a/tests/testutil.sh +++ b/tests/testutil.sh @@ -7,13 +7,14 @@ cosmos-testd config output json # Compares $1 & $2, exiting with $3 (label) if not eq function assert_eq { - if [[ $1 = $2 ]]; then - log_fail - echo Expected $3 to equal $2, instead got $1. - exit 1 - else + read -r out + if [[ $out = $1 ]]; then log_ok - echo $3 correctly equals $2 + echo $2 correctly equals $1 + else + log_fail + echo $2 should equal $1, instead got $out. + exit 1 fi }