From 0a84c19993558ac7fcb00e90158f306703a8c656 Mon Sep 17 00:00:00 2001 From: vindard <17693119+vindard@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:10:40 -0400 Subject: [PATCH] temp: debug callbacks --- .github/workflows/bats.yml | 2 +- bats/core/api/ln-receive.bats | 268 +++++++++++++++++----------------- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/.github/workflows/bats.yml b/.github/workflows/bats.yml index ebbebc0fe28..7795689f71f 100644 --- a/.github/workflows/bats.yml +++ b/.github/workflows/bats.yml @@ -21,7 +21,7 @@ jobs: //core/api-keys //apps/dashboard //apps/consent //apps/pay - name: Run bats tests run: | - nix develop -c bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/** + nix develop -c bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/api/ln-receive.bat - name: Upload Tilt log if: always() uses: actions/upload-artifact@v2 diff --git a/bats/core/api/ln-receive.bats b/bats/core/api/ln-receive.bats index 1fceebf840c..e5da6ccc1f7 100644 --- a/bats/core/api/ln-receive.bats +++ b/bats/core/api/ln-receive.bats @@ -125,137 +125,137 @@ usd_amount=50 [[ "$num_callback_events_after" -gt "$num_callback_events_before" ]] || exit 1 } -@test "ln-receive: settle via ln for USD wallet, invoice with amount" { - # Generate invoice - token_name="$ALICE" - usd_wallet_name="$token_name.usd_wallet_id" - - variables=$( - jq -n \ - --arg wallet_id "$(read_value $usd_wallet_name)" \ - --arg amount "$usd_amount" \ - '{input: {walletId: $wallet_id, amount: $amount}}' - ) - exec_graphql "$token_name" 'ln-usd-invoice-create' "$variables" - invoice="$(graphql_output '.data.lnUsdInvoiceCreate.invoice')" - - payment_request="$(echo $invoice | jq -r '.paymentRequest')" - [[ "${payment_request}" != "null" ]] || exit 1 - payment_hash="$(echo $invoice | jq -r '.paymentHash')" - [[ "${payment_hash}" != "null" ]] || exit 1 - - # Receive payment - lnd_outside_cli payinvoice -f \ - --pay_req "$payment_request" - - # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - - # Check for subscriber event - check_for_ln_update "$payment_hash" || exit 1 -} - -@test "ln-receive: settle via ln for BTC wallet, amountless invoice" { - token_name="$ALICE" - btc_wallet_name="$token_name.btc_wallet_id" - - # Generate invoice - variables=$( - jq -n \ - --arg wallet_id "$(read_value $btc_wallet_name)" \ - '{input: {walletId: $wallet_id}}' - ) - exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$variables" - invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" - - payment_request="$(echo $invoice | jq -r '.paymentRequest')" - [[ "${payment_request}" != "null" ]] || exit 1 - payment_hash="$(echo $invoice | jq -r '.paymentHash')" - [[ "${payment_hash}" != "null" ]] || exit 1 - - # Receive payment - lnd_outside_cli payinvoice -f \ - --pay_req "$payment_request" \ - --amt "$btc_amount" - - # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - - # Check for subscriber event - check_for_ln_update "$payment_hash" || exit 1 -} - -@test "ln-receive: handle less-than-1-sat ln payment for BTC wallet" { - token_name="$ALICE" - btc_wallet_name="$token_name.btc_wallet_id" - - # Generate amountless invoice - invoice_variables=$( - jq -n \ - --arg wallet_id "$(read_value $btc_wallet_name)" \ - '{input: {walletId: $wallet_id}}' - ) - exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$invoice_variables" - invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" - - payment_request="$(echo $invoice | jq -r '.paymentRequest')" - [[ "${payment_request}" != "null" ]] || exit 1 - payment_hash="$(echo $invoice | jq -r '.paymentHash')" - [[ "${payment_hash}" != "null" ]] || exit 1 - - # Check that invoice is retrievable from lnd1 - invoice_from_lnd=$(lnd_cli lookupinvoice "$payment_hash") - [[ -n $invoice_from_lnd ]] || exit 1 - - # Receive less-than-1-sat payment - pay_variables=$( - jq -n \ - --arg payment_request "$payment_request" \ - --arg amt_msat "995" \ - --arg timeout_seconds "5" \ - '{payment_request: $payment_request, amt_msat: $amt_msat, timeout_seconds: $timeout_seconds}'\ - | tr -d '[:space:]') - lnd_outside_rest "v2/router/send" "$pay_variables" - - # Check that payment fails - response=$(tail -n 1 "$LNDS_REST_LOG") - [[ -n $response ]] || exit 1 - pay_status=$(echo $response | jq -r '.result.status') - [[ "$pay_status" == "FAILED" ]] || exit 1 - failure_reason=$(echo $response | jq -r '.result.failure_reason') - [[ "$failure_reason" == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" ]] || exit 1 - - # Check that invoice is removed from lnd1 - invoice_from_lnd=$(lnd_cli lookupinvoice "$payment_hash") || true - [[ -z $invoice_from_lnd ]] || exit 1 -} - -@test "ln-receive: settle via ln for USD wallet, amountless invoice" { - # Generate invoice - token_name="$ALICE" - usd_wallet_name="$token_name.usd_wallet_id" - - variables=$( - jq -n \ - --arg wallet_id "$(read_value $usd_wallet_name)" \ - '{input: {walletId: $wallet_id}}' - ) - exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$variables" - invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" - - payment_request="$(echo $invoice | jq -r '.paymentRequest')" - [[ "${payment_request}" != "null" ]] || exit 1 - payment_hash="$(echo $invoice | jq -r '.paymentHash')" - [[ "${payment_hash}" != "null" ]] || exit 1 - - # Receive payment - lnd_outside_cli payinvoice -f \ - --pay_req "$payment_request" \ - --amt "$btc_amount" - - # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - - # Check for subscriber event - check_for_ln_update "$payment_hash" || exit 1 -} +# @test "ln-receive: settle via ln for USD wallet, invoice with amount" { +# # Generate invoice +# token_name="$ALICE" +# usd_wallet_name="$token_name.usd_wallet_id" + +# variables=$( +# jq -n \ +# --arg wallet_id "$(read_value $usd_wallet_name)" \ +# --arg amount "$usd_amount" \ +# '{input: {walletId: $wallet_id, amount: $amount}}' +# ) +# exec_graphql "$token_name" 'ln-usd-invoice-create' "$variables" +# invoice="$(graphql_output '.data.lnUsdInvoiceCreate.invoice')" + +# payment_request="$(echo $invoice | jq -r '.paymentRequest')" +# [[ "${payment_request}" != "null" ]] || exit 1 +# payment_hash="$(echo $invoice | jq -r '.paymentHash')" +# [[ "${payment_hash}" != "null" ]] || exit 1 + +# # Receive payment +# lnd_outside_cli payinvoice -f \ +# --pay_req "$payment_request" + +# # Check for settled +# retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + +# # Check for subscriber event +# check_for_ln_update "$payment_hash" || exit 1 +# } + +# @test "ln-receive: settle via ln for BTC wallet, amountless invoice" { +# token_name="$ALICE" +# btc_wallet_name="$token_name.btc_wallet_id" + +# # Generate invoice +# variables=$( +# jq -n \ +# --arg wallet_id "$(read_value $btc_wallet_name)" \ +# '{input: {walletId: $wallet_id}}' +# ) +# exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$variables" +# invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + +# payment_request="$(echo $invoice | jq -r '.paymentRequest')" +# [[ "${payment_request}" != "null" ]] || exit 1 +# payment_hash="$(echo $invoice | jq -r '.paymentHash')" +# [[ "${payment_hash}" != "null" ]] || exit 1 + +# # Receive payment +# lnd_outside_cli payinvoice -f \ +# --pay_req "$payment_request" \ +# --amt "$btc_amount" + +# # Check for settled +# retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + +# # Check for subscriber event +# check_for_ln_update "$payment_hash" || exit 1 +# } + +# @test "ln-receive: handle less-than-1-sat ln payment for BTC wallet" { +# token_name="$ALICE" +# btc_wallet_name="$token_name.btc_wallet_id" + +# # Generate amountless invoice +# invoice_variables=$( +# jq -n \ +# --arg wallet_id "$(read_value $btc_wallet_name)" \ +# '{input: {walletId: $wallet_id}}' +# ) +# exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$invoice_variables" +# invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + +# payment_request="$(echo $invoice | jq -r '.paymentRequest')" +# [[ "${payment_request}" != "null" ]] || exit 1 +# payment_hash="$(echo $invoice | jq -r '.paymentHash')" +# [[ "${payment_hash}" != "null" ]] || exit 1 + +# # Check that invoice is retrievable from lnd1 +# invoice_from_lnd=$(lnd_cli lookupinvoice "$payment_hash") +# [[ -n $invoice_from_lnd ]] || exit 1 + +# # Receive less-than-1-sat payment +# pay_variables=$( +# jq -n \ +# --arg payment_request "$payment_request" \ +# --arg amt_msat "995" \ +# --arg timeout_seconds "5" \ +# '{payment_request: $payment_request, amt_msat: $amt_msat, timeout_seconds: $timeout_seconds}'\ +# | tr -d '[:space:]') +# lnd_outside_rest "v2/router/send" "$pay_variables" + +# # Check that payment fails +# response=$(tail -n 1 "$LNDS_REST_LOG") +# [[ -n $response ]] || exit 1 +# pay_status=$(echo $response | jq -r '.result.status') +# [[ "$pay_status" == "FAILED" ]] || exit 1 +# failure_reason=$(echo $response | jq -r '.result.failure_reason') +# [[ "$failure_reason" == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" ]] || exit 1 + +# # Check that invoice is removed from lnd1 +# invoice_from_lnd=$(lnd_cli lookupinvoice "$payment_hash") || true +# [[ -z $invoice_from_lnd ]] || exit 1 +# } + +# @test "ln-receive: settle via ln for USD wallet, amountless invoice" { +# # Generate invoice +# token_name="$ALICE" +# usd_wallet_name="$token_name.usd_wallet_id" + +# variables=$( +# jq -n \ +# --arg wallet_id "$(read_value $usd_wallet_name)" \ +# '{input: {walletId: $wallet_id}}' +# ) +# exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$variables" +# invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + +# payment_request="$(echo $invoice | jq -r '.paymentRequest')" +# [[ "${payment_request}" != "null" ]] || exit 1 +# payment_hash="$(echo $invoice | jq -r '.paymentHash')" +# [[ "${payment_hash}" != "null" ]] || exit 1 + +# # Receive payment +# lnd_outside_cli payinvoice -f \ +# --pay_req "$payment_request" \ +# --amt "$btc_amount" + +# # Check for settled +# retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + +# # Check for subscriber event +# check_for_ln_update "$payment_hash" || exit 1 +# }