Skip to content

Commit

Permalink
fix: external and internal cancel payout tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Nov 16, 2023
1 parent 88139ab commit fa02c2c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
20 changes: 15 additions & 5 deletions bats/core/api/onchain-send.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bats

load "../../helpers/cli.bash"
load "../../helpers/user.bash"
load "../../helpers/funding/onchain.bash"
load "../../helpers/funding/wallet.bash"
Expand All @@ -16,6 +17,15 @@ setup_file() {
fund_user_onchain 'bob' 'usd_wallet'
}

generate_trigger_logs() {
tilt_cli logs api-trigger > .e2e-trigger.log
}

grep_in_trigger_logs() {
generate_trigger_logs
grep $1 .e2e-trigger.log
}

@test "onchain-send: settle trade intraccount" {
btc_wallet_name="alice.btc_wallet_id"
usd_wallet_name="alice.usd_wallet_id"
Expand Down Expand Up @@ -426,7 +436,6 @@ setup_file() {
[[ "${amount}" == 0 ]] || exit 1
}


@test "onchain-send: cancel external payout" {
payout_id=$(bria_cli submit-payout \
-w dev-wallet \
Expand All @@ -436,7 +445,8 @@ setup_file() {
| jq -r '.id'
)
[[ "${payout_id}" != "null" ]] || exit 1
retry 10 1 grep "sequence.*payout_submitted.*${payout_id}" .e2e-trigger.log

retry 10 1 grep_in_trigger_logs "sequence.*payout_submitted.*${payout_id}"

last_sequence=$(
grep "sequence" .e2e-trigger.log \
Expand All @@ -446,7 +456,7 @@ setup_file() {
[[ -n "${last_sequence}" ]] || exit 1

bria_cli cancel-payout -i ${payout_id}
retry 10 1 grep "sequence\":${sequence}.*payout_cancelled.*${payout_id}" .e2e-trigger.log
retry 10 1 grep_in_trigger_logs "sequence.*payout_cancelled.*${payout_id}"
}

@test "onchain-send: cancel internal payout" {
Expand Down Expand Up @@ -481,7 +491,7 @@ setup_file() {
[[ "${send_status}" = "SUCCESS" ]] || exit 1

# Parse payout_id value
retry 10 1 grep "sequence\":${sequence}.*payout_submitted" .e2e-trigger.log
retry 10 1 grep_in_trigger_logs "sequence\":${sequence}.*payout_submitted"
payout_id=$(
grep "sequence.*payout_submitted" .e2e-trigger.log \
| tail -n 1 \
Expand All @@ -490,5 +500,5 @@ setup_file() {

# Check for cancelled event
bria_cli cancel-payout -i ${payout_id}
retry 10 1 grep "sequence.*payout_cancelled.*${payout_id}" .e2e-trigger.log
retry 10 1 grep_in_trigger_logs "sequence.*payout_cancelled.*${payout_id}"
}
8 changes: 0 additions & 8 deletions bats/helpers/_common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,3 @@ cache_value() {
read_value() {
cat ${CACHE_DIR}/$1
}

bitcoin_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli $@
}

bria_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria $@
}
11 changes: 11 additions & 0 deletions bats/helpers/cli.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bitcoin_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli $@
}

bria_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria $@
}

tilt_cli() {
tilt $@
}

0 comments on commit fa02c2c

Please sign in to comment.