Skip to content

Commit

Permalink
fix: bats tests query/subscription by request
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Feb 12, 2024
1 parent ab07d54 commit 1d374db
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions bats/core/api/public-ln-receive.bats
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ usd_amount=50
--arg payment_request "$payment_request" \
'{input: {paymentRequest: $payment_request}}'
)
subscribe_to 'anon' 'ln-invoice-payment-status-sub' "$variables"
subscribe_to 'anon' 'ln-invoice-payment-status-by-request-sub' "$variables"
sleep 3
retry 10 1 grep "Data.*lnInvoicePaymentStatus.*PENDING" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatus.*$payment_hash" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatus.*$payment_request" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatusByRequest.*PENDING" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatusByRequest.*$payment_hash" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatusByRequest.*$payment_request" "$SUBSCRIBER_LOG_FILE"

# Receive payment
lnd_outside_cli payinvoice -f \
--pay_req "$payment_request" \

# Check for settled with subscriptions
retry 10 1 grep "Data.*lnInvoicePaymentStatus.*PAID" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatus.*$payment_hash" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatus.*$payment_request" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatusByRequest.*PAID" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatusByRequest.*$payment_hash" "$SUBSCRIBER_LOG_FILE"
retry 10 1 grep "Data.*lnInvoicePaymentStatusByRequest.*$payment_request" "$SUBSCRIBER_LOG_FILE"
stop_subscriber
}

Expand Down
10 changes: 10 additions & 0 deletions bats/gql/ln-invoice-payment-status-by-request-sub.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
subscription lnInvoicePaymentStatusByRequestSubscription($input: LnInvoicePaymentStatusByRequestInput!) {
lnInvoicePaymentStatusByRequest(input: $input) {
errors {
message
}
status
paymentHash
paymentRequest
}
}
7 changes: 7 additions & 0 deletions bats/gql/ln-invoice-payment-status-by-request.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query LnInvoicePaymentStatusByRequestQuery($input: LnInvoicePaymentStatusByRequestInput!) {
lnInvoicePaymentStatusByRequest(input: $input) {
status
paymentHash
paymentRequest
}
}
10 changes: 0 additions & 10 deletions bats/gql/ln-invoice-payment-status-sub.gql

This file was deleted.

7 changes: 0 additions & 7 deletions bats/gql/ln-invoice-payment-status.gql

This file was deleted.

8 changes: 4 additions & 4 deletions bats/helpers/ln.bash
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ check_ln_payment_settled() {
--arg payment_request "$payment_request" \
'{"input": {"paymentRequest": $payment_request}}'
)
exec_graphql 'anon' 'ln-invoice-payment-status' "$variables"
payment_status="$(graphql_output '.data.lnInvoicePaymentStatus.status')"
payment_request_resp="$(graphql_output '.data.lnInvoicePaymentStatus.paymentRequest')"
payment_hash_resp="$(graphql_output '.data.lnInvoicePaymentStatus.paymentHash')"
exec_graphql 'anon' 'ln-invoice-payment-status-by-request' "$variables"
payment_status="$(graphql_output '.data.lnInvoicePaymentStatusByRequest.status')"
payment_request_resp="$(graphql_output '.data.lnInvoicePaymentStatusByRequest.paymentRequest')"
payment_hash_resp="$(graphql_output '.data.lnInvoicePaymentStatusByRequest.paymentHash')"
[[ "${payment_hash}" = "${payment_hash_resp}" ]] || exit 1
[[ "${payment_request}" = "${payment_request_resp}" ]] || exit 1
[[ "${payment_status}" = "PAID" ]]
Expand Down

0 comments on commit 1d374db

Please sign in to comment.