aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-04-22 22:17:08 +0200
committerFlorian Dold <florian@dold.me>2023-04-22 22:17:08 +0200
commit321252040efdb0712a38b3488297a7a802c5cb59 (patch)
tree0ef4933afe3e8502246183a2e5bcf8c9a1e7c909 /packages
parent15a1b8d0966783033947588cdb27850fe6811405 (diff)
-fix test-exchange-deposit
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts15
-rw-r--r--packages/taler-harness/src/integrationtests/test-bank-api.ts10
-rw-r--r--packages/taler-harness/src/integrationtests/test-exchange-deposit.ts13
-rw-r--r--packages/taler-harness/src/integrationtests/test-tipping.ts15
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts15
-rw-r--r--packages/taler-wallet-core/src/bank-api-client.ts77
6 files changed, 96 insertions, 49 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts
index ff589dd79..561a10e6d 100644
--- a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts
+++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts
@@ -17,7 +17,11 @@
/**
* Imports.
*/
-import { BankApi, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import {
+ BankApi,
+ WalletApiOperation,
+ WireGatewayApiClient,
+} from "@gnu-taler/taler-wallet-core";
import { defaultCoinConfig } from "../harness/denomStructures.js";
import {
getWireMethodForTest,
@@ -158,10 +162,15 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
exchangeBankAccount.accountPaytoUri,
);
- await BankApi.adminAddIncoming(bank, {
+ const wireGatewayApiClient = new WireGatewayApiClient({
+ wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
+ accountName: exchangeBankAccount.accountName,
+ accountPassword: exchangeBankAccount.accountPassword,
+ });
+
+ await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:10",
debitAccountPayto: mbu.accountPaytoUri,
- exchangeBankAccount,
reservePub: tipReserveResp.reserve_pub,
});
diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts
index c7a23d3ce..d97860a2c 100644
--- a/packages/taler-harness/src/integrationtests/test-bank-api.ts
+++ b/packages/taler-harness/src/integrationtests/test-bank-api.ts
@@ -32,6 +32,7 @@ import {
BankApi,
BankAccessApi,
CreditDebitIndicator,
+ WireGatewayApiClient,
} from "@gnu-taler/taler-wallet-core";
/**
@@ -121,10 +122,15 @@ export async function runBankApiTest(t: GlobalTestState) {
const res = createEddsaKeyPair();
- await BankApi.adminAddIncoming(bank, {
+ const wireGatewayApiClient = new WireGatewayApiClient({
+ wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
+ accountName: exchangeBankAccount.accountName,
+ accountPassword: exchangeBankAccount.accountPassword,
+ });
+
+ await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:115",
debitAccountPayto: bankUser.accountPaytoUri,
- exchangeBankAccount: exchangeBankAccount,
reservePub: encodeCrock(res.eddsaPub),
});
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts b/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts
index 7df1047ea..18a3c172a 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts
@@ -59,14 +59,13 @@ export async function runExchangeDepositTest(t: GlobalTestState) {
const reserveKeyPair = await cryptoApi.createEddsaKeypair({});
- await topupReserveWithDemobank(
+ await topupReserveWithDemobank({
http,
- reserveKeyPair.pub,
- bank.baseUrl,
- bank.bankAccessApiBaseUrl,
+ amount: "TESTKUDOS:10",
+ bankAccessApiBaseUrl: bank.bankAccessApiBaseUrl,
exchangeInfo,
- "TESTKUDOS:10",
- );
+ reservePub: reserveKeyPair.pub,
+ });
await exchange.runWirewatchOnce();
@@ -126,7 +125,7 @@ export async function runExchangeDepositTest(t: GlobalTestState) {
});
} catch (e) {
if (e instanceof TalerError && e.errorDetail.code === 7005) {
- if (e.errorDetail.httpStatusCode === 400) {
+ if (e.errorDetail.httpStatusCode === 409) {
console.log("got expected error response from exchange");
console.log(e);
console.log(j2s(e.errorDetail));
diff --git a/packages/taler-harness/src/integrationtests/test-tipping.ts b/packages/taler-harness/src/integrationtests/test-tipping.ts
index d31e0c06b..69afad6fd 100644
--- a/packages/taler-harness/src/integrationtests/test-tipping.ts
+++ b/packages/taler-harness/src/integrationtests/test-tipping.ts
@@ -17,7 +17,11 @@
/**
* Imports.
*/
-import { WalletApiOperation, BankApi } from "@gnu-taler/taler-wallet-core";
+import {
+ WalletApiOperation,
+ BankApi,
+ WireGatewayApiClient,
+} from "@gnu-taler/taler-wallet-core";
import {
GlobalTestState,
MerchantPrivateApi,
@@ -53,10 +57,15 @@ export async function runTippingTest(t: GlobalTestState) {
exchangeBankAccount.accountPaytoUri,
);
- await BankApi.adminAddIncoming(bank, {
+ const wireGatewayApiClient = new WireGatewayApiClient({
+ wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
+ accountName: exchangeBankAccount.accountName,
+ accountPassword: exchangeBankAccount.accountPassword,
+ });
+
+ await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:10",
debitAccountPayto: mbu.accountPaytoUri,
- exchangeBankAccount,
reservePub: tipReserveResp.reserve_pub,
});
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts
index 260972498..4a79d2c21 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts
@@ -19,7 +19,11 @@
*/
import { GlobalTestState } from "../harness/harness.js";
import { createSimpleTestkudosEnvironment } from "../harness/helpers.js";
-import { WalletApiOperation, BankApi } from "@gnu-taler/taler-wallet-core";
+import {
+ WalletApiOperation,
+ BankApi,
+ WireGatewayApiClient,
+} from "@gnu-taler/taler-wallet-core";
import { AbsoluteTime, j2s, Logger } from "@gnu-taler/taler-util";
const logger = new Logger("test-withdrawal-manual.ts");
@@ -65,8 +69,13 @@ export async function runWithdrawalManualTest(t: GlobalTestState) {
const reservePub: string = wres.reservePub;
- await BankApi.adminAddIncoming(bank, {
- exchangeBankAccount,
+ const wireGatewayApiClient = new WireGatewayApiClient({
+ wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
+ accountName: exchangeBankAccount.accountName,
+ accountPassword: exchangeBankAccount.accountPassword,
+ });
+
+ await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:10",
debitAccountPayto: user.accountPaytoUri,
reservePub: reservePub,
diff --git a/packages/taler-wallet-core/src/bank-api-client.ts b/packages/taler-wallet-core/src/bank-api-client.ts
index 33f12172b..94ca2271b 100644
--- a/packages/taler-wallet-core/src/bank-api-client.ts
+++ b/packages/taler-wallet-core/src/bank-api-client.ts
@@ -37,6 +37,7 @@ import {
TalerErrorCode,
} from "@gnu-taler/taler-util";
import {
+ checkSuccessResponseOrThrow,
createPlatformHttpLib,
HttpRequestLibrary,
readSuccessResponseJsonOrThrow,
@@ -97,6 +98,9 @@ const codecForWithdrawalOperationInfo = (): Codec<WithdrawalOperationInfo> =>
.property("taler_withdraw_uri", codecForString())
.build("WithdrawalOperationInfo");
+/**
+ * @deprecated Use BankAccessApiClient or WireGatewayApi
+ */
export namespace BankApi {
// FIXME: Move to BankAccessApi?!
export async function registerAccount(
@@ -142,37 +146,6 @@ export namespace BankApi {
return await registerAccount(bank, username, password);
}
- export async function adminAddIncoming(
- bank: BankServiceHandle,
- params: {
- exchangeBankAccount: HarnessExchangeBankAccount;
- amount: string;
- reservePub: string;
- debitAccountPayto: string;
- },
- ) {
- let url = new URL(
- `taler-wire-gateway/${params.exchangeBankAccount.accountName}/admin/add-incoming`,
- bank.bankAccessApiBaseUrl,
- );
- await bank.http.postJson(
- url.href,
- {
- amount: params.amount,
- reserve_pub: params.reservePub,
- debit_account: params.debitAccountPayto,
- },
- {
- headers: {
- Authorization: makeBasicAuthHeader(
- params.exchangeBankAccount.accountName,
- params.exchangeBankAccount.accountPassword,
- ),
- },
- },
- );
- }
-
export async function confirmWithdrawalOperation(
bank: BankServiceHandle,
bankUser: BankUser,
@@ -227,6 +200,9 @@ export namespace BankApi {
}
}
+/**
+ * @deprecated use BankAccessApiClient
+ */
export namespace BankAccessApi {
export async function getAccountBalance(
bank: BankServiceHandle,
@@ -288,6 +264,45 @@ export interface BankAccessApiCreateTransactionRequest {
paytoUri: string;
}
+export class WireGatewayApiClientArgs {
+ accountName: string;
+ accountPassword: string;
+ wireGatewayApiBaseUrl: string;
+}
+
+export class WireGatewayApiClient {
+ httpLib = createPlatformHttpLib();
+
+ constructor(private args: WireGatewayApiClientArgs) {}
+
+ async adminAddIncoming(params: {
+ amount: string;
+ reservePub: string;
+ debitAccountPayto: string;
+ }): Promise<void> {
+ let url = new URL(
+ `admin/add-incoming`,
+ this.args.wireGatewayApiBaseUrl,
+ );
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "POST",
+ body: {
+ amount: params.amount,
+ reserve_pub: params.reservePub,
+ debit_account: params.debitAccountPayto,
+ },
+ headers: {
+ Authorization: makeBasicAuthHeader(
+ this.args.accountName,
+ this.args.accountPassword,
+ ),
+ },
+ });
+ logger.info(`add-incoming response status: ${resp.status}`);
+ await checkSuccessResponseOrThrow(resp);
+ }
+}
+
export class BankAccessApiClient {
httpLib = createPlatformHttpLib();