Skip to content

Commit

Permalink
test: add payout cancellation test to payout.bats
Browse files Browse the repository at this point in the history
  • Loading branch information
thevaibhav-dixit committed Jul 12, 2023
1 parent 04540ea commit a42701b
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions tests/e2e/payout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ teardown_file() {
stop_daemon
}


@test "payout: Cancel a payout and see if the balance is reflected" {
bria_cmd create-payout-queue --name high --interval-trigger 5
payout_id=$(bria_cmd submit-payout -w default --queue-name high --destination bcrt1q208tuy5rd3kvy8xdpv6yrczg7f3mnlk3lql7ej --amount 75000000 | jq -r '.id')
for i in {1..20}; do
cache_wallet_balance
[[ $(cached_encumbered_outgoing) == 75000000 ]] && break;
sleep 1
done
[[ $(cached_encumbered_outgoing) == 75000000 ]] || exit 1

bria_cmd cancel-payout --id ${payout_id}

for i in {1..20}; do
cache_wallet_balance
[[ $(cached_encumbered_outgoing) == 0 ]] && break;
sleep 1
done
[[ $(cached_encumbered_outgoing) == 0 ]] || exit 1;
}

@test "payout: Fund an address and see if the balance is reflected" {
bria_address=$(bria_cmd new-address -w default | jq -r '.address')
if [ -z "$bria_address" ]; then
Expand All @@ -26,7 +47,7 @@ teardown_file() {

for i in {1..30}; do
n_utxos=$(bria_cmd list-utxos -w default | jq '.keychains[0].utxos | length')
[[ "${n_utxos}" == "2" ]] && break
[[ "${n_utxos}" == "3" ]] && break
sleep 1
done
cache_wallet_balance
Expand All @@ -35,12 +56,11 @@ teardown_file() {
}

@test "payout: Create payout queue and have two queued payouts on it" {
bria_cmd create-payout-queue --name high --interval-trigger 5
bria_cmd submit-payout --wallet default --queue-name high --destination bcrt1q208tuy5rd3kvy8xdpv6yrczg7f3mnlk3lql7ej --amount 75000000
bria_cmd submit-payout --wallet default --queue-name high --destination bcrt1q3rr02wkkvkwcj7h0nr9dqr9z3z3066pktat7kv --amount 75000000 --metadata '{"foo":{"bar":"baz"}}'

n_payouts=$(bria_cmd list-payouts -w default | jq '.payouts | length')
[[ "${n_payouts}" == "2" ]] || exit 1
[[ "${n_payouts}" == "3" ]] || exit 1
batch_id=$(bria_cmd list-payouts -w default | jq '.payouts[0].batchId')
[[ "${batch_id}" == "null" ]] || exit 1
cache_wallet_balance
Expand All @@ -59,12 +79,12 @@ teardown_file() {
[[ $(cached_pending_income) == 0 ]] || exit 1

for i in {1..20}; do
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[0].batchId')
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[1].batchId')
[[ "${batch_id}" != "null" ]] && break
sleep 1
done
[[ "${batch_id}" != "null" ]] || exit 1
for i in {1..60}; do
for i in {1..20}; do
cache_wallet_balance
[[ $(cached_pending_outgoing) == 150000000 ]] && break;
sleep 1
Expand All @@ -76,7 +96,7 @@ teardown_file() {
}

@test "payout: Add signing config to complete payout" {
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[0].batchId')
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[1].batchId')
for i in {1..20}; do
signing_failure_reason=$(bria_cmd get-batch -b "${batch_id}" | jq -r '.signingSessions[0].failureReason')
[[ "${signing_failure_reason}" == "SignerConfigMissing" ]] && break
Expand Down Expand Up @@ -132,7 +152,7 @@ teardown_file() {
bria_cmd submit-payout --wallet default --queue-name manual --destination bcrt1q208tuy5rd3kvy8xdpv6yrczg7f3mnlk3lql7ej --amount 75000000

for i in {1..20}; do
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[2].batchId')
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[3].batchId')
[[ "${batch_id}" != "null" ]] && break;
sleep 1
done
Expand All @@ -141,7 +161,7 @@ teardown_file() {
bria_cmd trigger-payout-queue --name manual;

for i in {1..20}; do
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[2].batchId')
batch_id=$(bria_cmd list-payouts -w default | jq -r '.payouts[3].batchId')
[[ "${batch_id}" != "null" ]] && break
sleep 1
done
Expand Down

0 comments on commit a42701b

Please sign in to comment.