aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-06-17 13:34:59 +0200
committerFlorian Dold <florian@dold.me>2021-06-17 13:35:08 +0200
commit5df7ddba97aa4482c781bfe8e87f60c3bc195ae4 (patch)
tree0956d310a83f0fafbb7d5a93001566f9035269a0
parent0b4976601fe2ecb0462fe72ae188b5cbba06d9cc (diff)
use the new wallet core API interface in all tests
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/harness.ts256
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/helpers.ts21
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-claim-loop.ts3
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-deposit.ts19
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts49
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts5
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts26
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-merchant-exchange-confusion.ts19
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-merchant-longpolling.ts20
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-merchant-refund-api.ts44
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts19
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts29
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-claim.ts18
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts23
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-forgettable.ts2
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-idempotency.ts31
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts10
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts29
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-paywall-flow.ts37
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts14
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts18
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-refund-incremental.ts26
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-refund.ts26
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-revocation.ts21
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts11
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-timetravel-withdraw.ts6
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-tipping.ts12
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts40
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts46
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts11
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-withdrawal-abort-bank.ts22
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-withdrawal-bank-integrated.ts11
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-withdrawal-manual.ts14
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts26
-rw-r--r--packages/taler-wallet-core/src/wallet.ts2
35 files changed, 462 insertions, 504 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts b/packages/taler-wallet-cli/src/integrationtests/harness.ts
index b0a538a72..ffaffca1a 100644
--- a/packages/taler-wallet-cli/src/integrationtests/harness.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts
@@ -51,6 +51,8 @@ import {
getRandomBytes,
openPromise,
OperationFailedError,
+ WalletApiOperation,
+ WalletCoreApiClient,
} from "@gnu-taler/taler-wallet-core";
import {
AmountJson,
@@ -1624,6 +1626,7 @@ function shellWrap(s: string) {
export class WalletCli {
private currentTimetravel: Duration | undefined;
+ private _client: WalletCoreApiClient;
setTimetravel(d: Duration | undefined) {
this.currentTimetravel = d;
@@ -1640,7 +1643,29 @@ export class WalletCli {
constructor(
private globalTestState: GlobalTestState,
private name: string = "default",
- ) {}
+ ) {
+ const self = this;
+ this._client = {
+ async call(op: any, payload: any): Promise<any> {
+ const resp = await sh(
+ self.globalTestState,
+ `wallet-${self.name}`,
+ `taler-wallet-cli ${
+ self.timetravelArg ?? ""
+ } --no-throttle --wallet-db '${self.dbfile}' api '${op}' ${shellWrap(
+ JSON.stringify(payload),
+ )}`,
+ );
+ console.log(resp);
+ const ar = JSON.parse(resp) as CoreApiResponse;
+ if (ar.type === "error") {
+ throw new OperationFailedError(ar.error);
+ } else {
+ return ar.result;
+ }
+ },
+ };
+ }
get dbfile(): string {
return this.globalTestState.testDir + `/walletdb-${this.name}.json`;
@@ -1658,21 +1683,8 @@ export class WalletCli {
return [];
}
- async apiRequest(
- request: string,
- payload: unknown,
- ): Promise<CoreApiResponse> {
- const resp = await sh(
- this.globalTestState,
- `wallet-${this.name}`,
- `taler-wallet-cli ${
- this.timetravelArg ?? ""
- } --no-throttle --wallet-db '${this.dbfile}' api '${request}' ${shellWrap(
- JSON.stringify(payload),
- )}`,
- );
- console.log(resp);
- return JSON.parse(resp) as CoreApiResponse;
+ get client(): WalletCoreApiClient {
+ return this._client;
}
async runUntilDone(args: { maxRetries?: number } = {}): Promise<void> {
@@ -1705,216 +1717,4 @@ export class WalletCli {
],
);
}
-
- async applyRefund(req: ApplyRefundRequest): Promise<ApplyRefundResponse> {
- const resp = await this.apiRequest("applyRefund", req);
- if (resp.type === "response") {
- return codecForApplyRefundResponse().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async preparePay(req: PreparePayRequest): Promise<PreparePayResult> {
- const resp = await this.apiRequest("preparePay", req);
- if (resp.type === "response") {
- return codecForPreparePayResult().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async createDepositGroup(
- req: CreateDepositGroupRequest,
- ): Promise<CreateDepositGroupResponse> {
- const resp = await this.apiRequest("createDepositGroup", req);
- if (resp.type === "response") {
- return resp.result as CreateDepositGroupResponse;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async abortFailedPayWithRefund(
- req: AbortPayWithRefundRequest,
- ): Promise<void> {
- const resp = await this.apiRequest("abortFailedPayWithRefund", req);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async confirmPay(req: ConfirmPayRequest): Promise<ConfirmPayResult> {
- const resp = await this.apiRequest("confirmPay", req);
- if (resp.type === "response") {
- return codecForConfirmPayResult().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async prepareTip(req: PrepareTipRequest): Promise<PrepareTipResult> {
- const resp = await this.apiRequest("prepareTip", req);
- if (resp.type === "response") {
- return codecForPrepareTipResult().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async acceptTip(req: AcceptTipRequest): Promise<void> {
- const resp = await this.apiRequest("acceptTip", req);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async dumpCoins(): Promise<CoinDumpJson> {
- const resp = await this.apiRequest("dumpCoins", {});
- if (resp.type === "response") {
- return codecForAny().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async addExchange(req: AddExchangeRequest): Promise<void> {
- const resp = await this.apiRequest("addExchange", req);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async forceUpdateExchange(req: ForceExchangeUpdateRequest): Promise<void> {
- const resp = await this.apiRequest("addExchange", {
- exchangeBaseUrl: req.exchangeBaseUrl,
- forceUpdate: true,
- });
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async forceRefresh(req: ForceRefreshRequest): Promise<void> {
- const resp = await this.apiRequest("forceRefresh", req);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async listExchanges(): Promise<ExchangesListRespose> {
- const resp = await this.apiRequest("listExchanges", {});
- if (resp.type === "response") {
- return codecForExchangesListResponse().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async getBalances(): Promise<BalancesResponse> {
- const resp = await this.apiRequest("getBalances", {});
- if (resp.type === "response") {
- return codecForBalancesResponse().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async getPendingOperations(): Promise<PendingOperationsResponse> {
- const resp = await this.apiRequest("getPendingOperations", {});
- if (resp.type === "response") {
- // FIXME: validate properly!
- return codecForAny().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async getTransactions(): Promise<TransactionsResponse> {
- const resp = await this.apiRequest("getTransactions", {});
- if (resp.type === "response") {
- return codecForTransactionsResponse().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async trackDepositGroup(
- req: TrackDepositGroupRequest,
- ): Promise<TrackDepositGroupResponse> {
- const resp = await this.apiRequest("trackDepositGroup", req);
- if (resp.type === "response") {
- return resp.result as TrackDepositGroupResponse;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async runIntegrationTest(args: IntegrationTestArgs): Promise<void> {
- const resp = await this.apiRequest("runIntegrationTest", args);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async testPay(args: TestPayArgs): Promise<void> {
- const resp = await this.apiRequest("testPay", args);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async withdrawTestBalance(args: WithdrawTestBalanceRequest): Promise<void> {
- const resp = await this.apiRequest("withdrawTestBalance", args);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async getWithdrawalDetailsForUri(
- req: GetWithdrawalDetailsForUriRequest,
- ): Promise<WithdrawUriInfoResponse> {
- const resp = await this.apiRequest("getWithdrawalDetailsForUri", req);
- if (resp.type === "response") {
- return codecForWithdrawUriInfoResponse().decode(resp.result);
- }
- throw new OperationFailedError(resp.error);
- }
-
- async addBackupProvider(req: AddBackupProviderRequest): Promise<void> {
- const resp = await this.apiRequest("addBackupProvider", req);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async getBackupInfo(): Promise<BackupInfo> {
- const resp = await this.apiRequest("getBackupInfo", {});
- if (resp.type === "response") {
- return resp.result as BackupInfo;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async exportBackupRecovery(): Promise<BackupRecovery> {
- const resp = await this.apiRequest("exportBackupRecovery", {});
- if (resp.type === "response") {
- return resp.result as BackupRecovery;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async importBackupRecovery(req: RecoveryLoadRequest): Promise<void> {
- const resp = await this.apiRequest("importBackupRecovery", req);
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
-
- async runBackupCycle(): Promise<void> {
- const resp = await this.apiRequest("runBackupCycle", {});
- if (resp.type === "response") {
- return;
- }
- throw new OperationFailedError(resp.error);
- }
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/helpers.ts b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
index ab8939eeb..aa9164c19 100644
--- a/packages/taler-wallet-cli/src/integrationtests/helpers.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
@@ -50,6 +50,7 @@ import {
MerchantPrivateApi,
HarnessExchangeBankAccount,
} from "./harness.js";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
export interface SimpleTestEnvironment {
commonDb: DbInfo;
@@ -265,10 +266,9 @@ export async function startWithdrawViaBank(
// Hand it to the wallet
- const r1 = await wallet.apiRequest("getWithdrawalDetailsForUri", {
+ await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r1.type === "response");
await wallet.runPending();
@@ -278,11 +278,10 @@ export async function startWithdrawViaBank(
// Withdraw
- const r2 = await wallet.apiRequest("acceptBankIntegratedWithdrawal", {
+ await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
exchangeBaseUrl: exchange.baseUrl,
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r2.type === "response");
}
/**
@@ -305,8 +304,7 @@ export async function withdrawViaBank(
// Check balance
- const balApiResp = await wallet.apiRequest("getBalances", {});
- t.assertTrue(balApiResp.type === "response");
+ await wallet.client.call(WalletApiOperation.GetBalances, {});
}
export async function applyTimeTravel(
@@ -365,15 +363,18 @@ export async function makeTestPayment(
// Make wallet pay for the order
- const preparePayResult = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
- });
+ const preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- const r2 = await wallet.confirmPay({
+ const r2 = await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-claim-loop.ts b/packages/taler-wallet-cli/src/integrationtests/test-claim-loop.ts
index 4a4cd555b..46882d5c4 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-claim-loop.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-claim-loop.ts
@@ -20,6 +20,7 @@
import { GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { URL } from "url";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for the merchant's order lifecycle.
@@ -61,7 +62,7 @@ export async function runClaimLoopTest(t: GlobalTestState) {
// Make wallet claim the unpaid order.
t.assertTrue(orderStatusBefore.order_status === "unpaid");
const talerPayUri = orderStatusBefore.taler_pay_uri;
- const y = await wallet.preparePay({
+ await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri,
});
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-deposit.ts b/packages/taler-wallet-cli/src/integrationtests/test-deposit.ts
index 905cf8af5..585ca9996 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-deposit.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-deposit.ts
@@ -17,6 +17,7 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
@@ -39,14 +40,20 @@ export async function runDepositTest(t: GlobalTestState) {
await wallet.runUntilDone();
- const { depositGroupId } = await wallet.createDepositGroup({
- amount: "TESTKUDOS:10",
- depositPaytoUri: "payto://x-taler-bank/localhost/foo",
- });
+ const { depositGroupId } = await wallet.client.call(
+ WalletApiOperation.CreateDepositGroup,
+ {
+ amount: "TESTKUDOS:10",
+ depositPaytoUri: "payto://x-taler-bank/localhost/foo",
+ },
+ );
await wallet.runUntilDone();
- const transactions = await wallet.getTransactions();
+ const transactions = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {},
+ );
console.log("transactions", JSON.stringify(transactions, undefined, 2));
t.assertDeepEqual(transactions.transactions[0].type, "withdrawal");
t.assertDeepEqual(transactions.transactions[1].type, "deposit");
@@ -54,7 +61,7 @@ export async function runDepositTest(t: GlobalTestState) {
// deposit and wire fees.
t.assertDeepEqual(transactions.transactions[1].amountRaw, "TESTKUDOS:9.79");
- const trackResult = wallet.trackDepositGroup({
+ const trackResult = wallet.client.call(WalletApiOperation.TrackDepositGroup, {
depositGroupId,
});
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts b/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
index c2494be93..4f3446f79 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
@@ -27,7 +27,7 @@ import {
BankApi,
BankAccessApi,
} from "./harness";
-import { URL } from "@gnu-taler/taler-wallet-core";
+import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { ExchangesListRespose, TalerErrorCode } from "@gnu-taler/taler-util";
import {
FaultInjectedExchangeService,
@@ -116,24 +116,33 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
let exchangesList: ExchangesListRespose;
- exchangesList = await wallet.listExchanges();
+ exchangesList = await wallet.client.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
t.assertTrue(exchangesList.exchanges.length === 0);
// Try before fault is injected
- await wallet.addExchange({
+ await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: faultyExchange.baseUrl,
});
- exchangesList = await wallet.listExchanges();
+ exchangesList = await wallet.client.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
t.assertTrue(exchangesList.exchanges.length === 1);
- await wallet.addExchange({
+ await wallet.client.call(WalletApiOperation.ListExchanges, {
exchangeBaseUrl: faultyExchange.baseUrl,
});
console.log("listing exchanges");
- exchangesList = await wallet.listExchanges();
+ exchangesList = await wallet.client.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
t.assertTrue(exchangesList.exchanges.length === 1);
console.log("got list", exchangesList);
@@ -147,7 +156,10 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
wallet.deleteDatabase();
- exchangesList = await wallet.listExchanges();
+ exchangesList = await wallet.client.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
t.assertTrue(exchangesList.exchanges.length === 0);
faultyExchange.faultProxy.addFault({
@@ -163,7 +175,7 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
});
const err1 = await t.assertThrowsOperationErrorAsync(async () => {
- await wallet.addExchange({
+ await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: faultyExchange.baseUrl,
});
});
@@ -175,7 +187,10 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
);
- exchangesList = await wallet.listExchanges();
+ exchangesList = await wallet.client.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
t.assertTrue(exchangesList.exchanges.length === 0);
/*
@@ -202,7 +217,7 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
});
const err2 = await t.assertThrowsOperationErrorAsync(async () => {
- await wallet.addExchange({
+ await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: faultyExchange.baseUrl,
});
});
@@ -212,7 +227,10 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
TalerErrorCode.WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE,
);
- exchangesList = await wallet.listExchanges();
+ exchangesList = await wallet.client.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
t.assertTrue(exchangesList.exchanges.length === 0);
/*
@@ -236,9 +254,12 @@ export async function runExchangeManagementTest(t: GlobalTestState) {
// Hand it to the wallet
- const wd = await wallet.getWithdrawalDetailsForUri({
- talerWithdrawUri: wop.taler_withdraw_uri,
- });
+ const wd = await wallet.client.call(
+ WalletApiOperation.GetWithdrawalDetailsForUri,
+ {
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ },
+ );
// Make sure the faulty exchange isn't used for the suggestion.
t.assertTrue(wd.possibleExchanges.length === 0);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts b/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts
index c56fe7abf..e977c178e 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts
@@ -17,6 +17,7 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
GlobalTestState,
BankService,
@@ -183,7 +184,7 @@ export async function runFeeRegressionTest(t: GlobalTestState) {
amount: "TESTKUDOS:1.92",
});
- const coins = await wallet.dumpCoins();
+ const coins = await wallet.client.call(WalletApiOperation.DumpCoins, {});
// Make sure we really withdraw one 0.64 and one 1.28 coin.
t.assertTrue(coins.coins.length === 2);
@@ -198,7 +199,7 @@ export async function runFeeRegressionTest(t: GlobalTestState) {
await wallet.runUntilDone();
- const txs = await wallet.getTransactions();
+ const txs = await wallet.client.call(WalletApiOperation.GetTransactions, {});
t.assertAmountEquals(txs.transactions[1].amountEffective, "TESTKUDOS:1.30");
console.log(txs);
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
index 03d9fa357..34525844f 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
@@ -18,6 +18,7 @@
* Imports.
*/
import { CoreApiResponse } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
import {
DbInfo,
@@ -237,24 +238,19 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
libeufinNexus,
} = await createLibeufinTestEnvironment(t);
- let wresp: CoreApiResponse;
-
- // FIXME: add nicer api in the harness wallet for this.
- wresp = await wallet.apiRequest("addExchange", {
- exchangeBaseUrl: exchange.baseUrl,
- });
-
- t.assertTrue(wresp.type === "response");
-
- // FIXME: add nicer api in the harness wallet for this.
- wresp = await wallet.apiRequest("acceptManualWithdrawal", {
+ await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
- amount: "EUR:10",
});
- t.assertTrue(wresp.type === "response");
+ const wr = await wallet.client.call(
+ WalletApiOperation.AcceptManualWithdrawal,
+ {
+ exchangeBaseUrl: exchange.baseUrl,
+ amount: "EUR:10",
+ },
+ );
- const reservePub: string = (wresp.result as any).reservePub;
+ const reservePub: string = wr.reservePub;
await LibeufinSandboxApi.simulateIncomingTransaction(
libeufinSandbox,
@@ -275,7 +271,7 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
await wallet.runUntilDone();
- const bal = await wallet.getBalances();
+ const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
console.log("balances", JSON.stringify(bal, undefined, 2));
t.assertAmountEquals(bal.balances[0].available, "EUR:14.7");
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-wallet-cli/src/integrationtests/test-merchant-exchange-confusion.ts
index 3336f0c5e..a29e72af6 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-merchant-exchange-confusion.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-merchant-exchange-confusion.ts
@@ -43,6 +43,7 @@ import {
FaultInjectionRequestContext,
} from "./faultInjection";
import { defaultCoinConfig } from "./denomStructures";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run a test case with a simple TESTKUDOS Taler environment, consisting
@@ -199,9 +200,12 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.preparePay({
- talerPayUri: pubUnpaidStatus.taler_pay_uri,
- });
+ let preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: pubUnpaidStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);
@@ -221,9 +225,12 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
publicOrderStatusResp.data,
);
- const confirmPayRes = await wallet.confirmPay({
- proposalId: proposalId,
- });
+ const confirmPayRes = await wallet.client.call(
+ WalletApiOperation.ConfirmPay,
+ {
+ proposalId: proposalId,
+ },
+ );
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-merchant-longpolling.ts b/packages/taler-wallet-cli/src/integrationtests/test-merchant-longpolling.ts
index 0f6ba654f..04888ecc1 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-merchant-longpolling.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-merchant-longpolling.ts
@@ -25,7 +25,7 @@ import {
ConfirmPayResultType,
} from "@gnu-taler/taler-util";
import axios from "axios";
-import { URL } from "@gnu-taler/taler-wallet-core";
+import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -104,9 +104,12 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
validateStatus: () => true,
});
- let preparePayResp = await wallet.preparePay({
- talerPayUri: pubUnpaidStatus.taler_pay_uri,
- });
+ let preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: pubUnpaidStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);
@@ -124,9 +127,12 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
publicOrderStatusResp.data,
);
- const confirmPayRes = await wallet.confirmPay({
- proposalId: proposalId,
- });
+ const confirmPayRes = await wallet.client.call(
+ WalletApiOperation.ConfirmPay,
+ {
+ proposalId: proposalId,
+ },
+ );
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-merchant-refund-api.ts b/packages/taler-wallet-cli/src/integrationtests/test-merchant-refund-api.ts
index 32bc310d7..4d4310993 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-merchant-refund-api.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-merchant-refund-api.ts
@@ -32,7 +32,7 @@ import {
} from "./helpers";
import { durationFromSpec, PreparePayResultType } from "@gnu-taler/taler-util";
import axios from "axios";
-import { URL } from "@gnu-taler/taler-wallet-core";
+import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
async function testRefundApiWithFulfillmentUrl(
t: GlobalTestState,
@@ -66,18 +66,20 @@ async function testRefundApiWithFulfillmentUrl(
// Make wallet pay for the order
- let preparePayResult = await wallet.preparePay({
- talerPayUri,
- });
+ let preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- const r2 = await wallet.apiRequest("confirmPay", {
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -87,9 +89,12 @@ async function testRefundApiWithFulfillmentUrl(
t.assertTrue(orderStatus.order_status === "paid");
- preparePayResult = await wallet.preparePay({
- talerPayUri,
- });
+ preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.AlreadyConfirmed,
@@ -176,18 +181,20 @@ async function testRefundApiWithFulfillmentMessage(
// Make wallet pay for the order
- let preparePayResult = await wallet.preparePay({
- talerPayUri,
- });
+ let preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- const r2 = await wallet.apiRequest("confirmPay", {
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -197,9 +204,12 @@ async function testRefundApiWithFulfillmentMessage(
t.assertTrue(orderStatus.order_status === "paid");
- preparePayResult = await wallet.preparePay({
- talerPayUri,
- });
+ preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.AlreadyConfirmed,
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts b/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
index 10f9904f1..29e0fd0a6 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
@@ -23,7 +23,7 @@
* Imports.
*/
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
-import { URL } from "@gnu-taler/taler-wallet-core";
+import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
FaultInjectionRequestContext,
FaultInjectionResponseContext,
@@ -76,9 +76,12 @@ export async function runPayAbortTest(t: GlobalTestState) {
// Make wallet pay for the order
- const preparePayResult = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
- });
+ const preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
@@ -121,12 +124,12 @@ export async function runPayAbortTest(t: GlobalTestState) {
});
await t.assertThrowsOperationErrorAsync(async () => {
- await wallet.confirmPay({
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
});
- let txr = await wallet.getTransactions();
+ let txr = await wallet.client.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(txr, undefined, 2));
t.assertDeepEqual(txr.transactions[1].type, "payment");
@@ -136,13 +139,13 @@ export async function runPayAbortTest(t: GlobalTestState) {
TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
);
- await wallet.abortFailedPayWithRefund({
+ await wallet.client.call(WalletApiOperation.AbortFailedPayWithRefund, {
proposalId: preparePayResult.proposalId,
});
await wallet.runUntilDone();
- txr = await wallet.getTransactions();
+ txr = await wallet.client.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(txr, undefined, 2));
const txTypes = txr.transactions.map((x) => x.type);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts b/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
index a4f09855e..3155898a5 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
@@ -29,7 +29,7 @@ import {
} from "@gnu-taler/taler-util";
import axios from "axios";
import { FaultInjectionRequestContext } from "./faultInjection";
-import { URL } from "@gnu-taler/taler-wallet-core";
+import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for the wallets repurchase detection mechanism
@@ -103,9 +103,12 @@ export async function runPayPaidTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.preparePay({
- talerPayUri: pubUnpaidStatus.taler_pay_uri,
- });
+ let preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: pubUnpaidStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);
@@ -125,9 +128,12 @@ export async function runPayPaidTest(t: GlobalTestState) {
publicOrderStatusResp.data,
);
- const confirmPayRes = await wallet.confirmPay({
- proposalId: proposalId,
- });
+ const confirmPayRes = await wallet.client.call(
+ WalletApiOperation.ConfirmPay,
+ {
+ proposalId: proposalId,
+ },
+ );
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
@@ -198,9 +204,12 @@ export async function runPayPaidTest(t: GlobalTestState) {
// Pay with new taler://pay URI, which should
// have the new session ID!
// Wallet should now automatically re-play payment.
- preparePayResp = await wallet.preparePay({
- talerPayUri: orderStatusTwo.taler_pay_uri,
- });
+ preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatusTwo.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.AlreadyConfirmed);
t.assertTrue(preparePayResp.paid);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-claim.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-claim.ts
index 5a8adc966..9620db6d5 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-claim.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-claim.ts
@@ -21,6 +21,7 @@ import { GlobalTestState, MerchantPrivateApi, WalletCli } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { PreparePayResultType } from "@gnu-taler/taler-util";
import { TalerErrorCode } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -61,25 +62,26 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
// Make wallet pay for the order
- const preparePayResult = await wallet.preparePay({
- talerPayUri,
- });
+ const preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
t.assertThrowsOperationErrorAsync(async () => {
- await walletTwo.preparePay({
+ await walletTwo.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri,
});
});
- const r2 = await wallet.apiRequest("confirmPay", {
- // FIXME: should be validated, don't cast!
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -92,7 +94,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
walletTwo.deleteDatabase();
const err = await t.assertThrowsOperationErrorAsync(async () => {
- await walletTwo.preparePay({
+ await walletTwo.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri,
});
});
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
index 37ae0739c..57ad6a4ff 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
@@ -39,6 +39,7 @@ import {
} from "./faultInjection";
import { CoreApiResponse } from "@gnu-taler/taler-util";
import { defaultCoinConfig } from "./denomStructures";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -124,10 +125,9 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Hand it to the wallet
- const r1 = await wallet.apiRequest("getWithdrawalDetailsForUri", {
+ await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r1.type === "response");
await wallet.runPending();
@@ -137,16 +137,15 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Withdraw
- const r2 = await wallet.apiRequest("acceptBankIntegratedWithdrawal", {
+ await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
exchangeBaseUrl: faultyExchange.baseUrl,
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r2.type === "response");
await wallet.runUntilDone();
// Check balance
- await wallet.getBalances();
+ await wallet.client.call(WalletApiOperation.GetBalances, {});
// Set up order.
@@ -168,12 +167,14 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
let apiResp: CoreApiResponse;
- apiResp = await wallet.apiRequest("preparePay", {
- talerPayUri: orderStatus.taler_pay_uri,
- });
- t.assertTrue(apiResp.type === "response");
+ const prepResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
- const proposalId = (apiResp.result as any).proposalId;
+ const proposalId = prepResp.proposalId;
await wallet.runPending();
@@ -196,7 +197,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// confirmPay won't work, as the exchange is unreachable
- apiResp = await wallet.apiRequest("confirmPay", {
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
// FIXME: should be validated, don't cast!
proposalId: proposalId,
});
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-forgettable.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-forgettable.ts
index 9c34bee8a..49ffadc93 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-forgettable.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-forgettable.ts
@@ -78,4 +78,4 @@ export async function runPaymentForgettableTest(t: GlobalTestState) {
await wallet.runUntilDone();
}
-runPaymentForgettableTest.suites = ["wallet"];
+runPaymentForgettableTest.suites = ["wallet", "merchant"];
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-idempotency.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-idempotency.ts
index 061fe511c..58c951b68 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-idempotency.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-idempotency.ts
@@ -20,6 +20,7 @@
import { GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { PreparePayResultType } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Test the wallet-core payment API, especially that repeated operations
@@ -59,13 +60,19 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
// Make wallet pay for the order
- const preparePayResult = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
- });
+ const preparePayResult = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
- const preparePayResultRep = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
- });
+ const preparePayResultRep = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
@@ -76,11 +83,10 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
const proposalId = preparePayResult.proposalId;
- const r2 = await wallet.apiRequest("confirmPay", {
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
// FIXME: should be validated, don't cast!
proposalId: proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -90,9 +96,12 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
t.assertTrue(orderStatus.order_status === "paid");
- const preparePayResultAfter = await wallet.preparePay({
- talerPayUri,
- });
+ const preparePayResultAfter = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri,
+ },
+ );
t.assertTrue(
preparePayResultAfter.status === PreparePayResultType.AlreadyConfirmed,
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
index 5197967b8..f545d5861 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
@@ -28,6 +28,7 @@ import {
} from "./harness";
import { withdrawViaBank } from "./helpers";
import { coin_ct10, coin_u1 } from "./denomStructures";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
async function setupTest(
t: GlobalTestState,
@@ -137,16 +138,14 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.apiRequest("preparePay", {
+ const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- t.assertTrue(r1.type === "response");
- const r2 = await wallet.apiRequest("confirmPay", {
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
// FIXME: should be validated, don't cast!
- proposalId: (r1.result as any).proposalId,
+ proposalId: r1.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -160,3 +159,4 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
}
runPaymentMultipleTest.suites = ["wallet"];
+runPaymentMultipleTest.timeoutMs = 120000;
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
index 0733cd03b..102c3c598 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
@@ -34,7 +34,7 @@ import {
TalerErrorCode,
TalerErrorDetails,
} from "@gnu-taler/taler-util";
-import { URL } from "@gnu-taler/taler-wallet-core";
+import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for a payment where the merchant has a transient
@@ -90,9 +90,12 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.preparePay({
- talerPayUri: pubUnpaidStatus.taler_pay_uri,
- });
+ let preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: pubUnpaidStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);
@@ -139,18 +142,24 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
},
});
- const confirmPayResp = await wallet.confirmPay({
- proposalId,
- });
+ const confirmPayResp = await wallet.client.call(
+ WalletApiOperation.ConfirmPay,
+ {
+ proposalId,
+ },
+ );
console.log(confirmPayResp);
t.assertTrue(confirmPayResp.type === ConfirmPayResultType.Pending);
t.assertTrue(faultInjected);
- const confirmPayRespTwo = await wallet.confirmPay({
- proposalId,
- });
+ const confirmPayRespTwo = await wallet.client.call(
+ WalletApiOperation.ConfirmPay,
+ {
+ proposalId,
+ },
+ );
t.assertTrue(confirmPayRespTwo.type === ConfirmPayResultType.Done);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-paywall-flow.ts b/packages/taler-wallet-cli/src/integrationtests/test-paywall-flow.ts
index 865fd77d1..77e322622 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-paywall-flow.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-paywall-flow.ts
@@ -25,6 +25,7 @@ import {
ConfirmPayResultType,
} from "@gnu-taler/taler-util";
import axios from "axios";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -90,9 +91,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.preparePay({
- talerPayUri: pubUnpaidStatus.taler_pay_uri,
- });
+ let preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: pubUnpaidStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);
@@ -112,9 +116,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
publicOrderStatusResp.data,
);
- const confirmPayRes = await wallet.confirmPay({
- proposalId: proposalId,
- });
+ const confirmPayRes = await wallet.client.call(
+ WalletApiOperation.ConfirmPay,
+ {
+ proposalId: proposalId,
+ },
+ );
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
@@ -148,9 +155,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// Pay with new taler://pay URI, which should
// have the new session ID!
// Wallet should now automatically re-play payment.
- preparePayResp = await wallet.preparePay({
- talerPayUri: talerPayUriOne,
- });
+ preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: talerPayUriOne,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.AlreadyConfirmed);
t.assertTrue(preparePayResp.paid);
@@ -185,9 +195,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// Here the re-purchase detection should kick in,
// and the wallet should re-pay for the old order
// under the new session ID (mysession-three).
- preparePayResp = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
- });
+ preparePayResp = await wallet.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.AlreadyConfirmed);
t.assertTrue(preparePayResp.paid);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts b/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts
index a78b0ecca..f1e79f4b9 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts
@@ -20,6 +20,7 @@
import { GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { durationFromSpec } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -59,16 +60,14 @@ export async function runRefundAutoTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.apiRequest("preparePay", {
+ const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- t.assertTrue(r1.type === "response");
- const r2 = await wallet.apiRequest("confirmPay", {
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
// FIXME: should be validated, don't cast!
- proposalId: (r1.result as any).proposalId,
+ proposalId: r1.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -90,7 +89,10 @@ export async function runRefundAutoTest(t: GlobalTestState) {
// The wallet should now automatically pick up the refund.
await wallet.runUntilDone();
- const transactions = await wallet.getTransactions();
+ const transactions = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {},
+ );
console.log(JSON.stringify(transactions, undefined, 2));
const transactionTypes = transactions.transactions.map((x) => x.type);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts b/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts
index c2640bb22..b4276248e 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts
@@ -29,6 +29,7 @@ import {
getTimestampNow,
timestampTruncateToSecond,
} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -74,16 +75,13 @@ export async function runRefundGoneTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.apiRequest("preparePay", {
+ const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- t.assertTrue(r1.type === "response");
- const r2 = await wallet.apiRequest("confirmPay", {
- // FIXME: should be validated, don't cast!
- proposalId: (r1.result as any).proposalId,
+ const r2 = await wallet.client.call(WalletApiOperation.ConfirmPay, {
+ proposalId: r1.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -108,7 +106,7 @@ export async function runRefundGoneTest(t: GlobalTestState) {
console.log(ref);
- let rr = await wallet.applyRefund({
+ let rr = await wallet.client.call(WalletApiOperation.ApplyRefund, {
talerRefundUri: ref.talerRefundUri,
});
@@ -117,11 +115,11 @@ export async function runRefundGoneTest(t: GlobalTestState) {
await wallet.runUntilDone();
- let r = await wallet.apiRequest("getBalances", {});
+ let r = await wallet.client.call(WalletApiOperation.GetBalances, {});
console.log(JSON.stringify(r, undefined, 2));
- r = await wallet.apiRequest("getTransactions", {});
- console.log(JSON.stringify(r, undefined, 2));
+ const r3 = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+ console.log(JSON.stringify(r3, undefined, 2));
await t.shutdown();
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-refund-incremental.ts b/packages/taler-wallet-cli/src/integrationtests/test-refund-incremental.ts
index 55f8ad6cd..11e1226d1 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-refund-incremental.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-refund-incremental.ts
@@ -24,6 +24,7 @@ import {
Amounts,
durationFromSpec,
} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -61,16 +62,13 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.apiRequest("preparePay", {
+ const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- t.assertTrue(r1.type === "response");
- const r2 = await wallet.apiRequest("confirmPay", {
- // FIXME: should be validated, don't cast!
- proposalId: (r1.result as any).proposalId,
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
+ proposalId: r1.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -90,11 +88,14 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
console.log("first refund increase response", ref);
{
- let wr = await wallet.applyRefund({
+ let wr = await wallet.client.call(WalletApiOperation.ApplyRefund, {
talerRefundUri: ref.talerRefundUri,
});
console.log(wr);
- const txs = await wallet.getTransactions();
+ const txs = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {},
+ );
console.log(
"transactions after applying first refund:",
JSON.stringify(txs, undefined, 2),
@@ -128,7 +129,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
console.log("third refund increase response", ref);
{
- let wr = await wallet.applyRefund({
+ let wr = await wallet.client.call(WalletApiOperation.ApplyRefund, {
talerRefundUri: ref.talerRefundUri,
});
console.log(wr);
@@ -146,11 +147,14 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
await wallet.runUntilDone();
- const bal = await wallet.getBalances();
+ const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
console.log(JSON.stringify(bal, undefined, 2));
{
- const txs = await wallet.getTransactions();
+ const txs = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {},
+ );
console.log(JSON.stringify(txs, undefined, 2));
const txTypes = txs.transactions.map((x) => x.type);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-refund.ts b/packages/taler-wallet-cli/src/integrationtests/test-refund.ts
index 4c7d478bf..1808f7d73 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-refund.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-refund.ts
@@ -18,6 +18,7 @@
* Imports.
*/
import { durationFromSpec } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
@@ -57,16 +58,13 @@ export async function runRefundTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.apiRequest("preparePay", {
+ const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- t.assertTrue(r1.type === "response");
- const r2 = await wallet.apiRequest("confirmPay", {
- // FIXME: should be validated, don't cast!
- proposalId: (r1.result as any).proposalId,
+ await wallet.client.call(WalletApiOperation.ConfirmPay, {
+ proposalId: r1.proposalId,
});
- t.assertTrue(r2.type === "response");
// Check if payment was successful.
@@ -85,19 +83,21 @@ export async function runRefundTest(t: GlobalTestState) {
console.log(ref);
- let r = await wallet.apiRequest("applyRefund", {
+ let r = await wallet.client.call(WalletApiOperation.ApplyRefund, {
talerRefundUri: ref.talerRefundUri,
});
- t.assertTrue(r.type === "response");
console.log(r);
await wallet.runUntilDone();
- r = await wallet.apiRequest("getBalances", {});
- console.log(JSON.stringify(r, undefined, 2));
-
- r = await wallet.apiRequest("getTransactions", {});
- console.log(JSON.stringify(r, undefined, 2));
+ {
+ const r2 = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ console.log(JSON.stringify(r2, undefined, 2));
+ }
+ {
+ const r2 = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+ console.log(JSON.stringify(r2, undefined, 2));
+ }
await t.shutdown();
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
index cf1eded12..fc1ffb267 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
@@ -17,6 +17,7 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig } from "./denomStructures";
import {
GlobalTestState,
@@ -39,7 +40,7 @@ async function revokeAllWalletCoins(req: {
merchant: MerchantService;
}): Promise<void> {
const { wallet, exchange, merchant } = req;
- const coinDump = await wallet.dumpCoins();
+ const coinDump = await wallet.client.call(WalletApiOperation.DumpCoins, {});
console.log(coinDump);
const usedDenomHashes = new Set<string>();
for (const coin of coinDump.coins) {
@@ -160,10 +161,13 @@ export async function runRevocationTest(t: GlobalTestState) {
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
// is implemented.
- await wallet.forceUpdateExchange({ exchangeBaseUrl: exchange.baseUrl });
+ await wallet.client.call(WalletApiOperation.AddExchange, {
+ exchangeBaseUrl: exchange.baseUrl,
+ forceUpdate: true,
+ });
await wallet.runUntilDone();
await wallet.runUntilDone();
- const bal = await wallet.getBalances();
+ const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
console.log("wallet balance", bal);
const order = {
@@ -177,10 +181,10 @@ export async function runRevocationTest(t: GlobalTestState) {
wallet.deleteDatabase();
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
- const coinDump = await wallet.dumpCoins();
+ const coinDump = await wallet.client.call(WalletApiOperation.DumpCoins, {});
console.log(coinDump);
const coinPubList = coinDump.coins.map((x) => x.coin_pub);
- await wallet.forceRefresh({
+ await wallet.client.call(WalletApiOperation.ForceRefresh, {
coinPubList,
});
await wallet.runUntilDone();
@@ -190,11 +194,14 @@ export async function runRevocationTest(t: GlobalTestState) {
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
// is implemented.
- await wallet.forceUpdateExchange({ exchangeBaseUrl: exchange.baseUrl });
+ await wallet.client.call(WalletApiOperation.AddExchange, {
+ exchangeBaseUrl: exchange.baseUrl,
+ forceUpdate: true,
+ });
await wallet.runUntilDone();
await wallet.runUntilDone();
{
- const bal = await wallet.getBalances();
+ const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
console.log("wallet balance", bal);
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
index 8146eafc5..bee7581bd 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
@@ -23,7 +23,10 @@ import {
durationFromSpec,
PreparePayResultType,
} from "@gnu-taler/taler-util";
-import { PendingOperationsResponse } from "@gnu-taler/taler-wallet-core";
+import {
+ PendingOperationsResponse,
+ WalletApiOperation,
+} from "@gnu-taler/taler-wallet-core";
import { makeNoFeeCoinConfig } from "./denomStructures";
import {
BankService,
@@ -145,7 +148,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
await wallet.runUntilDone();
let p: PendingOperationsResponse;
- p = await wallet.getPendingOperations();
+ p = await wallet.client.call(WalletApiOperation.GetPendingOperations, {});
console.log("pending operations after first time travel");
console.log(JSON.stringify(p, undefined, 2));
@@ -191,7 +194,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
t.assertTrue(orderStatus.order_status === "unpaid");
- const r = await wallet.preparePay({
+ const r = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
@@ -199,7 +202,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
t.assertTrue(r.status === PreparePayResultType.PaymentPossible);
- const cpr = await wallet.confirmPay({
+ const cpr = await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: r.proposalId,
});
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-withdraw.ts b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-withdraw.ts
index 0ddc6ab06..b9e45c862 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-withdraw.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-withdraw.ts
@@ -24,6 +24,7 @@ import {
startWithdrawViaBank,
} from "./helpers";
import { Duration, TransactionType } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Basic time travel test.
@@ -71,7 +72,10 @@ export async function runTimetravelWithdrawTest(t: GlobalTestState) {
// Check that transactions are correct for the failed withdrawal
{
await wallet.runUntilDone({ maxRetries: 5 });
- const transactions = await wallet.getTransactions();
+ const transactions = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {},
+ );
console.log(transactions);
const types = transactions.transactions.map((x) => x.type);
t.assertDeepEqual(types, ["withdrawal", "withdrawal"]);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts b/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts
index fbd7709ed..02439616a 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts
@@ -17,6 +17,7 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi, BankApi } from "./harness";
import { createSimpleTestkudosEnvironment } from "./helpers";
@@ -83,7 +84,7 @@ export async function runTippingTest(t: GlobalTestState) {
console.log("created tip", tip);
const doTip = async (): Promise<void> => {
- const ptr = await wallet.prepareTip({
+ const ptr = await wallet.client.call(WalletApiOperation.PrepareTip, {
talerTipUri: tip.taler_tip_uri,
});
@@ -92,19 +93,22 @@ export async function runTippingTest(t: GlobalTestState) {
t.assertAmountEquals(ptr.tipAmountRaw, "TESTKUDOS:5");
t.assertAmountEquals(ptr.tipAmountEffective, "TESTKUDOS:4.85");
- await wallet.acceptTip({
+ await wallet.client.call(WalletApiOperation.AcceptTip, {
walletTipId: ptr.walletTipId,
});
await wallet.runUntilDone();
- const bal = await wallet.getBalances();
+ const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
console.log(bal);
t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:4.85");
- const txns = await wallet.getTransactions();
+ const txns = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {},
+ );
console.log("Transactions:", JSON.stringify(txns, undefined, 2));
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
index 3793a5d1a..3342a560b 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
@@ -17,6 +17,7 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, WalletCli } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { SyncService } from "./sync";
@@ -49,30 +50,30 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
await sync.start();
await sync.pingUntilAvailable();
- await wallet.addBackupProvider({
+ await wallet.client.call(WalletApiOperation.AddBackupProvider, {
backupProviderBaseUrl: sync.baseUrl,
activate: false,
});
{
- const bi = await wallet.getBackupInfo();
+ const bi = await wallet.client.call(WalletApiOperation.GetBackupInfo, {});
t.assertDeepEqual(bi.providers[0].active, false);
}
- await wallet.addBackupProvider({
+ await wallet.client.call(WalletApiOperation.AddBackupProvider, {
backupProviderBaseUrl: sync.baseUrl,
activate: true,
});
{
- const bi = await wallet.getBackupInfo();
+ const bi = await wallet.client.call(WalletApiOperation.GetBackupInfo, {});
t.assertDeepEqual(bi.providers[0].active, true);
}
- await wallet.runBackupCycle();
+ await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
{
- const bi = await wallet.getBackupInfo();
+ const bi = await wallet.client.call(WalletApiOperation.GetBackupInfo, {});
console.log(bi);
t.assertDeepEqual(
bi.providers[0].paymentStatus.type,
@@ -82,46 +83,51 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
- await wallet.runBackupCycle();
+ await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
{
- const bi = await wallet.getBackupInfo();
+ const bi = await wallet.client.call(WalletApiOperation.GetBackupInfo, {});
console.log(bi);
}
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:5" });
- await wallet.runBackupCycle();
+ await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
{
- const bi = await wallet.getBackupInfo();
+ const bi = await wallet.client.call(WalletApiOperation.GetBackupInfo, {});
console.log(bi);
}
- const backupRecovery = await wallet.exportBackupRecovery();
+ const backupRecovery = await wallet.client.call(
+ WalletApiOperation.ExportBackupRecovery,
+ {},
+ );
const wallet2 = new WalletCli(t, "wallet2");
// Check that the second wallet is a fresh wallet.
{
- const bal = await wallet2.getBalances();
+ const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {});
t.assertTrue(bal.balances.length === 0);
}
- await wallet2.importBackupRecovery({ recovery: backupRecovery });
+ await wallet2.client.call(WalletApiOperation.ImportBackupRecovery, {
+ recovery: backupRecovery,
+ });
- await wallet2.runBackupCycle();
+ await wallet2.client.call(WalletApiOperation.RunBackupCycle, {});
// Check that now the old balance is available!
{
- const bal = await wallet2.getBalances();
+ const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {});
t.assertTrue(bal.balances.length === 1);
console.log(bal);
}
// Now do some basic checks that the restored wallet is still functional
{
- const bal1 = await wallet2.getBalances();
+ const bal1 = await wallet2.client.call(WalletApiOperation.GetBalances, {});
t.assertAmountEquals(bal1.balances[0].available, "TESTKUDOS:14.1");
@@ -134,7 +140,7 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
await wallet2.runUntilDone();
- const bal2 = await wallet2.getBalances();
+ const bal2 = await wallet2.client.call(WalletApiOperation.GetBalances, {});
t.assertAmountEquals(bal2.balances[0].available, "TESTKUDOS:23.82");
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts
index c5d590771..7d3c5f6dc 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts
@@ -18,6 +18,7 @@
* Imports.
*/
import { PreparePayResultType } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, WalletCli, MerchantPrivateApi } from "./harness";
import {
createSimpleTestkudosEnvironment,
@@ -54,26 +55,34 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
await sync.start();
await sync.pingUntilAvailable();
- await wallet.addBackupProvider({
+ await wallet.client.call(WalletApiOperation.AddBackupProvider, {
backupProviderBaseUrl: sync.baseUrl,
activate: true,
});
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
- await wallet.runBackupCycle();
+ await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
await wallet.runUntilDone();
- await wallet.runBackupCycle();
+ await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
- const backupRecovery = await wallet.exportBackupRecovery();
+ const backupRecovery = await wallet.client.call(
+ WalletApiOperation.ExportBackupRecovery,
+ {},
+ );
const wallet2 = new WalletCli(t, "wallet2");
- await wallet2.importBackupRecovery({ recovery: backupRecovery });
+ await wallet2.client.call(WalletApiOperation.ImportBackupRecovery, {
+ recovery: backupRecovery,
+ });
- await wallet2.runBackupCycle();
+ await wallet2.client.call(WalletApiOperation.RunBackupCycle, {});
- console.log("wallet1 balance before spend:", await wallet.getBalances());
+ console.log(
+ "wallet1 balance before spend:",
+ await wallet.client.call(WalletApiOperation.GetBalances, {}),
+ );
await makeTestPayment(t, {
merchant,
@@ -86,10 +95,16 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
await wallet.runUntilDone();
- console.log("wallet1 balance after spend:", await wallet.getBalances());
+ console.log(
+ "wallet1 balance after spend:",
+ await wallet.client.call(WalletApiOperation.GetBalances, {}),
+ );
{
- console.log("wallet2 balance:", await wallet2.getBalances());
+ console.log(
+ "wallet2 balance:",
+ await wallet2.client.call(WalletApiOperation.GetBalances, {}),
+ );
}
// Now we double-spend with the second wallet
@@ -116,15 +131,18 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
// Make wallet pay for the order
- const preparePayResult = await wallet2.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
- });
+ const preparePayResult = await wallet2.client.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- const res = await wallet2.confirmPay({
+ const res = await wallet2.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
@@ -139,7 +157,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
amount: "TESTKUDOS:50",
});
- const bal = await wallet2.getBalances();
+ const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {});
console.log("bal", bal);
await wallet2.runUntilDone();
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts
index 68d2c7264..5fb017edd 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts
@@ -22,6 +22,7 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
import {
BankService,
@@ -114,7 +115,7 @@ export async function createMyEnvironment(
export async function runWallettestingTest(t: GlobalTestState) {
const { wallet, bank, exchange, merchant } = await createMyEnvironment(t);
- await wallet.runIntegrationTest({
+ await wallet.client.call(WalletApiOperation.RunIntegrationTest, {
amountToSpend: "TESTKUDOS:5",
amountToWithdraw: "TESTKUDOS:10",
bankBaseUrl: bank.baseUrl,
@@ -123,7 +124,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
merchantBaseUrl: merchant.makeInstanceBaseUrl(),
});
- let txns = await wallet.getTransactions();
+ let txns = await wallet.client.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(txns, undefined, 2));
let txTypes = txns.transactions.map((x) => x.type);
@@ -138,7 +139,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
wallet.deleteDatabase();
- await wallet.withdrawTestBalance({
+ await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
amount: "TESTKUDOS:10",
bankBaseUrl: bank.baseUrl,
exchangeBaseUrl: exchange.baseUrl,
@@ -146,7 +147,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
await wallet.runUntilDone();
- await wallet.testPay({
+ await wallet.client.call(WalletApiOperation.TestPay, {
amount: "TESTKUDOS:5",
merchantAuthToken: merchantAuthToken,
merchantBaseUrl: merchant.makeInstanceBaseUrl(),
@@ -155,7 +156,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
await wallet.runUntilDone();
- txns = await wallet.getTransactions();
+ txns = await wallet.client.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(txns, undefined, 2));
txTypes = txns.transactions.map((x) => x.type);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-abort-bank.ts b/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-abort-bank.ts
index bfffa23b3..896b1e877 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-abort-bank.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-abort-bank.ts
@@ -18,6 +18,7 @@
* Imports.
*/
import { TalerErrorCode } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
import { createSimpleTestkudosEnvironment } from "./helpers";
@@ -40,10 +41,9 @@ export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
// Hand it to the wallet
- const r1 = await wallet.apiRequest("getWithdrawalDetailsForUri", {
+ await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r1.type === "response");
await wallet.runPending();
@@ -53,14 +53,18 @@ export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
// Withdraw
- const r2 = await wallet.apiRequest("acceptBankIntegratedWithdrawal", {
- exchangeBaseUrl: exchange.baseUrl,
- talerWithdrawUri: wop.taler_withdraw_uri,
+ const e = await t.assertThrowsOperationErrorAsync(async () => {
+ await wallet.client.call(
+ WalletApiOperation.AcceptBankIntegratedWithdrawal,
+ {
+ exchangeBaseUrl: exchange.baseUrl,
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ },
+ );
});
- t.assertTrue(r2.type === "error");
- t.assertTrue(
- r2.error.code ===
- TalerErrorCode.WALLET_WITHDRAWAL_OPERATION_ABORTED_BY_BANK,
+ t.assertDeepEqual(
+ e.operationError.code,
+ TalerErrorCode.WALLET_WITHDRAWAL_OPERATION_ABORTED_BY_BANK,
);
await t.shutdown();
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-bank-integrated.ts b/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-bank-integrated.ts
index 12e594c44..4a02b2708 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-bank-integrated.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-bank-integrated.ts
@@ -20,6 +20,7 @@
import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
import { createSimpleTestkudosEnvironment } from "./helpers";
import { codecForBalancesResponse } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -40,10 +41,9 @@ export async function runWithdrawalBankIntegratedTest(t: GlobalTestState) {
// Hand it to the wallet
- const r1 = await wallet.apiRequest("getWithdrawalDetailsForUri", {
+ const r1 = await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r1.type === "response");
await wallet.runPending();
@@ -53,18 +53,15 @@ export async function runWithdrawalBankIntegratedTest(t: GlobalTestState) {
// Withdraw
- const r2 = await wallet.apiRequest("acceptBankIntegratedWithdrawal", {
+ const r2 = await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
exchangeBaseUrl: exchange.baseUrl,
talerWithdrawUri: wop.taler_withdraw_uri,
});
- t.assertTrue(r2.type === "response");
await wallet.runUntilDone();
// Check balance
- const balApiResp = await wallet.apiRequest("getBalances", {});
- t.assertTrue(balApiResp.type === "response");
- const balResp = codecForBalancesResponse().decode(balApiResp.result);
+ const balResp = await wallet.client.call(WalletApiOperation.GetBalances, {});
t.assertAmountEquals("TESTKUDOS:9.72", balResp.balances[0].available);
await t.shutdown();
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-manual.ts b/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-manual.ts
index 97ea6892a..613618071 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-manual.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-withdrawal-manual.ts
@@ -21,6 +21,7 @@ import { GlobalTestState, BankApi } from "./harness";
import { createSimpleTestkudosEnvironment } from "./helpers";
import { CoreApiResponse } from "@gnu-taler/taler-util";
import { codecForBalancesResponse } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -41,20 +42,17 @@ export async function runTestWithdrawalManualTest(t: GlobalTestState) {
let wresp: CoreApiResponse;
- wresp = await wallet.apiRequest("addExchange", {
+ await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
});
- t.assertTrue(wresp.type === "response");
- wresp = await wallet.apiRequest("acceptManualWithdrawal", {
+ const wres = await wallet.client.call(WalletApiOperation.AcceptManualWithdrawal, {
exchangeBaseUrl: exchange.baseUrl,
amount: "TESTKUDOS:10",
});
- t.assertTrue(wresp.type === "response");
-
- const reservePub: string = (wresp.result as any).reservePub;
+ const reservePub: string = wres.reservePub;
await BankApi.adminAddIncoming(bank, {
exchangeBankAccount,
@@ -69,9 +67,7 @@ export async function runTestWithdrawalManualTest(t: GlobalTestState) {
// Check balance
- const balApiResp = await wallet.apiRequest("getBalances", {});
- t.assertTrue(balApiResp.type === "response");
- const balResp = codecForBalancesResponse().decode(balApiResp.result);
+ const balResp = await wallet.client.call(WalletApiOperation.GetBalances, {});
t.assertAmountEquals("TESTKUDOS:9.72", balResp.balances[0].available);
await t.shutdown();
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
index 39d63b04b..d1c8914d9 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -22,6 +22,7 @@
* Imports.
*/
import {
+ AbortPayWithRefundRequest,
AcceptBankIntegratedWithdrawalRequest,
AcceptExchangeTosRequest,
AcceptManualWithdrawalRequest,
@@ -45,6 +46,7 @@ import {
GetExchangeTosResult,
GetWithdrawalDetailsForAmountRequest,
GetWithdrawalDetailsForUriRequest,
+ IntegrationTestArgs,
ManualWithdrawalDetails,
PreparePayRequest,
PreparePayResult,
@@ -54,12 +56,14 @@ import {
RetryTransactionRequest,
SetCoinSuspendedRequest,
SetWalletDeviceIdRequest,
+ TestPayArgs,
TrackDepositGroupRequest,
TrackDepositGroupResponse,
TransactionsRequest,
TransactionsResponse,
WalletBackupContentV1,
WalletCurrencyInfo,
+ WithdrawTestBalanceRequest,
WithdrawUriInfoResponse,
} from "@gnu-taler/taler-util";
import { AddBackupProviderRequest, BackupInfo } from "./operations/backup";
@@ -85,7 +89,7 @@ export enum WalletApiOperation {
AcceptBankIntegratedWithdrawal = "acceptBankIntegratedWithdrawal",
GetExchangeTos = "getExchangeTos",
RetryPendingNow = "retryPendingNow",
- PreparePay = "preparePay",
+ AbortFailedPayWithRefund = "abortFailedPayWithRefund",
ConfirmPay = "confirmPay",
DumpCoins = "dumpCoins",
SetCoinSuspended = "setCoinSuspended",
@@ -117,14 +121,14 @@ export type WalletOperations = {
request: {};
response: {};
};
- [WalletApiOperation.PreparePay]: {
- request: PreparePayRequest;
- response: PreparePayResult;
- };
[WalletApiOperation.ConfirmPay]: {
request: ConfirmPayRequest;
response: ConfirmPayResult;
};
+ [WalletApiOperation.AbortFailedPayWithRefund]: {
+ request: AbortPayWithRefundRequest;
+ response: {};
+ };
[WalletApiOperation.GetBalances]: {
request: {};
response: BalancesResponse;
@@ -241,6 +245,18 @@ export type WalletOperations = {
request: {};
response: BackupInfo;
};
+ [WalletApiOperation.RunIntegrationTest]: {
+ request: IntegrationTestArgs;
+ response: {};
+ };
+ [WalletApiOperation.WithdrawTestBalance]: {
+ request: WithdrawTestBalanceRequest;
+ response: {};
+ };
+ [WalletApiOperation.TestPay]: {
+ request: TestPayArgs;
+ response: {};
+ }
};
export type RequestType<
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 85b5ae657..920cd2cc1 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -791,6 +791,8 @@ async function dispatchRequestInternal(
await runPending(ws, true);
return {};
}
+ // FIXME: Deprecate one of the aliases!
+ case "preparePayForUri":
case "preparePay": {
const req = codecForPreparePayRequest().decode(payload);
return await preparePayForUri(ws, req.talerPayUri);