From 889be84e26f8342eb5be6384c62fa6f30e6d047e Mon Sep 17 00:00:00 2001 From: Arvin <17693119+vindard@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:35:24 -0400 Subject: [PATCH] test(refactor): clean up ln-send tests move (#3757) * test(core): refactor retry to not break with bad message * refactor(core): remove 'SVIX_CALLBACK_URL' env variable & add_callback function --- .env | 1 - .env.ci | 1 - bats/helpers/callback.bash | 2 +- bats/helpers/ln.bash | 5 +---- core/api/.env | 1 - core/api/.env.ci | 1 - core/api/test/bats/callback.bats | 2 ++ core/api/test/bats/helpers/setup-and-teardown.bash | 11 ----------- 8 files changed, 4 insertions(+), 20 deletions(-) diff --git a/.env b/.env index 8d2ed9f144..273934a056 100644 --- a/.env +++ b/.env @@ -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" diff --git a/.env.ci b/.env.ci index 3d026eb668..9106424b7f 100644 --- a/.env.ci +++ b/.env.ci @@ -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} diff --git a/bats/helpers/callback.bash b/bats/helpers/callback.bash index d524c261a0..532b3185a9 100644 --- a/bats/helpers/callback.bash +++ b/bats/helpers/callback.bash @@ -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 diff --git a/bats/helpers/ln.bash b/bats/helpers/ln.bash index 3cf7569118..b2671fd715 100644 --- a/bats/helpers/ln.bash +++ b/bats/helpers/ln.bash @@ -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" \ diff --git a/core/api/.env b/core/api/.env index 9e86c86b55..0eaebedf7c 100644 --- a/core/api/.env +++ b/core/api/.env @@ -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" diff --git a/core/api/.env.ci b/core/api/.env.ci index 5110a904bf..b1cb183882 100644 --- a/core/api/.env.ci +++ b/core/api/.env.ci @@ -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} diff --git a/core/api/test/bats/callback.bats b/core/api/test/bats/callback.bats index b054f493eb..e9da0b6c36 100644 --- a/core/api/test/bats/callback.bats +++ b/core/api/test/bats/callback.bats @@ -3,6 +3,8 @@ load "helpers/setup-and-teardown" load "helpers/ln" +SVIX_CALLBACK_URL="http://bats-tests:8080/webhook/" + setup_file() { clear_cache diff --git a/core/api/test/bats/helpers/setup-and-teardown.bash b/core/api/test/bats/helpers/setup-and-teardown.bash index fe37be42be..cd1978c2d2 100644 --- a/core/api/test/bats/helpers/setup-and-teardown.bash +++ b/core/api/test/bats/helpers/setup-and-teardown.bash @@ -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