2022-09-02 13:48:12 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-09-13 17:01:24 -07:00
|
|
|
# Tests the core auction flow (without specifying verified providers)
|
2022-09-08 17:10:04 -07:00
|
|
|
|
2022-09-02 13:48:12 -07:00
|
|
|
# import utilities
|
|
|
|
HERE=$(cd $(dirname $BASH_SOURCE) && pwd)
|
|
|
|
source $HERE/testutil.sh
|
|
|
|
|
2022-09-08 17:10:04 -07:00
|
|
|
colineard tx colinearcore unlock-all-funds -y --from alice \
|
|
|
|
| swallow "Unlock all funds before proceeding"
|
2022-09-07 16:49:58 -07:00
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-auction asdf asdf 2000 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-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-auction asdf asdf 2000 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-05 14:18:04 -07:00
|
|
|
|
2022-09-07 16:49:58 -07:00
|
|
|
before=$(get_balance $BOB uusdc)
|
2022-09-04 17:10:42 -07:00
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-auction asdf asdf 2000 uusdc $(now + 3700) \
|
2022-09-03 17:41:27 -07:00
|
|
|
-y --from bob \
|
2022-09-04 17:10:42 -07:00
|
|
|
| expect_success "New auction is created"
|
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
get_balance $BOB uusdc | expect_change -2000 $before "Change in Bob's balance"
|
2022-09-07 16:49:58 -07:00
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 1900 \
|
2022-09-07 16:49:58 -07:00
|
|
|
-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)"
|
2022-09-03 17:41:27 -07:00
|
|
|
|
2022-09-08 17:10:04 -07:00
|
|
|
colineard tx colinearcore lock-funds 500000000 -y --from alice \
|
|
|
|
| expect_success "Lock funds before bidding"
|
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 2000 \
|
2022-09-03 17:41:27 -07:00
|
|
|
-y --from alice \
|
|
|
|
| expect_success "New bid is correctly created"
|
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 1900 \
|
2022-09-03 17:59:37 -07:00
|
|
|
-y --from alice \
|
|
|
|
| expect_success "Can bid below price ceiling"
|
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 1900 \
|
2022-09-03 17:41:27 -07:00
|
|
|
-y --from alice \
|
|
|
|
| expect_fail "Can't create duplicate bids"
|
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_next_auction_index) 1800 \
|
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
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 6000 \
|
2022-09-03 17:41:27 -07:00
|
|
|
-y --from alice \
|
|
|
|
| expect_fail "Can't bid over price ceiling"
|
2022-09-02 13:48:12 -07:00
|
|
|
|
2022-09-07 15:15:49 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 0 \
|
2022-09-03 17:41:27 -07:00
|
|
|
-y --from alice \
|
2022-09-14 17:42:31 -07:00
|
|
|
| expect_fail "Can't bid 0 tokens"
|
2022-09-03 17:41:27 -07:00
|
|
|
|
2022-09-07 15:15:49 -07:00
|
|
|
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)
|
2022-09-05 14:18:04 -07:00
|
|
|
|
2022-09-05 15:20:19 -07:00
|
|
|
# Was experiencing issues with bob's balance not updating, probably
|
2022-09-14 17:42:31 -07:00
|
|
|
# because we weren't waiting long enough; block times are not *exactly* 1s in testing, maybe?
|
2022-09-13 17:01:24 -07:00
|
|
|
wait=12
|
|
|
|
log_info "Waiting $wait s until auction expires..."
|
|
|
|
sleep $wait
|
2022-09-03 17:41:27 -07:00
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
colineard tx colinearcore new-bid $(get_last_auction_index) 1500 \
|
2022-09-03 17:41:27 -07:00
|
|
|
-y --from alice \
|
|
|
|
| expect_fail "Can't add bids after auction expiry"
|
2022-09-05 14:18:04 -07:00
|
|
|
|
2022-09-07 15:15:49 -07:00
|
|
|
colineard q colinearcore show-auction $(get_last_auction_index) \
|
2022-09-05 14:18:04 -07:00
|
|
|
| jq -rM ".auction.best.amount" \
|
2022-09-14 17:42:31 -07:00
|
|
|
| assert_eq 1900 "Finalized top bid amount"
|
2022-09-13 17:01:24 -07:00
|
|
|
|
|
|
|
colineard q colinearcore show-auction $(get_last_auction_index) \
|
|
|
|
| jq -rM ".auction.remaining" \
|
2022-09-14 17:42:31 -07:00
|
|
|
| assert_eq 1900 "Remaining vested amount"
|
2022-09-05 14:18:04 -07:00
|
|
|
|
2022-09-14 17:42:31 -07:00
|
|
|
get_balance $BOB uusdc | expect_change 100 $before "Change in Bob's balance (from paid remainder)"
|
|
|
|
|
|
|
|
# --- Test vesting payout after some wait time ---
|
|
|
|
|
|
|
|
before=$(get_balance $ALICE uusdc)
|
2022-09-14 23:39:35 -07:00
|
|
|
remaining_before=$(colineard q colinearcore show-auction $(get_last_auction_index) \
|
|
|
|
| jq -rM ".auction.remaining")
|
2022-09-14 17:42:31 -07:00
|
|
|
|
|
|
|
wait=5
|
|
|
|
log_info "Waiting $wait s for vested funds to accumulate..."
|
|
|
|
sleep $wait
|
|
|
|
|
|
|
|
colineard tx colinearcore claim-funds $(get_last_auction_index) \
|
|
|
|
-y --from alice \
|
|
|
|
| expect_success "Top bidder can claim vested funds"
|
|
|
|
|
|
|
|
get_balance $ALICE uusdc \
|
|
|
|
| expect_increase $before "Alice's balance"
|
2022-09-14 23:39:35 -07:00
|
|
|
|
|
|
|
colineard q colinearcore show-auction $(get_last_auction_index) \
|
|
|
|
| jq -rM ".auction.remaining" \
|
|
|
|
| expect_decrease $remaining_before "Remaining claimable amount in auction"
|