gpu-compute-chain/tests/test_auction_flow.sh

87 lines
2.9 KiB
Bash
Raw Normal View History

2022-09-02 13:48:12 -07:00
#!/bin/bash
# Tests the core auction flow (without specifying verified providers)
2022-09-02 13:48:12 -07:00
# import utilities
HERE=$(cd $(dirname $BASH_SOURCE) && pwd)
source $HERE/testutil.sh
colineard tx colinearcore unlock-all-funds -y --from alice \
| swallow "Unlock all funds before proceeding"
2022-09-07 16:49:58 -07:00
colineard tx colinearcore new-auction asdf asdf 200 uusdc $(now + 3500) \
2022-09-05 15:17:55 -07:00
-y --from bob \
| expect_fail "Can't create auction below min lease period"
2022-09-07 16:49:58 -07:00
colineard tx colinearcore new-auction asdf asdf 200 uusdc $(now + 8200000) \
2022-09-05 15:17:55 -07:00
-y --from bob \
| expect_fail "Can't create auction above max lease period"
2022-09-07 16:49:58 -07:00
before=$(get_balance $BOB uusdc)
2022-09-07 16:49:58 -07:00
colineard tx colinearcore new-auction asdf asdf 200 uusdc $(now + 3700) \
-y --from bob \
| expect_success "New auction is created"
2022-09-07 16:49:58 -07:00
get_balance $BOB uusdc | expect_change -200 $before "Change in Bob's balance"
colineard tx colinearcore new-bid $(get_last_auction_index) 100 \
-y --from alice \
| expect_fail "Can't bid without locking CLR"
colineard tx colinearcore lock-funds 550000000 -y --from alice \
| expect_success "Can lock above the maximum (550 CLR)"
colineard tx colinearcore lock-funds 500000000 -y --from alice \
| expect_success "Lock funds before bidding"
colineard tx colinearcore new-bid $(get_last_auction_index) 100 \
-y --from alice \
| expect_success "New bid is correctly created"
colineard tx colinearcore new-bid $(get_last_auction_index) 90 \
2022-09-03 17:59:37 -07:00
-y --from alice \
| expect_success "Can bid below price ceiling"
colineard tx colinearcore new-bid $(get_last_auction_index) 100 \
-y --from alice \
| expect_fail "Can't create duplicate bids"
colineard tx colinearcore new-bid $(get_next_auction_index) 100 \
2022-09-03 00:41:54 -07:00
-y --from alice \
| expect_fail "Can't create bids for nonexistent auctions"
2022-09-02 13:48:12 -07:00
colineard tx colinearcore new-bid $(get_last_auction_index) 600 \
-y --from alice \
| expect_fail "Can't bid over price ceiling"
2022-09-02 13:48:12 -07:00
colineard tx colinearcore new-bid $(get_last_auction_index) 0 \
-y --from alice \
2022-09-07 16:49:58 -07:00
| expect_fail "Can't bid 0 uusdcs"
colineard q colinearcore auction-bids $(get_last_auction_index) \
2022-09-03 17:59:37 -07:00
| jq -M ".bids | length" \
| assert_eq 2 "Number of auction bids"
2022-09-07 16:49:58 -07:00
before=$(get_balance $BOB uusdc)
# Was experiencing issues with bob's balance not updating, probably
# because we weren't waiting long enough
wait=12
log_info "Waiting $wait s until auction expires..."
sleep $wait
colineard tx colinearcore new-bid $(get_last_auction_index) 50 \
-y --from alice \
| expect_fail "Can't add bids after auction expiry"
colineard q colinearcore show-auction $(get_last_auction_index) \
| jq -rM ".auction.best.amount" \
| assert_eq 90 "Finalized top bid amount"
colineard q colinearcore show-auction $(get_last_auction_index) \
| jq -rM ".auction.remaining" \
| assert_eq 90 "Remaining vested amount"
2022-09-07 16:49:58 -07:00
get_balance $BOB uusdc | expect_change 110 $before "Change in Bob's balance"