From df48ee3ce65d0f056fdbd24c475a1db3c8ef875f Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Fri, 9 Sep 2022 00:10:04 +0000 Subject: [PATCH] updated tests for unlocking & locked-fund queries --- Makefile | 1 + tests/test_auction_flow.sh | 9 ++++++-- tests/test_locking_funds.sh | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 tests/test_locking_funds.sh diff --git a/Makefile b/Makefile index 784d4c8..3fead79 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ SHELL = /bin/bash .PHONY: test test: + ./tests/test_locking_funds.sh ./tests/test_auction_flow.sh utest: diff --git a/tests/test_auction_flow.sh b/tests/test_auction_flow.sh index da13493..4cc4a71 100755 --- a/tests/test_auction_flow.sh +++ b/tests/test_auction_flow.sh @@ -1,11 +1,13 @@ #!/bin/bash +# Tests the core auction flow + # import utilities HERE=$(cd $(dirname $BASH_SOURCE) && pwd) source $HERE/testutil.sh -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 unlock-all-funds -y --from alice \ +| swallow "Unlock all funds before proceeding" colineard tx colinearcore new-auction asdf asdf 200 uusdc $(now + 3500) \ -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 \ | 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" diff --git a/tests/test_locking_funds.sh b/tests/test_locking_funds.sh new file mode 100755 index 0000000..5148100 --- /dev/null +++ b/tests/test_locking_funds.sh @@ -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"