Skip to content

Commit

Permalink
test(core): move transactions bats tests (#3799)
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard authored Jan 9, 2024
1 parent 4afff9a commit ad10d03
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
#!/usr/bin/env bats

load "helpers/setup-and-teardown"
load "../../helpers/_common.bash"
load "../../helpers/onchain.bash"
load "../../helpers/user.bash"

setup_file() {
clear_cache
reset_redis

bitcoind_init
start_trigger
start_server

initialize_user_from_onchain "$ALICE_TOKEN_NAME" "$ALICE_PHONE" "$CODE"
}

teardown_file() {
stop_trigger
stop_server
create_user 'alice'
fund_user_onchain 'alice' 'btc_wallet'
fund_user_onchain 'alice' 'usd_wallet'
}

count_transactions_by_currency() {
Expand All @@ -36,7 +30,7 @@ currency_for_wallet() {
}

@test "transactions: by account" {
token_name="$ALICE_TOKEN_NAME"
token_name='alice'
account_transactions_query='.data.me.defaultAccount.transactions.edges[]'

exec_graphql "$token_name" 'transactions' '{"first": 3}'
Expand All @@ -53,7 +47,7 @@ currency_for_wallet() {
}

@test "transactions: by account, filtered by wallet" {
token_name="$ALICE_TOKEN_NAME"
token_name='alice'
usd_wallet_name="$token_name.usd_wallet_id"
account_transactions_query='.data.me.defaultAccount.transactions.edges[]'

Expand All @@ -76,7 +70,7 @@ currency_for_wallet() {
}

@test "transactions: by wallet" {
token_name="$ALICE_TOKEN_NAME"
token_name='alice'
btc_wallet_name="$token_name.btc_wallet_id"
usd_wallet_name="$token_name.usd_wallet_id"

Expand Down
79 changes: 79 additions & 0 deletions bats/gql/transactions-by-wallet.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
query transactionsByWallet($first: Int, $after: String) {
me {
defaultAccount {
displayCurrency
wallets {
... on BTCWallet {
__typename
id
walletCurrency
transactions(first: $first, after: $after) {
...TransactionList
}
}
... on UsdWallet {
__typename
id
walletCurrency
transactions(first: $first, after: $after) {
...TransactionList
}
}
}
}
}
}

fragment TransactionList on TransactionConnection {
pageInfo {
hasNextPage
}
edges {
cursor
node {
__typename
id
status
direction
memo
createdAt
settlementAmount
settlementFee
settlementDisplayAmount
settlementDisplayFee
settlementDisplayCurrency
settlementCurrency
settlementPrice {
base
offset
}
initiationVia {
__typename
... on InitiationViaIntraLedger {
counterPartyWalletId
counterPartyUsername
}
... on InitiationViaLn {
paymentHash
paymentRequest
}
... on InitiationViaOnChain {
address
}
}
settlementVia {
__typename
... on SettlementViaIntraLedger {
counterPartyWalletId
counterPartyUsername
}
... on SettlementViaLn {
preImage
}
... on SettlementViaOnChain {
transactionHash
}
}
}
}
}
1 change: 1 addition & 0 deletions bats/gql/transactions.gql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fragment TransactionList on TransactionConnection {
}
... on InitiationViaLn {
paymentHash
paymentRequest
}
... on InitiationViaOnChain {
address
Expand Down

0 comments on commit ad10d03

Please sign in to comment.