diff --git a/core/api/test/bats/transactions.bats b/bats/core/api/transactions.bats similarity index 88% rename from core/api/test/bats/transactions.bats rename to bats/core/api/transactions.bats index 0c61cfdd78..b8f14a49c7 100644 --- a/core/api/test/bats/transactions.bats +++ b/bats/core/api/transactions.bats @@ -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() { @@ -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}' @@ -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[]' @@ -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" diff --git a/bats/gql/transactions-by-wallet.gql b/bats/gql/transactions-by-wallet.gql new file mode 100644 index 0000000000..494cbb3d96 --- /dev/null +++ b/bats/gql/transactions-by-wallet.gql @@ -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 + } + } + } + } +} diff --git a/bats/gql/transactions.gql b/bats/gql/transactions.gql index 5e6ee06eb7..5955d7a311 100644 --- a/bats/gql/transactions.gql +++ b/bats/gql/transactions.gql @@ -42,6 +42,7 @@ fragment TransactionList on TransactionConnection { } ... on InitiationViaLn { paymentHash + paymentRequest } ... on InitiationViaOnChain { address