Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: e2e, add new public-ln-receive.bats #3657

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions bats/core/api/public-ln-receive.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bats

load "../../helpers/user.bash"
load "../../helpers/onchain.bash"
load "../../helpers/_common.bash"

setup_file() {
create_user 'alice'
user_update_username 'alice'
fund_user_onchain 'alice' 'btc_wallet'
fund_user_onchain 'alice' 'usd_wallet'
}

btc_amount=1000
usd_amount=50

@test "public-ln-receive: account details - can fetch with btc default wallet-id from username" {
btc_wallet_name="alice.btc_wallet_id"
usd_wallet_name="alice.usd_wallet_id"

# Change default wallet to btc
variables=$(
jq -n \
--arg wallet_id "$(read_value $btc_wallet_name)" \
'{input: {walletId: $wallet_id}}'
)
exec_graphql 'alice' 'account-update-default-wallet-id' "$variables"
updated_wallet_id="$(graphql_output '.data.accountUpdateDefaultWalletId.account.defaultWalletId')"
[[ "$updated_wallet_id" == "$(read_value $btc_wallet_name)" ]] || exit 1

# Fetch btc-wallet-id from username
variables=$(
jq -n \
--arg username 'alice' \
'{username: $username}'
)
exec_graphql 'anon' 'account-default-wallet' "$variables"
receiver_wallet_id="$(graphql_output '.data.accountDefaultWallet.id')"
[[ "$receiver_wallet_id" == "$(read_value $btc_wallet_name)" ]] || exit 1

# Fetch usd-wallet-id from username
variables=$(
jq -n \
--arg username 'alice' \
'{username: $username, walletCurrency: "USD"}'
)
exec_graphql 'anon' 'account-default-wallet' "$variables"
receiver_wallet_id="$(graphql_output '.data.accountDefaultWallet.id')"
[[ "$receiver_wallet_id" == "$(read_value $usd_wallet_name)" ]] || exit 1
}
6 changes: 6 additions & 0 deletions bats/gql/account-default-wallet.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query accountDefaultWallet($username: Username!, $walletCurrency: WalletCurrency) {
accountDefaultWallet(username: $username, walletCurrency: $walletCurrency) {
id
walletCurrency
}
}
7 changes: 7 additions & 0 deletions bats/gql/account-update-default-wallet-id.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation accountUpdateDefaultWalletId($input: AccountUpdateDefaultWalletIdInput!) {
accountUpdateDefaultWalletId(input: $input) {
account {
defaultWalletId
}
}
}
13 changes: 13 additions & 0 deletions bats/gql/ln-invoice-create-on-behalf-of-recipient.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mutation lnInvoiceCreateOnBehalfOfRecipient(
$input: LnInvoiceCreateOnBehalfOfRecipientInput!
) {
lnInvoiceCreateOnBehalfOfRecipient(input: $input) {
invoice {
paymentRequest
paymentHash
}
errors {
message
}
}
}
13 changes: 13 additions & 0 deletions bats/gql/ln-no-amount-invoice-create-on-behalf-of-recipient.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mutation lnNoAmountInvoiceCreateOnBehalfOfRecipient(
$input: LnNoAmountInvoiceCreateOnBehalfOfRecipientInput!
) {
lnNoAmountInvoiceCreateOnBehalfOfRecipient(input: $input) {
invoice {
paymentRequest
paymentHash
}
errors {
message
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mutation lnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipient(
$input: LnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipientInput!
) {
lnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipient(input: $input) {
invoice {
paymentRequest
paymentHash
}
errors {
message
}
}
}
13 changes: 13 additions & 0 deletions bats/gql/ln-usd-invoice-create-on-behalf-of-recipient.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mutation lnUsdInvoiceCreateOnBehalfOfRecipient(
$input: LnUsdInvoiceCreateOnBehalfOfRecipientInput!
) {
lnUsdInvoiceCreateOnBehalfOfRecipient(input: $input) {
invoice {
paymentRequest
paymentHash
}
errors {
message
}
}
}
2 changes: 1 addition & 1 deletion bats/helpers/_common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ cache_value() {

read_value() {
cat ${CACHE_DIR}/$1
}
}
8 changes: 8 additions & 0 deletions bats/helpers/cli.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ lnd_cli() {
$@
}

lnd_outside_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-lnd-outside-1-1" \
lncli \
--macaroonpath /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon \
--tlscertpath /root/.lnd/tls.cert \
$@
}

bria_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria $@
}
Expand Down
2 changes: 1 addition & 1 deletion bats/helpers/ln.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ create_new_lnd_onchain_address() {
insert_lnd1_address "$wallet_id" "$address" > /dev/null

echo $address
}
}
Loading