Skip to content

Commit

Permalink
test(refactor): clean up ln-send tests move (#3757)
Browse files Browse the repository at this point in the history
* test(core): refactor retry to not break with bad message

* refactor(core): remove 'SVIX_CALLBACK_URL' env variable & add_callback function
  • Loading branch information
vindard authored Dec 27, 2023
1 parent ffef6b2 commit 889be84
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 20 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export UNSECURE_IP_FROM_REQUEST_OBJECT=true

export SVIX_SECRET="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2OTE2NzIwMTQsImV4cCI6MjAwNzAzMjAxNCwibmJmIjoxNjkxNjcyMDE0LCJpc3MiOiJzdml4LXNlcnZlciIsInN1YiI6Im9yZ18yM3JiOFlkR3FNVDBxSXpwZ0d3ZFhmSGlyTXUifQ.b9s0aWSisNdUNki4edabBEToLNSwjC9-AiJQr4J3y4E"
export SVIX_ENDPOINT="http://localhost:8071"
export SVIX_CALLBACK_URL=http://bats-tests:8080/webhook/

export KRATOS_PUBLIC_API="http://localhost:4433"
export KRATOS_ADMIN_API="http://localhost:4434"
Expand Down
1 change: 0 additions & 1 deletion .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ MATTERMOST_WEBHOOK_URL=${MATTERMOST_WEBHOOK_URL}
UNSECURE_DEFAULT_LOGIN_CODE=${UNSECURE_DEFAULT_LOGIN_CODE}
SVIX_SECRET=${SVIX_SECRET}
SVIX_ENDPOINT=http://svix:8071
SVIX_CALLBACK_URL=${SVIX_CALLBACK_URL}

BRIA_API_KEY=${BRIA_API_KEY}

Expand Down
2 changes: 1 addition & 1 deletion bats/helpers/callback.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CURRENT_FILE=${BASH_SOURCE:-bats/helpers/.}
source "$(dirname "$CURRENT_FILE")/_common.bash"

SVIX_CALLBACK_URL=${SVIX_CALLBACK_URL:-"http://bats-tests:8080/webhook/"}
SVIX_CALLBACK_URL="http://bats-tests:8080/webhook/"

add_callback() {
local token_name=$1
Expand Down
5 changes: 1 addition & 4 deletions bats/helpers/ln.bash
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ check_for_ln_update() {
payment_hash=$1

retry 10 1 \
grep "Data.*LnUpdate.*$payment_hash" "$SUBSCRIBER_LOG_FILE" \
| awk '{print $2}' \
| jq -r --arg hash "$payment_hash" 'select(.data.myUpdates.update.paymentHash == $hash)' \
|| exit 1
grep "Data.*LnUpdate.*$payment_hash" "$SUBSCRIBER_LOG_FILE" || exit 1

paid_status=$( \
grep 'Data.*LnUpdate' "$SUBSCRIBER_LOG_FILE" \
Expand Down
1 change: 0 additions & 1 deletion core/api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export UNSECURE_IP_FROM_REQUEST_OBJECT=true

export SVIX_SECRET="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2OTE2NzIwMTQsImV4cCI6MjAwNzAzMjAxNCwibmJmIjoxNjkxNjcyMDE0LCJpc3MiOiJzdml4LXNlcnZlciIsInN1YiI6Im9yZ18yM3JiOFlkR3FNVDBxSXpwZ0d3ZFhmSGlyTXUifQ.b9s0aWSisNdUNki4edabBEToLNSwjC9-AiJQr4J3y4E"
export SVIX_ENDPOINT="http://localhost:8071"
export SVIX_CALLBACK_URL=http://bats-tests:8080/webhook/

export KRATOS_PUBLIC_API="http://localhost:4433"
export KRATOS_ADMIN_API="http://localhost:4434"
Expand Down
1 change: 0 additions & 1 deletion core/api/.env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ MATTERMOST_WEBHOOK_URL=${MATTERMOST_WEBHOOK_URL}
UNSECURE_DEFAULT_LOGIN_CODE=${UNSECURE_DEFAULT_LOGIN_CODE}
SVIX_SECRET=${SVIX_SECRET}
SVIX_ENDPOINT=http://svix:8071
SVIX_CALLBACK_URL=${SVIX_CALLBACK_URL}

BRIA_API_KEY=${BRIA_API_KEY}

Expand Down
2 changes: 2 additions & 0 deletions core/api/test/bats/callback.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
load "helpers/setup-and-teardown"
load "helpers/ln"

SVIX_CALLBACK_URL="http://bats-tests:8080/webhook/"

setup_file() {
clear_cache

Expand Down
11 changes: 0 additions & 11 deletions core/api/test/bats/helpers/setup-and-teardown.bash
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ subscribe_to() {
echo $! > $SUBSCRIBER_PID_FILE
}

add_callback() {
local token_name=$1

local variables=$(
jq -n \
--arg url "$SVIX_CALLBACK_URL" \
'{input: {url: $url}}'
)
exec_graphql "$token_name" 'callback-endpoint-add' "$variables"
}

start_ws_server() {
stop_ws_server > /dev/null 2>&1 || true

Expand Down

0 comments on commit 889be84

Please sign in to comment.