updated tests for unlocking & locked-fund queries

master
michael 2022-09-09 00:10:04 +00:00
parent 8976bfa8a7
commit df48ee3ce6
3 changed files with 49 additions and 2 deletions

View File

@ -3,6 +3,7 @@ SHELL = /bin/bash
.PHONY: test .PHONY: test
test: test:
./tests/test_locking_funds.sh
./tests/test_auction_flow.sh ./tests/test_auction_flow.sh
utest: utest:

View File

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
# Tests the core auction flow
# import utilities # import utilities
HERE=$(cd $(dirname $BASH_SOURCE) && pwd) HERE=$(cd $(dirname $BASH_SOURCE) && pwd)
source $HERE/testutil.sh source $HERE/testutil.sh
colineard tx colinearcore lock-funds 400000000 -y --from alice \ colineard tx colinearcore unlock-all-funds -y --from alice \
| expect_fail "Can't lock any amount below the minimum required (400 CLR)" | swallow "Unlock all funds before proceeding"
colineard tx colinearcore new-auction asdf asdf 200 uusdc $(now + 3500) \ colineard tx colinearcore new-auction asdf asdf 200 uusdc $(now + 3500) \
-y --from bob \ -y --from bob \
@ -30,6 +32,9 @@ colineard tx colinearcore new-bid $(get_last_auction_index) 100 \
colineard tx colinearcore lock-funds 550000000 -y --from alice \ colineard tx colinearcore lock-funds 550000000 -y --from alice \
| expect_success "Can lock above the maximum (550 CLR)" | 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 \ colineard tx colinearcore new-bid $(get_last_auction_index) 100 \
-y --from alice \ -y --from alice \
| expect_success "New bid is correctly created" | expect_success "New bid is correctly created"

41
tests/test_locking_funds.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Tests the behavior of provider CLR locking
# import utilities
HERE=$(cd $(dirname $BASH_SOURCE) && pwd)
source $HERE/testutil.sh
# We swallow this because with a fresh chain state there is nothing
# locked to begin with
colineard tx colinearcore unlock-all-funds -y --from alice \
| swallow "Unlock all funds before proceeding"
colineard tx colinearcore lock-funds 400000000 -y --from alice \
| expect_fail "Can't lock any amount below the minimum required (400 CLR)"
colineard tx colinearcore lock-funds 500000000 -y --from alice \
| expect_success "Can lock at the min amount of CLR required"
colineard tx colinearcore lock-funds 100000000 -y --from alice \
| expect_success "Can lock over the min amount of CLR required"
before=$(colineard q colinearcore locked-funds $ALICE \
| jq -rM ".amount")
colineard tx colinearcore unlock-funds 150000000 -y --from alice \
| expect_success "Unlock 150 CLR"
colineard q colinearcore locked-funds $ALICE \
| jq -rM ".amount" \
| expect_change -150000000 $before "New locked balance reflects unlock"
before=$(colineard q colinearcore locked-funds $ALICE \
| jq -rM ".amount")
colineard tx colinearcore unlock-all-funds -y --from alice \
| expect_success "Unlock all remaining funds"
colineard q colinearcore locked-funds $ALICE \
| jq -rM ".amount" \
| expect_change -450000000 $before "New locked balance reflects unlock"