Skip to content

Commit

Permalink
test(core): remove trigger sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Dec 20, 2023
1 parent 8c2fc05 commit 7cc4250
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bats/core/api/ln-receive.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ load "../../helpers/ledger.bash"
load "../../helpers/ln.bash"
load "../../helpers/onchain.bash"
load "../../helpers/subscriber.bash"
load "../../helpers/trigger.bash"
load "../../helpers/user.bash"

ALICE='alice'

TRIGGER_STOP_FILE="$BATS_ROOT_DIR/.stop_trigger"

setup_file() {
create_user "$ALICE"
add_callback "$ALICE"
Expand Down Expand Up @@ -269,6 +268,7 @@ usd_amount=50

# Stop trigger
touch $TRIGGER_STOP_FILE
retry 10 1 trigger_is_stopped || exit 1

# Generate invoice
variables=$(
Expand All @@ -286,7 +286,7 @@ usd_amount=50

# Start trigger
rm $TRIGGER_STOP_FILE
sleep 5
retry 10 1 trigger_is_started

# Pay invoice & check for settled
lnd_outside_cli payinvoice -f \
Expand All @@ -302,6 +302,7 @@ usd_amount=50

# Stop trigger
touch $TRIGGER_STOP_FILE
retry 10 1 trigger_is_stopped || exit 1

# Generate invoice
variables=$(
Expand All @@ -319,7 +320,7 @@ usd_amount=50

# Start trigger
rm $TRIGGER_STOP_FILE
sleep 5
retry 10 1 trigger_is_started

# Pay invoice & check for settled
lnd_outside_cli payinvoice -f \
Expand Down
26 changes: 26 additions & 0 deletions bats/helpers/trigger.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CURRENT_FILE=${BASH_SOURCE:-bats/helpers/.}
source "$(dirname "$CURRENT_FILE")/_common.bash"

TRIGGER_STOP_FILE="$BATS_ROOT_DIR/.stop_trigger"

trigger_is_stopped() {
local NUM_LINES=2
cat $TILT_LOG_FILE | grep 'api-trigger │' \
| tail -n $NUM_LINES \
| grep "Successfully stopped trigger"

return "$?"
}

trigger_is_started() {
local NUM_LINES=18
cat $TILT_LOG_FILE | grep 'api-trigger │' \
| tail -n $NUM_LINES \
| grep "Successfully stopped trigger"

if [[ "$?" == "0" ]]; then
return 1
else
return 0
fi
}

0 comments on commit 7cc4250

Please sign in to comment.