aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-harness/src')
-rw-r--r--packages/taler-harness/src/bench2.ts1
-rw-r--r--packages/taler-harness/src/bench3.ts1
-rw-r--r--packages/taler-harness/src/env-full.ts4
-rw-r--r--packages/taler-harness/src/harness/harness.ts438
-rw-r--r--packages/taler-harness/src/harness/helpers.ts358
-rw-r--r--packages/taler-harness/src/harness/libeufin-apis.ts76
-rw-r--r--packages/taler-harness/src/index.ts28
-rw-r--r--packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts171
-rw-r--r--packages/taler-harness/src/integrationtests/test-bank-api.ts49
-rw-r--r--packages/taler-harness/src/integrationtests/test-claim-loop.ts27
-rw-r--r--packages/taler-harness/src/integrationtests/test-clause-schnorr.ts34
-rw-r--r--packages/taler-harness/src/integrationtests/test-denom-unoffered.ts17
-rw-r--r--packages/taler-harness/src/integrationtests/test-deposit.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-exchange-deposit.ts1
-rw-r--r--packages/taler-harness/src/integrationtests/test-exchange-management.ts42
-rw-r--r--packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts64
-rw-r--r--packages/taler-harness/src/integrationtests/test-fee-regression.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-kyc.ts24
-rw-r--r--packages/taler-harness/src/integrationtests/test-libeufin-api-sandbox-camt.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-libeufin-basic.ts45
-rw-r--r--packages/taler-harness/src/integrationtests/test-libeufin-nexus-balance.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts42
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts14
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts6
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-instances.ts18
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts22
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts97
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts106
-rw-r--r--packages/taler-harness/src/integrationtests/test-pay-paid.ts59
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-abort.ts48
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-claim.ts20
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-expired.ts131
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-fault.ts50
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-idempotency.ts12
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-multiple.ts48
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-share.ts29
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-template.ts33
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-transient.ts28
-rw-r--r--packages/taler-harness/src/integrationtests/test-paywall-flow.ts27
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-repair.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund-auto.ts18
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund-gone.ts55
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund-incremental.ts23
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund.ts13
-rw-r--r--packages/taler-harness/src/integrationtests/test-revocation.ts80
-rw-r--r--packages/taler-harness/src/integrationtests/test-stored-backups.ts112
-rw-r--r--packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts112
-rw-r--r--packages/taler-harness/src/integrationtests/test-timetravel-withdraw.ts40
-rw-r--r--packages/taler-harness/src/integrationtests/test-tipping.ts47
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallet-backup-basic.ts29
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts62
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallet-balance.ts29
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallet-notifications.ts15
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallettesting.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts34
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts14
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts28
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts3
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts30
-rw-r--r--packages/taler-harness/src/integrationtests/testrunner.ts74
-rw-r--r--packages/taler-harness/src/lint.ts1
63 files changed, 1411 insertions, 1594 deletions
diff --git a/packages/taler-harness/src/bench2.ts b/packages/taler-harness/src/bench2.ts
index 48ac76b9f..53db6f6c1 100644
--- a/packages/taler-harness/src/bench2.ts
+++ b/packages/taler-harness/src/bench2.ts
@@ -57,7 +57,6 @@ export async function runBench2(configJson: any): Promise<void> {
const http = createPlatformHttpLib({
enableThrottling: false,
- allowHttp: true,
});
const numIter = benchConf.iterations ?? 1;
diff --git a/packages/taler-harness/src/bench3.ts b/packages/taler-harness/src/bench3.ts
index c7eca90a8..0b5371af5 100644
--- a/packages/taler-harness/src/bench3.ts
+++ b/packages/taler-harness/src/bench3.ts
@@ -52,7 +52,6 @@ export async function runBench3(configJson: any): Promise<void> {
const myHttpLib = createPlatformHttpLib({
enableThrottling: false,
- allowHttp: true,
});
const numIter = b3conf.iterations ?? 1;
diff --git a/packages/taler-harness/src/env-full.ts b/packages/taler-harness/src/env-full.ts
index 3a684db0b..210d38e32 100644
--- a/packages/taler-harness/src/env-full.ts
+++ b/packages/taler-harness/src/env-full.ts
@@ -79,7 +79,7 @@ export async function runEnvFull(t: GlobalTestState): Promise<void> {
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -88,7 +88,7 @@ export async function runEnvFull(t: GlobalTestState): Promise<void> {
),
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
index 7db9d82bd..24e42099e 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -25,59 +25,45 @@
* Imports
*/
import {
+ AccountAddDetails,
AmountJson,
Amounts,
- AmountString,
- codecForMerchantOrderPrivateStatusResponse,
- codecForMerchantPostOrderResponse,
- codecForMerchantReserveCreateConfirmation,
+ BankAccessApiClient,
Configuration,
CoreApiResponse,
- createEddsaKeyPair,
Duration,
- eddsaGetPublic,
EddsaKeyPair,
+ Logger,
+ MerchantInstanceConfig,
+ PartialMerchantInstanceConfig,
+ TalerError,
+ WalletNotification,
+ createEddsaKeyPair,
+ eddsaGetPublic,
encodeCrock,
hash,
j2s,
- Logger,
- MerchantInstancesResponse,
- MerchantOrderPrivateStatusResponse,
- MerchantPostOrderRequest,
- MerchantPostOrderResponse,
- MerchantReserveCreateConfirmation,
- MerchantTemplateAddDetails,
parsePaytoUri,
stringToBytes,
- TalerError,
- TalerProtocolDuration,
- RewardCreateConfirmation,
- RewardCreateRequest,
- TippingReserveStatus,
- WalletNotification,
- codecForAny,
} from "@gnu-taler/taler-util";
import {
+ HttpRequestLibrary,
createPlatformHttpLib,
expectSuccessResponseOrThrow,
- readSuccessResponseJsonOrThrow,
} from "@gnu-taler/taler-util/http";
import {
- BankApi,
- BankServiceHandle,
- HarnessExchangeBankAccount,
- openPromise,
WalletCoreApiClient,
WalletCoreRequestType,
WalletCoreResponseType,
WalletOperations,
+ openPromise,
} from "@gnu-taler/taler-wallet-core";
import {
+ RemoteWallet,
+ WalletNotificationWaiter,
createRemoteWallet,
getClientFromRemoteWallet,
makeNotificationWaiter,
- RemoteWallet,
- WalletNotificationWaiter,
} from "@gnu-taler/taler-wallet-core/remote";
import { deepStrictEqual } from "assert";
import { ChildProcess, spawn } from "child_process";
@@ -383,7 +369,11 @@ export class GlobalTestState {
logger.warn(`could not start process (${command})`, err);
});
proc.on("exit", (code, signal) => {
- logger.warn(`process ${logName} exited ${j2s({ code, signal })}`);
+ if (code == 0 && signal == null) {
+ logger.info(`process ${logName} exited with success`);
+ } else {
+ logger.warn(`process ${logName} exited ${j2s({ code, signal })}`);
+ }
});
const stderrLogFileName = this.testDir + `/${logName}-stderr.log`;
const stderrLog = fs.createWriteStream(stderrLogFileName, {
@@ -578,6 +568,13 @@ class BankServiceBase {
) {}
}
+export interface HarnessExchangeBankAccount {
+ accountName: string;
+ accountPassword: string;
+ accountPaytoUri: string;
+ wireGatewayApiBaseUrl: string;
+}
+
/**
* Implementation of the bank service using the "taler-fakebank-run" tool.
*/
@@ -587,7 +584,7 @@ export class FakebankService
{
proc: ProcessWrapper | undefined;
- http = createPlatformHttpLib({ allowHttp: true, enableThrottling: false });
+ http = createPlatformHttpLib({ enableThrottling: false });
// We store "created" accounts during setup and
// register them after startup.
@@ -695,13 +692,9 @@ export class FakebankService
"bank",
);
await this.pingUntilAvailable();
+ const bankClient = new BankAccessApiClient(this.bankAccessApiBaseUrl);
for (const acc of this.accounts) {
- await BankApi.registerAccount(
- this,
- acc.accountName,
- acc.accountPassword,
- {},
- );
+ await bankClient.registerAccount(acc.accountName, acc.accountPassword);
}
}
@@ -714,6 +707,11 @@ export class FakebankService
// Use libeufin bank instead of pybank.
const useLibeufinBank = false;
+export interface BankServiceHandle {
+ readonly bankAccessApiBaseUrl: string;
+ readonly http: HttpRequestLibrary;
+}
+
export type BankService = BankServiceHandle;
export const BankService = FakebankService;
@@ -760,19 +758,19 @@ export class ExchangeService implements ExchangeServiceInterface {
return new ExchangeService(gc, ec, cfgFilename, keyPair);
}
- private currentTimetravel: Duration | undefined;
+ private currentTimetravelOffsetMs: number | undefined;
- setTimetravel(t: Duration | undefined): void {
+ setTimetravel(t: number | undefined): void {
if (this.isRunning()) {
throw Error("can't set time travel while the exchange is running");
}
- this.currentTimetravel = t;
+ this.currentTimetravelOffsetMs = t;
}
private get timetravelArg(): string | undefined {
- if (this.currentTimetravel && this.currentTimetravel.d_ms !== "forever") {
+ if (this.currentTimetravelOffsetMs != null) {
// Convert to microseconds
- return `--timetravel=+${this.currentTimetravel.d_ms * 1000}`;
+ return `--timetravel=+${this.currentTimetravelOffsetMs * 1000}`;
}
return undefined;
}
@@ -1334,282 +1332,19 @@ export interface MerchantConfig {
overrideTestDir?: string;
}
-export interface PrivateOrderStatusQuery {
- instance?: string;
- orderId: string;
- sessionId?: string;
-}
-
export interface MerchantServiceInterface {
makeInstanceBaseUrl(instanceName?: string): string;
readonly port: number;
readonly name: string;
}
-export interface DeleteTippingReserveArgs {
- reservePub: string;
- purge?: boolean;
-}
-
/**
* Default HTTP client handle for the integration test harness.
*/
export const harnessHttpLib = createPlatformHttpLib({
- allowHttp: true,
enableThrottling: false,
});
-export class MerchantApiClient {
- constructor(
- private baseUrl: string,
- public readonly auth: MerchantAuthConfiguration,
- ) {}
-
- httpClient = createPlatformHttpLib({ allowHttp: true, enableThrottling: false });
-
- async changeAuth(auth: MerchantAuthConfiguration): Promise<void> {
- const url = new URL("private/auth", this.baseUrl);
- const res = await this.httpClient.fetch(url.href, {
- method: "POST",
- body: auth,
- headers: this.makeAuthHeader(),
- });
- await expectSuccessResponseOrThrow(res);
- }
-
- async deleteTippingReserve(req: DeleteTippingReserveArgs): Promise<void> {
- const url = new URL(`private/reserves/${req.reservePub}`, this.baseUrl);
- if (req.purge) {
- url.searchParams.set("purge", "YES");
- }
- const resp = await this.httpClient.fetch(url.href, {
- method: "DELETE",
- headers: this.makeAuthHeader(),
- });
- logger.info(`delete status: ${resp.status}`);
- return;
- }
-
- async createTippingReserve(
- req: CreateMerchantTippingReserveRequest,
- ): Promise<MerchantReserveCreateConfirmation> {
- const url = new URL("private/reserves", this.baseUrl);
- const resp = await this.httpClient.fetch(url.href, {
- method: "POST",
- body: req,
- headers: this.makeAuthHeader(),
- });
- const respData = readSuccessResponseJsonOrThrow(
- resp,
- codecForMerchantReserveCreateConfirmation(),
- );
- return respData;
- }
-
- async getPrivateInstanceInfo(): Promise<any> {
- console.log(this.makeAuthHeader());
- const url = new URL("private", this.baseUrl);
- logger.info(`request url ${url.href}`);
- const resp = await this.httpClient.fetch(url.href, {
- method: "GET",
- headers: this.makeAuthHeader(),
- });
- return await resp.json();
- }
-
- async getPrivateTipReserves(): Promise<TippingReserveStatus> {
- console.log(this.makeAuthHeader());
- const url = new URL("private/reserves", this.baseUrl);
- const resp = await this.httpClient.fetch(url.href, {
- method: "GET",
- headers: this.makeAuthHeader(),
- });
- // FIXME: Validate!
- return await resp.json();
- }
-
- async deleteInstance(instanceId: string) {
- const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
- const resp = await this.httpClient.fetch(url.href, {
- method: "DELETE",
- headers: this.makeAuthHeader(),
- });
- await expectSuccessResponseOrThrow(resp);
- }
-
- async createInstance(req: MerchantInstanceConfig): Promise<void> {
- const url = new URL("management/instances", this.baseUrl);
- await this.httpClient.fetch(url.href, {
- method: "POST",
- body: req,
- headers: this.makeAuthHeader(),
- });
- }
-
- async getInstances(): Promise<MerchantInstancesResponse> {
- const url = new URL("management/instances", this.baseUrl);
- const resp = await this.httpClient.fetch(url.href, {
- headers: this.makeAuthHeader(),
- });
- return resp.json();
- }
-
- async getInstanceFullDetails(instanceId: string): Promise<any> {
- const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
- try {
- const resp = await this.httpClient.fetch(url.href, {
- headers: this.makeAuthHeader(),
- });
- return resp.json();
- } catch (e) {
- throw e;
- }
- }
-
- makeAuthHeader(): Record<string, string> {
- switch (this.auth.method) {
- case "external":
- return {};
- case "token":
- return {
- Authorization: `Bearer ${this.auth.token}`,
- };
- }
- }
-}
-
-/**
- * FIXME: This should be deprecated in favor of MerchantApiClient
- *
- * @deprecated use MerchantApiClient instead
- */
-export namespace MerchantPrivateApi {
- export async function createOrder(
- merchantService: MerchantServiceInterface,
- instanceName: string,
- req: MerchantPostOrderRequest,
- withAuthorization: WithAuthorization = {},
- ): Promise<MerchantPostOrderResponse> {
- const baseUrl = merchantService.makeInstanceBaseUrl(instanceName);
- let url = new URL("private/orders", baseUrl);
- const resp = await harnessHttpLib.fetch(url.href, {
- method: "POST",
- body: req,
- headers: withAuthorization as Record<string, string>,
- });
- return readSuccessResponseJsonOrThrow(
- resp,
- codecForMerchantPostOrderResponse(),
- );
- }
-
- export async function createTemplate(
- merchantService: MerchantServiceInterface,
- instanceName: string,
- req: MerchantTemplateAddDetails,
- withAuthorization: WithAuthorization = {},
- ) {
- const baseUrl = merchantService.makeInstanceBaseUrl(instanceName);
- let url = new URL("private/templates", baseUrl);
- const resp = await harnessHttpLib.fetch(url.href, {
- method: "POST",
- body: req,
- headers: withAuthorization as Record<string, string>,
- });
- if (resp.status !== 204) {
- throw Error("failed to create template");
- }
- }
-
- export async function queryPrivateOrderStatus(
- merchantService: MerchantServiceInterface,
- query: PrivateOrderStatusQuery,
- withAuthorization: WithAuthorization = {},
- ): Promise<MerchantOrderPrivateStatusResponse> {
- const reqUrl = new URL(
- `private/orders/${query.orderId}`,
- merchantService.makeInstanceBaseUrl(query.instance),
- );
- if (query.sessionId) {
- reqUrl.searchParams.set("session_id", query.sessionId);
- }
- const resp = await harnessHttpLib.fetch(reqUrl.href, {
- headers: withAuthorization as Record<string, string>,
- });
- return readSuccessResponseJsonOrThrow(
- resp,
- codecForMerchantOrderPrivateStatusResponse(),
- );
- }
-
- export async function giveRefund(
- merchantService: MerchantServiceInterface,
- r: {
- instance: string;
- orderId: string;
- amount: string;
- justification: string;
- },
- ): Promise<{ talerRefundUri: string }> {
- const reqUrl = new URL(
- `private/orders/${r.orderId}/refund`,
- merchantService.makeInstanceBaseUrl(r.instance),
- );
- const resp = await harnessHttpLib.fetch(reqUrl.href, {
- method: "POST",
- body: {
- refund: r.amount,
- reason: r.justification,
- },
- });
- const respBody = await resp.json();
- return {
- talerRefundUri: respBody.taler_refund_uri,
- };
- }
-
- export async function queryTippingReserves(
- merchantService: MerchantServiceInterface,
- instance: string,
- ): Promise<TippingReserveStatus> {
- const reqUrl = new URL(
- `private/reserves`,
- merchantService.makeInstanceBaseUrl(instance),
- );
- const resp = await harnessHttpLib.fetch(reqUrl.href);
- // FIXME: validate
- return resp.json();
- }
-
- export async function giveTip(
- merchantService: MerchantServiceInterface,
- instance: string,
- req: RewardCreateRequest,
- ): Promise<RewardCreateConfirmation> {
- const reqUrl = new URL(
- `private/tips`,
- merchantService.makeInstanceBaseUrl(instance),
- );
- const resp = await harnessHttpLib.fetch(reqUrl.href, {
- method: "POST",
- body: req,
- });
- // FIXME: validate
- return resp.json();
- }
-}
-
-export interface CreateMerchantTippingReserveRequest {
- // Amount that the merchant promises to put into the reserve
- initial_balance: AmountString;
-
- // Exchange the merchant intends to use for tipping
- exchange_url: string;
-
- // Desired wire method, for example "iban" or "x-taler-bank"
- wire_method: string;
-}
-
export class MerchantService implements MerchantServiceInterface {
static fromExistingConfig(
gc: GlobalTestState,
@@ -1636,23 +1371,23 @@ export class MerchantService implements MerchantServiceInterface {
private configFilename: string,
) {}
- private currentTimetravel: Duration | undefined;
+ private currentTimetravelOffsetMs: number | undefined;
private isRunning(): boolean {
return !!this.proc;
}
- setTimetravel(t: Duration | undefined): void {
+ setTimetravel(t: number | undefined): void {
if (this.isRunning()) {
throw Error("can't set time travel while the exchange is running");
}
- this.currentTimetravel = t;
+ this.currentTimetravelOffsetMs = t;
}
private get timetravelArg(): string | undefined {
- if (this.currentTimetravel && this.currentTimetravel.d_ms !== "forever") {
+ if (this.currentTimetravelOffsetMs != null) {
// Convert to microseconds
- return `--timetravel=+${this.currentTimetravel.d_ms * 1000}`;
+ return `--timetravel=+${this.currentTimetravelOffsetMs * 1000}`;
}
return undefined;
}
@@ -1759,7 +1494,7 @@ export class MerchantService implements MerchantServiceInterface {
}
async addDefaultInstance(): Promise<void> {
- return await this.addInstance({
+ return await this.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -1769,13 +1504,16 @@ export class MerchantService implements MerchantServiceInterface {
});
}
- async addInstance(
+ /**
+ * Add an instance together with a wire account.
+ */
+ async addInstanceWithWireAccount(
instanceConfig: PartialMerchantInstanceConfig,
): Promise<void> {
if (!this.proc) {
throw Error("merchant must be running to add instance");
}
- logger.info("adding instance");
+ logger.info(`adding instance '${instanceConfig.id}'`);
const url = `http://localhost:${this.merchantConfig.httpPort}/management/instances`;
const auth = instanceConfig.auth ?? { method: "external" };
@@ -1801,12 +1539,20 @@ export class MerchantService implements MerchantServiceInterface {
instanceConfig.defaultPayDelay ??
Duration.toTalerProtocolDuration(Duration.getForever()),
};
- const httpLib = createPlatformHttpLib({
- allowHttp: true,
- enableThrottling: false,
- });
- const resp = await httpLib.fetch(url, { method: "POST", body });
+ const resp = await harnessHttpLib.fetch(url, { method: "POST", body });
await expectSuccessResponseOrThrow(resp);
+
+ const accountCreateUrl = `http://localhost:${this.merchantConfig.httpPort}/instances/${instanceConfig.id}/private/accounts`;
+ for (const paytoUri of instanceConfig.paytoUris) {
+ const accountReq: AccountAddDetails = {
+ payto_uri: paytoUri,
+ };
+ const acctResp = await harnessHttpLib.fetch(accountCreateUrl, {
+ method: "POST",
+ body: accountReq,
+ });
+ await expectSuccessResponseOrThrow(acctResp);
+ }
}
makeInstanceBaseUrl(instanceName?: string): string {
@@ -1823,66 +1569,6 @@ export class MerchantService implements MerchantServiceInterface {
}
}
-export interface MerchantAuthConfiguration {
- method: "external" | "token";
- token?: string;
-}
-
-// FIXME: Why do we need this? Describe / fix!
-export interface PartialMerchantInstanceConfig {
- auth?: MerchantAuthConfiguration;
- id: string;
- name: string;
- paytoUris: string[];
- address?: unknown;
- jurisdiction?: unknown;
- defaultWireTransferDelay?: TalerProtocolDuration;
- defaultPayDelay?: TalerProtocolDuration;
-}
-
-// FIXME: Move all these types into merchant-api-types.ts!
-
-type FacadeCredentials = NoFacadeCredentials | BasicAuthFacadeCredentials;
-interface NoFacadeCredentials {
- type: "none";
-}
-interface BasicAuthFacadeCredentials {
- type: "basic";
-
- // Username to use to authenticate
- username: string;
-
- // Password to use to authenticate
- password: string;
-}
-
-interface MerchantBankAccount {
- // The payto:// URI where the wallet will send coins.
- payto_uri: string;
-
- // Optional base URL for a facade where the
- // merchant backend can see incoming wire
- // transfers to reconcile its accounting
- // with that of the exchange. Used by
- // taler-merchant-wirewatch.
- credit_facade_url?: string;
-
- // Credentials for accessing the credit facade.
- credit_facade_credentials?: FacadeCredentials;
-}
-
-export interface MerchantInstanceConfig {
- accounts: MerchantBankAccount[];
- auth: MerchantAuthConfiguration;
- id: string;
- name: string;
- address: unknown;
- jurisdiction: unknown;
- use_stefan: boolean;
- default_wire_transfer_delay: TalerProtocolDuration;
- default_pay_delay: TalerProtocolDuration;
-}
-
type TestStatus = "pass" | "fail" | "skip";
export interface TestRunResult {
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts
index d1d0ea104..9892e600b 100644
--- a/packages/taler-harness/src/harness/helpers.ts
+++ b/packages/taler-harness/src/harness/helpers.ts
@@ -25,21 +25,18 @@
*/
import {
AmountString,
+ BankAccessApiClient,
ConfirmPayResultType,
- MerchantContractTerms,
Duration,
- PreparePayResultType,
+ Logger,
+ MerchantApiClient,
+ MerchantContractTerms,
NotificationType,
- WalletNotification,
+ PreparePayResultType,
TransactionMajorState,
- Logger,
+ WalletNotification,
} from "@gnu-taler/taler-util";
-import {
- BankAccessApi,
- BankApi,
- HarnessExchangeBankAccount,
- WalletApiOperation,
-} from "@gnu-taler/taler-wallet-core";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "./denomStructures.js";
import {
FaultInjectedExchangeService,
@@ -51,17 +48,17 @@ import {
ExchangeService,
ExchangeServiceInterface,
FakebankService,
- getPayto,
GlobalTestState,
- MerchantPrivateApi,
+ HarnessExchangeBankAccount,
MerchantService,
MerchantServiceInterface,
- setupDb,
- setupSharedDb,
WalletCli,
WalletClient,
WalletService,
WithAuthorization,
+ getPayto,
+ setupDb,
+ setupSharedDb,
} from "./harness.js";
import * as fs from "fs";
@@ -107,114 +104,6 @@ export interface EnvOptions {
additionalBankConfig?(b: BankService): void;
}
-/**
- * Run a test case with a simple TESTKUDOS Taler environment, consisting
- * of one exchange, one bank and one merchant.
- *
- * @deprecated use {@link createSimpleTestkudosEnvironmentV2} instead
- */
-export async function createSimpleTestkudosEnvironment(
- t: GlobalTestState,
- coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")),
- opts: EnvOptions = {},
-): Promise<SimpleTestEnvironment> {
- const db = await setupDb(t);
-
- const bank = await BankService.create(t, {
- allowRegistrations: true,
- currency: "TESTKUDOS",
- database: db.connStr,
- httpPort: 8082,
- });
-
- const exchange = ExchangeService.create(t, {
- name: "testexchange-1",
- currency: "TESTKUDOS",
- httpPort: 8081,
- database: db.connStr,
- });
-
- const merchant = await MerchantService.create(t, {
- name: "testmerchant-1",
- currency: "TESTKUDOS",
- httpPort: 8083,
- database: db.connStr,
- });
-
- const exchangeBankAccount = await bank.createExchangeAccount(
- "myexchange",
- "x",
- );
- await exchange.addBankAccount("1", exchangeBankAccount);
-
- bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
-
- await bank.start();
-
- await bank.pingUntilAvailable();
-
- const ageMaskSpec = opts.ageMaskSpec;
-
- if (ageMaskSpec) {
- exchange.enableAgeRestrictions(ageMaskSpec);
- // Enable age restriction for all coins.
- exchange.addCoinConfigList(
- coinConfig.map((x) => ({
- ...x,
- name: `${x.name}-age`,
- ageRestricted: true,
- })),
- );
- // For mixed age restrictions, we also offer coins without age restrictions
- if (opts.mixedAgeRestriction) {
- exchange.addCoinConfigList(
- coinConfig.map((x) => ({ ...x, ageRestricted: false })),
- );
- }
- } else {
- exchange.addCoinConfigList(coinConfig);
- }
-
- await exchange.start();
- await exchange.pingUntilAvailable();
-
- merchant.addExchange(exchange);
-
- await merchant.start();
- await merchant.pingUntilAvailable();
-
- await merchant.addInstance({
- id: "default",
- name: "Default Instance",
- paytoUris: [getPayto("merchant-default")],
- defaultWireTransferDelay: Duration.toTalerProtocolDuration(
- Duration.fromSpec({ minutes: 1 }),
- ),
- });
-
- await merchant.addInstance({
- id: "minst1",
- name: "minst1",
- paytoUris: [getPayto("minst1")],
- defaultWireTransferDelay: Duration.toTalerProtocolDuration(
- Duration.fromSpec({ minutes: 1 }),
- ),
- });
-
- console.log("setup done!");
-
- const wallet = new WalletCli(t);
-
- return {
- commonDb: db,
- exchange,
- merchant,
- wallet,
- bank,
- exchangeBankAccount,
- };
-}
-
export function getSharedTestDir(): string {
return `/tmp/taler-harness@${process.env.USER}`;
}
@@ -344,7 +233,7 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) {
await merchant.pingUntilAvailable();
if (!prevSetupDone) {
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -353,7 +242,7 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) {
),
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -476,7 +365,7 @@ export async function createSimpleTestkudosEnvironmentV2(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -485,7 +374,7 @@ export async function createSimpleTestkudosEnvironmentV2(
),
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -554,7 +443,7 @@ export interface FaultyMerchantTestEnvironment {
exchangeBankAccount: HarnessExchangeBankAccount;
merchant: MerchantService;
faultyMerchant: FaultInjectedMerchantService;
- wallet: WalletCli;
+ walletClient: WalletClient;
}
/**
@@ -620,13 +509,13 @@ export async function createFaultInjectedMerchantTestkudosEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -634,13 +523,15 @@ export async function createFaultInjectedMerchantTestkudosEnvironment(
console.log("setup done!");
- const wallet = new WalletCli(t);
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "default",
+ });
return {
commonDb: db,
exchange,
merchant,
- wallet,
+ walletClient,
bank,
exchangeBankAccount,
faultyMerchant,
@@ -648,51 +539,6 @@ export async function createFaultInjectedMerchantTestkudosEnvironment(
};
}
-/**
- * Start withdrawing into the wallet.
- *
- * Only starts the operation, does not wait for it to finish.
- */
-export async function startWithdrawViaBank(
- t: GlobalTestState,
- p: {
- wallet: WalletCli;
- bank: BankService;
- exchange: ExchangeServiceInterface;
- amount: AmountString;
- restrictAge?: number;
- },
-): Promise<void> {
- const { wallet, bank, exchange, amount } = p;
-
- const user = await BankApi.createRandomBankUser(bank);
- const wop = await BankAccessApi.createWithdrawalOperation(bank, user, amount);
-
- // Hand it to the wallet
-
- await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
- talerWithdrawUri: wop.taler_withdraw_uri,
- restrictAge: p.restrictAge,
- });
-
- await wallet.runPending();
-
- // Withdraw (AKA select)
-
- await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
- exchangeBaseUrl: exchange.baseUrl,
- talerWithdrawUri: wop.taler_withdraw_uri,
- restrictAge: p.restrictAge,
- });
-
- // Confirm it
-
- await BankApi.confirmWithdrawalOperation(bank, user, wop);
-
- // We do *not* call runPending / runUntilDone on the wallet here.
- // Some tests rely on the final withdraw failing.
-}
-
export interface WithdrawViaBankResult {
withdrawalFinishedCond: Promise<true>;
}
@@ -714,8 +560,10 @@ export async function withdrawViaBankV2(
): Promise<WithdrawViaBankResult> {
const { walletClient: wallet, bank, exchange, amount } = p;
- const user = await BankApi.createRandomBankUser(bank);
- const wop = await BankAccessApi.createWithdrawalOperation(bank, user, amount);
+ const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
+
+ const user = await bankClient.createRandomBankUser();
+ const wop = await bankClient.createWithdrawalOperation(user.username, amount);
// Hand it to the wallet
@@ -744,140 +592,44 @@ export async function withdrawViaBankV2(
// Confirm it
- await BankApi.confirmWithdrawalOperation(bank, user, wop);
+ await bankClient.confirmWithdrawalOperation(user.username, wop);
return {
withdrawalFinishedCond,
};
}
-/**
- * Withdraw balance.
- *
- * @deprecated use {@link withdrawViaBankV2 instead}
- */
-export async function withdrawViaBank(
- t: GlobalTestState,
- p: {
- wallet: WalletCli;
- bank: BankService;
- exchange: ExchangeServiceInterface;
- amount: AmountString;
- restrictAge?: number;
- },
-): Promise<void> {
- const { wallet } = p;
-
- await startWithdrawViaBank(t, p);
-
- await wallet.runUntilDone();
-
- // Check balance
-
- await wallet.client.call(WalletApiOperation.GetBalances, {});
-}
-
-export async function applyTimeTravel(
- timetravelDuration: Duration,
+export async function applyTimeTravelV2(
+ timetravelOffsetMs: number,
s: {
exchange?: ExchangeService;
merchant?: MerchantService;
- wallet?: WalletCli;
+ walletClient?: WalletClient;
},
): Promise<void> {
if (s.exchange) {
await s.exchange.stop();
- s.exchange.setTimetravel(timetravelDuration);
+ s.exchange.setTimetravel(timetravelOffsetMs);
await s.exchange.start();
await s.exchange.pingUntilAvailable();
}
if (s.merchant) {
await s.merchant.stop();
- s.merchant.setTimetravel(timetravelDuration);
+ s.merchant.setTimetravel(timetravelOffsetMs);
await s.merchant.start();
await s.merchant.pingUntilAvailable();
}
- if (s.wallet) {
- s.wallet.setTimetravel(timetravelDuration);
+ if (s.walletClient) {
+ await s.walletClient.call(WalletApiOperation.TestingSetTimetravel, {
+ offsetMs: timetravelOffsetMs,
+ });
}
}
/**
* Make a simple payment and check that it succeeded.
- *
- * @deprecated
- */
-export async function makeTestPayment(
- t: GlobalTestState,
- args: {
- merchant: MerchantServiceInterface;
- wallet: WalletCli;
- order: Partial<MerchantContractTerms>;
- instance?: string;
- },
- auth: WithAuthorization = {},
-): Promise<void> {
- // Set up order.
-
- const { wallet, merchant } = args;
- const instance = args.instance ?? "default";
-
- const orderResp = await MerchantPrivateApi.createOrder(
- merchant,
- instance,
- {
- order: args.order,
- },
- auth,
- );
-
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- },
- auth,
- );
-
- t.assertTrue(orderStatus.order_status === "unpaid");
-
- // Make wallet pay for the order
-
- const preparePayResult = await wallet.client.call(
- WalletApiOperation.PreparePayForUri,
- {
- talerPayUri: orderStatus.taler_pay_uri,
- },
- );
-
- t.assertTrue(
- preparePayResult.status === PreparePayResultType.PaymentPossible,
- );
-
- const r2 = await wallet.client.call(WalletApiOperation.ConfirmPay, {
- proposalId: preparePayResult.proposalId,
- });
-
- t.assertTrue(r2.type === ConfirmPayResultType.Done);
-
- // Check if payment was successful.
-
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- instance,
- },
- auth,
- );
-
- t.assertTrue(orderStatus.order_status === "paid");
-}
-
-/**
- * Make a simple payment and check that it succeeded.
*/
export async function makeTestPaymentV2(
t: GlobalTestState,
@@ -891,25 +643,19 @@ export async function makeTestPaymentV2(
): Promise<void> {
// Set up order.
- const { walletClient, merchant } = args;
- const instance = args.instance ?? "default";
+ const { walletClient, merchant, instance } = args;
- const orderResp = await MerchantPrivateApi.createOrder(
- merchant,
- instance,
- {
- order: args.order,
- },
- auth,
+ const merchantClient = new MerchantApiClient(
+ merchant.makeInstanceBaseUrl(instance),
);
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- },
- auth,
- );
+ const orderResp = await merchantClient.createOrder({
+ order: args.order,
+ });
+
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ });
t.assertTrue(orderStatus.order_status === "unpaid");
@@ -934,14 +680,10 @@ export async function makeTestPaymentV2(
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- instance,
- },
- auth,
- );
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ instance,
+ });
t.assertTrue(orderStatus.order_status === "paid");
}
diff --git a/packages/taler-harness/src/harness/libeufin-apis.ts b/packages/taler-harness/src/harness/libeufin-apis.ts
index 3c57eee07..0193f9252 100644
--- a/packages/taler-harness/src/harness/libeufin-apis.ts
+++ b/packages/taler-harness/src/harness/libeufin-apis.ts
@@ -176,7 +176,7 @@ export interface LibeufinSandboxAddIncomingRequest {
direction: string;
}
-const libeufinHttpLib = createPlatformHttpLib();
+const libeufinHarnessHttpLib = createPlatformHttpLib();
/**
* APIs spread across Legacy and Access, it is therefore
@@ -192,7 +192,7 @@ export namespace LibeufinSandboxApi {
iban: string | null = null,
): Promise<void> {
let url = new URL("testing/register", libeufinSandboxService.baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: {
username: username,
@@ -211,7 +211,7 @@ export namespace LibeufinSandboxApi {
): Promise<void> {
// baseUrl should already be pointed to one demobank.
let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: {
userID: req.userID,
@@ -228,7 +228,7 @@ export namespace LibeufinSandboxApi {
): Promise<void> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL(`admin/ebics/hosts/${hostID}/rotate-keys`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: {},
});
@@ -239,7 +239,7 @@ export namespace LibeufinSandboxApi {
): Promise<void> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL("admin/ebics/hosts", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: {
hostID,
@@ -255,7 +255,7 @@ export namespace LibeufinSandboxApi {
): Promise<void> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL(`admin/bank-accounts/${req.label}`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
@@ -272,7 +272,7 @@ export namespace LibeufinSandboxApi {
): Promise<void> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL("admin/ebics/subscribers", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
@@ -289,7 +289,7 @@ export namespace LibeufinSandboxApi {
): Promise<void> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL("admin/ebics/bank-accounts", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
@@ -306,7 +306,7 @@ export namespace LibeufinSandboxApi {
`admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`,
baseUrl,
);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
@@ -322,7 +322,7 @@ export namespace LibeufinSandboxApi {
`admin/bank-accounts/${accountLabel}/transactions`,
baseUrl,
);
- const res = await libeufinHttpLib.fetch(url.href, {
+ const res = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return (await res.json()) as SandboxAccountTransactions;
@@ -334,7 +334,7 @@ export namespace LibeufinSandboxApi {
): Promise<any> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL("admin/payments/camt", baseUrl);
- return await libeufinHttpLib.fetch(url.href, {
+ return await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {
@@ -350,7 +350,7 @@ export namespace LibeufinSandboxApi {
): Promise<LibeufinSandboxAdminBankAccountBalance> {
const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL(`admin/bank-accounts/${accountLabel}`, baseUrl);
- const res = await libeufinHttpLib.fetch(url.href, {
+ const res = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return res.json();
@@ -362,7 +362,7 @@ export namespace LibeufinNexusApi {
nexus: LibeufinNexusServiceInterface,
): Promise<NexusBankConnections> {
let url = new URL("bank-connections", nexus.baseUrl);
- const res = await libeufinHttpLib.fetch(url.href, {
+ const res = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return res.json();
@@ -374,7 +374,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("bank-connections/delete-connection", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: req,
@@ -387,7 +387,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("bank-connections", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {
@@ -411,7 +411,7 @@ export namespace LibeufinNexusApi {
): Promise<any> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`bank-accounts/${accountName}`, baseUrl);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return resp.json();
@@ -427,7 +427,7 @@ export namespace LibeufinNexusApi {
`bank-accounts/${accountName}/payment-initiations/${paymentId}/submit`,
baseUrl,
);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {},
@@ -443,7 +443,7 @@ export namespace LibeufinNexusApi {
`bank-connections/${connectionName}/fetch-accounts`,
baseUrl,
);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {},
@@ -461,7 +461,7 @@ export namespace LibeufinNexusApi {
`bank-connections/${connectionName}/import-account`,
baseUrl,
);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {
@@ -477,7 +477,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`bank-connections/${connectionName}/connect`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {},
@@ -495,7 +495,7 @@ export namespace LibeufinNexusApi {
`/bank-accounts/${accountName}/payment-initiations`,
baseUrl,
);
- let response = await libeufinHttpLib.fetch(url.href, {
+ let response = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
const respJson = await response.json();
@@ -518,7 +518,7 @@ export namespace LibeufinNexusApi {
for (const [k, v] of Object.entries(params)) {
url.searchParams.set(k, String(v));
}
- let response = await libeufinHttpLib.fetch(url.href, {
+ let response = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return response.json();
@@ -534,7 +534,7 @@ export namespace LibeufinNexusApi {
): Promise<LibeufinNexusTransactions> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl);
- let response = await libeufinHttpLib.fetch(url.href, {
+ let response = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return response.json();
@@ -553,7 +553,7 @@ export namespace LibeufinNexusApi {
`/bank-accounts/${accountName}/fetch-transactions`,
baseUrl,
);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {
@@ -572,7 +572,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/users/${username}/password`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: req,
@@ -585,7 +585,7 @@ export namespace LibeufinNexusApi {
): Promise<NexusUserResponse> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/user`, baseUrl);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return resp.json();
@@ -597,7 +597,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/users`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: req,
@@ -609,7 +609,7 @@ export namespace LibeufinNexusApi {
): Promise<NexusGetPermissionsResponse> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/permissions`, baseUrl);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return resp.json();
@@ -621,7 +621,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/permissions`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: req,
@@ -634,7 +634,7 @@ export namespace LibeufinNexusApi {
): Promise<NexusTaskCollection> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return resp.json();
@@ -653,7 +653,7 @@ export namespace LibeufinNexusApi {
baseUrl,
);
if (taskName) url = new URL(taskName, `${url.href}/`);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
return resp.json();
@@ -669,7 +669,7 @@ export namespace LibeufinNexusApi {
`/bank-accounts/${bankAccountName}/schedule/${taskName}`,
baseUrl,
);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "DELETE",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
@@ -682,7 +682,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: req,
@@ -695,7 +695,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`facades/${facadeName}`, baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "DELETE",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
@@ -706,7 +706,7 @@ export namespace LibeufinNexusApi {
): Promise<NexusFacadeListResponse> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("facades", baseUrl);
- const resp = await libeufinHttpLib.fetch(url.href, {
+ const resp = await libeufinHarnessHttpLib.fetch(url.href, {
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
});
// FIXME: Just return validated, typed response here!
@@ -719,7 +719,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("facades", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {
@@ -741,7 +741,7 @@ export namespace LibeufinNexusApi {
): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("facades", baseUrl);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {
@@ -766,7 +766,7 @@ export namespace LibeufinNexusApi {
`/bank-accounts/${accountId}/submit-all-payment-initiations`,
baseUrl,
);
- await libeufinHttpLib.fetch(url.href, {
+ await libeufinHarnessHttpLib.fetch(url.href, {
method: "POST",
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
body: {},
diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts
index cd688ed89..f5d4fd2c2 100644
--- a/packages/taler-harness/src/index.ts
+++ b/packages/taler-harness/src/index.ts
@@ -20,17 +20,18 @@
import {
addPaytoQueryParams,
Amounts,
+ BankAccessApiClient,
Configuration,
decodeCrock,
j2s,
Logger,
+ MerchantApiClient,
rsaBlind,
setGlobalLogLevelFromString,
} from "@gnu-taler/taler-util";
import { clk } from "@gnu-taler/taler-util/clk";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
import {
- BankAccessApiClient,
CryptoDispatcher,
downloadExchangeInfo,
SynchronousCryptoWorkerFactoryPlain,
@@ -45,11 +46,7 @@ import { runBench2 } from "./bench2.js";
import { runBench3 } from "./bench3.js";
import { runEnvFull } from "./env-full.js";
import { runEnv1 } from "./env1.js";
-import {
- GlobalTestState,
- MerchantApiClient,
- runTestWithState,
-} from "./harness/harness.js";
+import { GlobalTestState, runTestWithState } from "./harness/harness.js";
import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
import { lintExchangeDeployment } from "./lint.js";
@@ -239,14 +236,15 @@ deploymentCli
console.log(tipReserveResp);
- const bankAccessApiClient = new BankAccessApiClient({
- baseUrl: args.tipTopup.bankAccessUrl,
- auth: {
- username: args.tipTopup.bankAccount,
- password: args.tipTopup.bankPassword,
+ const bankAccessApiClient = new BankAccessApiClient(
+ args.tipTopup.bankAccessUrl,
+ {
+ auth: {
+ username: args.tipTopup.bankAccount,
+ password: args.tipTopup.bankPassword,
+ },
},
- allowHttp: true,
- });
+ );
const paytoUri = addPaytoQueryParams(tipReserveResp.accounts[0].payto_uri, {
message: `tip-reserve ${tipReserveResp.reserve_pub}`,
@@ -402,7 +400,6 @@ deploymentCli
);
const res = await merchantClient.getPrivateInstanceInfo();
- console.log(res);
const tipRes = await merchantClient.getPrivateTipReserves();
console.log(j2s(tipRes));
@@ -506,9 +503,6 @@ testingCli
if (t.suites.length > 0) {
s += ` (suites: ${t.suites.join(",")})`;
}
- if (t.excludeByDefault) {
- s += ` [excluded by default]`;
- }
if (t.experimental) {
s += ` [experimental]`;
}
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 919097deb..7f936a479 100644
--- a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts
+++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts
@@ -1,6 +1,6 @@
/*
This file is part of GNU Taler
- (C) 2022 Taler Systems S.A.
+ (C) 2022-2023 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -17,24 +17,20 @@
/**
* Imports.
*/
-import {
- BankApi,
- WalletApiOperation,
- WireGatewayApiClient,
-} from "@gnu-taler/taler-wallet-core";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { defaultCoinConfig } from "../harness/denomStructures.js";
+import { getWireMethodForTest, GlobalTestState } from "../harness/harness.js";
import {
- getWireMethodForTest,
- GlobalTestState,
- MerchantApiClient,
- MerchantPrivateApi,
- WalletCli,
-} from "../harness/harness.js";
-import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
- makeTestPayment,
+ createSimpleTestkudosEnvironmentV2,
+ createWalletDaemonWithClient,
+ makeTestPaymentV2,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
+import {
+ BankAccessApiClient,
+ MerchantApiClient,
+ WireGatewayApiClient,
+} from "@gnu-taler/taler-util";
/**
* Run test for basic, bank-integrated withdrawal and payment.
@@ -43,12 +39,12 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
// Set up test environment
const {
- wallet: walletOne,
+ walletClient: walletClientOne,
bank,
exchange,
merchant,
exchangeBankAccount,
- } = await createSimpleTestkudosEnvironment(
+ } = await createSimpleTestkudosEnvironmentV2(
t,
defaultCoinConfig.map((x) => x("TESTKUDOS")),
{
@@ -58,24 +54,34 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
const merchantClient = new MerchantApiClient(
merchant.makeInstanceBaseUrl("default"),
+ );
+
+ const { walletClient: walletClientTwo } = await createWalletDaemonWithClient(
+ t,
{
- method: "external",
+ name: "w2",
},
);
- const walletTwo = new WalletCli(t, "walletTwo");
- const walletThree = new WalletCli(t, "walletThree");
+ const { walletClient: walletClientThree } =
+ await createWalletDaemonWithClient(t, {
+ name: "w3",
+ });
{
- const walletZero = new WalletCli(t, "walletZero");
+ const { walletClient: walletClientZero } =
+ await createWalletDaemonWithClient(t, {
+ name: "w0",
+ });
- await withdrawViaBank(t, {
- wallet: walletZero,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient: walletClientZero,
bank,
exchange,
amount: "TESTKUDOS:20",
restrictAge: 13,
});
+ await wres.withdrawalFinishedCond;
const order = {
summary: "Buy me!",
@@ -84,20 +90,28 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
minimum_age: 9,
};
- await makeTestPayment(t, { wallet: walletZero, merchant, order });
- await walletZero.runUntilDone();
+ await makeTestPaymentV2(t, {
+ walletClient: walletClientZero,
+ merchant,
+ order,
+ });
+ await walletClientZero.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
}
{
- const wallet = walletOne;
+ const walletClient = walletClientOne;
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
restrictAge: 13,
});
+ await wres.withdrawalFinishedCond;
const order = {
summary: "Buy me!",
@@ -106,20 +120,24 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
minimum_age: 9,
};
- await makeTestPayment(t, { wallet, merchant, order });
- await wallet.runUntilDone();
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
+ await walletClient.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
}
{
- const wallet = walletTwo;
+ const walletClient = walletClientTwo;
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
restrictAge: 13,
});
+ await wres.withdrawalFinishedCond;
const order = {
summary: "Buy me!",
@@ -127,19 +145,23 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- await makeTestPayment(t, { wallet, merchant, order });
- await wallet.runUntilDone();
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
+ await walletClient.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
}
{
- const wallet = walletThree;
+ const walletClient = walletClientThree;
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
});
+ await wres.withdrawalFinishedCond;
const order = {
summary: "Buy me!",
@@ -148,32 +170,37 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
minimum_age: 9,
};
- await makeTestPayment(t, { wallet, merchant, order });
- await wallet.runUntilDone();
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
+ await walletClient.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
}
// Pay with coin from tipping
{
- const mbu = await BankApi.createRandomBankUser(bank);
- const tipReserveResp = await merchantClient.createTippingReserve(
- {
- exchange_url: exchange.baseUrl,
- initial_balance: "TESTKUDOS:10",
- wire_method: getWireMethodForTest(),
- },
- );
+ const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
+ const mbu = await bankClient.createRandomBankUser();
+ const tipReserveResp = await merchantClient.createTippingReserve({
+ exchange_url: exchange.baseUrl,
+ initial_balance: "TESTKUDOS:10",
+ wire_method: getWireMethodForTest(),
+ });
t.assertDeepEqual(
tipReserveResp.accounts[0].payto_uri,
exchangeBankAccount.accountPaytoUri,
);
- const wireGatewayApiClient = new WireGatewayApiClient({
- wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
- accountName: exchangeBankAccount.accountName,
- accountPassword: exchangeBankAccount.accountPassword,
- allowHttp: true,
- });
+ const wireGatewayApiClient = new WireGatewayApiClient(
+ exchangeBankAccount.wireGatewayApiBaseUrl,
+ {
+ auth: {
+ username: exchangeBankAccount.accountName,
+ password: exchangeBankAccount.accountPassword,
+ },
+ },
+ );
await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:10",
@@ -183,23 +210,32 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
await exchange.runWirewatchOnce();
- const tip = await MerchantPrivateApi.giveTip(merchant, "default", {
+ const tip = await merchantClient.giveTip({
amount: "TESTKUDOS:5",
justification: "why not?",
next_url: "https://example.com/after-tip",
});
- const walletTipping = new WalletCli(t, "age-tipping");
+ const { walletClient: walletClientTipping } =
+ await createWalletDaemonWithClient(t, {
+ name: "age-tipping",
+ });
- const ptr = await walletTipping.client.call(WalletApiOperation.PrepareReward, {
- talerRewardUri: tip.taler_reward_uri,
- });
+ const ptr = await walletClientTipping.call(
+ WalletApiOperation.PrepareReward,
+ {
+ talerRewardUri: tip.taler_reward_uri,
+ },
+ );
- await walletTipping.client.call(WalletApiOperation.AcceptReward, {
+ await walletClientTipping.call(WalletApiOperation.AcceptReward, {
walletRewardId: ptr.walletRewardId,
});
- await walletTipping.runUntilDone();
+ await walletClientTipping.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
const order = {
summary: "Buy me!",
@@ -208,8 +244,15 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
minimum_age: 9,
};
- await makeTestPayment(t, { wallet: walletTipping, merchant, order });
- await walletTipping.runUntilDone();
+ await makeTestPaymentV2(t, {
+ walletClient: walletClientTipping,
+ merchant,
+ order,
+ });
+ await walletClientTipping.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
}
}
diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts
index 9ac16980b..a13ff63c7 100644
--- a/packages/taler-harness/src/integrationtests/test-bank-api.ts
+++ b/packages/taler-harness/src/integrationtests/test-bank-api.ts
@@ -17,13 +17,13 @@
/**
* Imports.
*/
-import { createEddsaKeyPair, encodeCrock } from "@gnu-taler/taler-util";
import {
- BankAccessApi,
- BankApi,
+ BankAccessApiClient,
CreditDebitIndicator,
WireGatewayApiClient,
-} from "@gnu-taler/taler-wallet-core";
+ createEddsaKeyPair,
+ encodeCrock,
+} from "@gnu-taler/taler-util";
import { defaultCoinConfig } from "../harness/denomStructures.js";
import {
BankService,
@@ -84,32 +84,34 @@ export async function runBankApiTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addDefaultInstance();
- await merchant.addInstance({
- id: "minst1",
- name: "minst1",
- paytoUris: [getPayto("minst1")],
- });
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
+ await merchant.addInstanceWithWireAccount({
+ id: "minst1",
+ name: "minst1",
+ paytoUris: [getPayto("minst1")],
+ });
+
console.log("setup done!");
- const bankUser = await BankApi.registerAccount(bank, "user1", "pw1", {});
+ const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
+
+ const bankUser = await bankClient.registerAccount("user1", "pw1");
// Make sure that registering twice results in a 409 Conflict
{
const e = await t.assertThrowsTalerErrorAsync(async () => {
- await BankApi.registerAccount(bank, "user1", "pw2", {});
+ await bankClient.registerAccount("user1", "pw2");
});
t.assertTrue(e.errorDetail.httpStatusCode === 409);
}
- let balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
+ let balResp = await bankClient.getAccountBalance(bankUser.username);
console.log(balResp);
@@ -121,12 +123,15 @@ export async function runBankApiTest(t: GlobalTestState) {
const res = createEddsaKeyPair();
- const wireGatewayApiClient = new WireGatewayApiClient({
- wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
- accountName: exchangeBankAccount.accountName,
- accountPassword: exchangeBankAccount.accountPassword,
- allowHttp: true,
- });
+ const wireGatewayApiClient = new WireGatewayApiClient(
+ exchangeBankAccount.wireGatewayApiBaseUrl,
+ {
+ auth: {
+ username: exchangeBankAccount.accountName,
+ password: exchangeBankAccount.accountPassword,
+ },
+ },
+ );
await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:115",
@@ -134,9 +139,11 @@ export async function runBankApiTest(t: GlobalTestState) {
reservePub: encodeCrock(res.eddsaPub),
});
- balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
+ balResp = await bankClient.getAccountBalance(bankUser.username);
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:15");
t.assertTrue(
balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit,
);
}
+
+runBankApiTest.suites = ["fakebank"] \ No newline at end of file
diff --git a/packages/taler-harness/src/integrationtests/test-claim-loop.ts b/packages/taler-harness/src/integrationtests/test-claim-loop.ts
index 32706c28b..a424e0101 100644
--- a/packages/taler-harness/src/integrationtests/test-claim-loop.ts
+++ b/packages/taler-harness/src/integrationtests/test-claim-loop.ts
@@ -19,11 +19,12 @@
*/
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { URL } from "url";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
} from "../harness/helpers.js";
+import { MerchantApiClient } from "@gnu-taler/taler-util";
/**
* Run test for the merchant's order lifecycle.
@@ -44,8 +45,10 @@ export async function runClaimLoopTest(t: GlobalTestState) {
amount: "TESTKUDOS:20",
});
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -54,12 +57,9 @@ export async function runClaimLoopTest(t: GlobalTestState) {
});
// Query private order status before claiming it.
- let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- },
- );
+ let orderStatusBefore = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ });
t.assertTrue(orderStatusBefore.order_status === "unpaid");
let statusUrlBefore = new URL(orderStatusBefore.order_status_url);
@@ -71,13 +71,12 @@ export async function runClaimLoopTest(t: GlobalTestState) {
});
// Query private order status after claiming it.
- let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- },
- );
+ let orderStatusAfter = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ });
t.assertTrue(orderStatusAfter.order_status === "claimed");
await t.shutdown();
}
+
+runClaimLoopTest.suites = ["merchant"]; \ No newline at end of file
diff --git a/packages/taler-harness/src/integrationtests/test-clause-schnorr.ts b/packages/taler-harness/src/integrationtests/test-clause-schnorr.ts
index bf42dc4c6..a5ad382a7 100644
--- a/packages/taler-harness/src/integrationtests/test-clause-schnorr.ts
+++ b/packages/taler-harness/src/integrationtests/test-clause-schnorr.ts
@@ -17,12 +17,13 @@
/**
* Imports.
*/
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import { GlobalTestState } from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
- makeTestPayment,
+ createSimpleTestkudosEnvironmentV2,
+ makeTestPaymentV2,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
/**
@@ -53,12 +54,18 @@ export async function runClauseSchnorrTest(t: GlobalTestState) {
name: "rsa_dummy",
});
- const { wallet, bank, exchange, merchant } =
- await createSimpleTestkudosEnvironment(t, coinConfig);
+ const { walletClient, bank, exchange, merchant } =
+ await createSimpleTestkudosEnvironmentV2(t, coinConfig);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+ await wres.withdrawalFinishedCond;
const order = {
summary: "Buy me!",
@@ -66,8 +73,8 @@ export async function runClauseSchnorrTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- await makeTestPayment(t, { wallet, merchant, order });
- await wallet.runUntilDone();
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
// Test JSON normalization of contract terms: Does the wallet
// agree with the merchant?
@@ -77,8 +84,8 @@ export async function runClauseSchnorrTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- await makeTestPayment(t, { wallet, merchant, order: order2 });
- await wallet.runUntilDone();
+ await makeTestPaymentV2(t, { walletClient, merchant, order: order2 });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
// Test JSON normalization of contract terms: Does the wallet
// agree with the merchant?
@@ -88,10 +95,9 @@ export async function runClauseSchnorrTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- await makeTestPayment(t, { wallet, merchant, order: order3 });
-
- await wallet.runUntilDone();
+ await makeTestPaymentV2(t, { walletClient, merchant, order: order3 });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
}
runClauseSchnorrTest.suites = ["experimental-wallet"];
-runClauseSchnorrTest.excludeByDefault = true;
+runClauseSchnorrTest.experimental = true;
diff --git a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
index 5a471b9aa..b4268ee42 100644
--- a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
+++ b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
@@ -17,9 +17,13 @@
/**
* Imports.
*/
-import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
+import {
+ MerchantApiClient,
+ PreparePayResultType,
+ TalerErrorCode,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -46,13 +50,14 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
// Effectively we completely reset the exchange,
// but keep the exchange master public key.
+ await merchant.stop();
+
await exchange.stop();
await exchange.purgeDatabase();
await exchange.purgeSecmodKeys();
await exchange.start();
await exchange.pingUntilAvailable();
- await merchant.stop();
await merchant.start();
await merchant.pingUntilAvailable();
@@ -62,11 +67,13 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
+ const orderResp = await merchantClient.createOrder({
order: order,
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-deposit.ts b/packages/taler-harness/src/integrationtests/test-deposit.ts
index 8ea3fc12e..7e1bb2a5c 100644
--- a/packages/taler-harness/src/integrationtests/test-deposit.ts
+++ b/packages/taler-harness/src/integrationtests/test-deposit.ts
@@ -102,3 +102,5 @@ export async function runDepositTest(t: GlobalTestState) {
// deposit and wire fees.
t.assertDeepEqual(transactions.transactions[1].amountRaw, "TESTKUDOS:9.79");
}
+
+runDepositTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts b/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts
index 05bbbfaa1..96255f5b5 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts
@@ -49,7 +49,6 @@ export async function runExchangeDepositTest(t: GlobalTestState) {
const { bank, exchange } = await createSimpleTestkudosEnvironmentV2(t);
const http = createPlatformHttpLib({
- allowHttp: true,
enableThrottling: false,
});
const cryptiDisp = new CryptoDispatcher(
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-management.ts b/packages/taler-harness/src/integrationtests/test-exchange-management.ts
index c67f861e1..9338a8988 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-management.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-management.ts
@@ -18,30 +18,27 @@
* Imports.
*/
import {
- GlobalTestState,
- WalletCli,
- setupDb,
- BankService,
- ExchangeService,
- MerchantService,
- getPayto,
-} from "../harness/harness.js";
-import {
- WalletApiOperation,
- BankApi,
- BankAccessApi,
-} from "@gnu-taler/taler-wallet-core";
-import {
+ BankAccessApiClient,
ExchangesListResponse,
- URL,
TalerErrorCode,
+ URL,
j2s,
} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { defaultCoinConfig } from "../harness/denomStructures.js";
import {
FaultInjectedExchangeService,
FaultInjectionResponseContext,
} from "../harness/faultInjection.js";
-import { defaultCoinConfig } from "../harness/denomStructures.js";
+import {
+ BankService,
+ ExchangeService,
+ GlobalTestState,
+ MerchantService,
+ WalletCli,
+ getPayto,
+ setupDb,
+} from "../harness/harness.js";
/**
* Test if the wallet handles outdated exchange versions correctly.
@@ -105,13 +102,13 @@ export async function runExchangeManagementTest(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -266,10 +263,11 @@ export async function runExchangeManagementTest(
// Create withdrawal operation
- const user = await BankApi.createRandomBankUser(bank);
- const wop = await BankAccessApi.createWithdrawalOperation(
- bank,
- user,
+ const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
+
+ const user = await bankClient.createRandomBankUser();
+ const wop = await bankClient.createWithdrawalOperation(
+ user.username,
"TESTKUDOS:10",
);
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
index 5ae97c3da..2ef7683b3 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
@@ -41,7 +41,11 @@ import {
setupDb,
WalletCli,
} from "../harness/harness.js";
-import { withdrawViaBank } from "../harness/helpers.js";
+import {
+ applyTimeTravelV2,
+ createWalletDaemonWithClient,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
const logger = new Logger("test-exchange-timetravel.ts");
@@ -89,36 +93,7 @@ function getDenomInfoFromKeys(ek: ExchangeKeysJson): DenomInfo[] {
return denomInfos;
}
-async function applyTimeTravel(
- timetravelDuration: Duration,
- s: {
- exchange?: ExchangeService;
- merchant?: MerchantService;
- wallet?: WalletCli;
- },
-): Promise<void> {
- if (s.exchange) {
- await s.exchange.stop();
- s.exchange.setTimetravel(timetravelDuration);
- await s.exchange.start();
- await s.exchange.pingUntilAvailable();
- }
-
- if (s.merchant) {
- await s.merchant.stop();
- s.merchant.setTimetravel(timetravelDuration);
- await s.merchant.start();
- await s.merchant.pingUntilAvailable();
- }
-
- if (s.wallet) {
- console.log("setting wallet time travel to", timetravelDuration);
- s.wallet.setTimetravel(timetravelDuration);
- }
-}
-
const http = createPlatformHttpLib({
- allowHttp: true,
enableThrottling: false,
});
@@ -173,13 +148,13 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -187,11 +162,19 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
console.log("setup done!");
- const wallet = new WalletCli(t);
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "default",
+ });
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:15",
+ });
+ await wres.withdrawalFinishedCond;
const keysResp1 = await http.fetch(exchange.baseUrl + "keys");
const keys1 = await readSuccessResponseJsonOrThrow(
@@ -206,11 +189,14 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
// Travel into the future, the deposit expiration is two years
// into the future.
console.log("applying first time travel");
- await applyTimeTravel(durationFromSpec({ days: 400 }), {
- wallet,
- exchange,
- merchant,
- });
+ await applyTimeTravelV2(
+ Duration.toMilliseconds(durationFromSpec({ days: 400 })),
+ {
+ walletClient,
+ exchange,
+ merchant,
+ },
+ );
const keysResp2 = await http.fetch(exchange.baseUrl + "keys");
const keys2 = await readSuccessResponseJsonOrThrow(
diff --git a/packages/taler-harness/src/integrationtests/test-fee-regression.ts b/packages/taler-harness/src/integrationtests/test-fee-regression.ts
index e0dc4bc3b..2d84b3a7c 100644
--- a/packages/taler-harness/src/integrationtests/test-fee-regression.ts
+++ b/packages/taler-harness/src/integrationtests/test-fee-regression.ts
@@ -139,7 +139,7 @@ export async function createMyTestkudosEnvironment(
await merchant.pingUntilAvailable();
await merchant.addDefaultInstance();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts
index 0fe24d708..1f7358b66 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc.ts
@@ -18,6 +18,7 @@
* Imports.
*/
import {
+ BankAccessApiClient,
Duration,
j2s,
Logger,
@@ -26,11 +27,9 @@ import {
TransactionMinorState,
TransactionType,
} from "@gnu-taler/taler-util";
-import {
- BankAccessApi,
- BankApi,
- WalletApiOperation,
-} from "@gnu-taler/taler-wallet-core";
+import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import * as http from "node:http";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import {
BankService,
@@ -43,8 +42,6 @@ import {
WalletService,
} from "../harness/harness.js";
import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js";
-import * as http from "node:http";
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
const logger = new Logger("test-kyc.ts");
@@ -162,7 +159,7 @@ export async function createKycTestkudosEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -171,7 +168,7 @@ export async function createKycTestkudosEnvironment(
),
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -305,9 +302,11 @@ export async function runKycTest(t: GlobalTestState) {
// Withdraw digital cash into the wallet.
+ const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
+
const amount = "TESTKUDOS:20";
- const user = await BankApi.createRandomBankUser(bank);
- const wop = await BankAccessApi.createWithdrawalOperation(bank, user, amount);
+ const user = await bankClient.createRandomBankUser();
+ const wop = await bankClient.createWithdrawalOperation(user.username, amount);
// Hand it to the wallet
@@ -332,7 +331,7 @@ export async function runKycTest(t: GlobalTestState) {
// Confirm it
- await BankApi.confirmWithdrawalOperation(bank, user, wop);
+ await bankClient.confirmWithdrawalOperation(user.username, wop);
const kycNotificationCond = walletClient.waitForNotificationCond((x) => {
if (
@@ -376,7 +375,6 @@ export async function runKycTest(t: GlobalTestState) {
// which would usually done in the browser.
const httpLib = createPlatformHttpLib({
- allowHttp: true,
enableThrottling: false,
});
const kycServerResp = await httpLib.fetch(kycUrl);
diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-api-sandbox-camt.ts b/packages/taler-harness/src/integrationtests/test-libeufin-api-sandbox-camt.ts
index 239bab334..22b411dc2 100644
--- a/packages/taler-harness/src/integrationtests/test-libeufin-api-sandbox-camt.ts
+++ b/packages/taler-harness/src/integrationtests/test-libeufin-api-sandbox-camt.ts
@@ -72,5 +72,5 @@ export async function runLibeufinApiSandboxCamtTest(t: GlobalTestState) {
let ret = await LibeufinSandboxApi.getCamt053(sandbox, "mock-account-1");
console.log(ret);
}
-runLibeufinApiSandboxCamtTest.excludeByDefault = true;
+runLibeufinApiSandboxCamtTest.experimental = true;
runLibeufinApiSandboxCamtTest.suites = ["libeufin"];
diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts b/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts
index f03b63f50..d87278197 100644
--- a/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts
+++ b/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts
@@ -19,23 +19,24 @@
*/
import {
AbsoluteTime,
- MerchantContractTerms,
Duration,
+ MerchantContractTerms,
} from "@gnu-taler/taler-util";
-import {
- WalletApiOperation,
- HarnessExchangeBankAccount,
-} from "@gnu-taler/taler-wallet-core";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import {
DbInfo,
ExchangeService,
GlobalTestState,
+ HarnessExchangeBankAccount,
MerchantService,
+ WalletClient,
setupDb,
- WalletCli,
} from "../harness/harness.js";
-import { makeTestPayment } from "../harness/helpers.js";
+import {
+ createWalletDaemonWithClient,
+ makeTestPaymentV2,
+} from "../harness/helpers.js";
import {
LibeufinNexusApi,
LibeufinNexusService,
@@ -53,7 +54,7 @@ export interface LibeufinTestEnvironment {
exchange: ExchangeService;
exchangeBankAccount: HarnessExchangeBankAccount;
merchant: MerchantService;
- wallet: WalletCli;
+ walletClient: WalletClient;
libeufinSandbox: LibeufinSandboxService;
libeufinNexus: LibeufinNexusService;
}
@@ -69,7 +70,7 @@ export async function createLibeufinTestEnvironment(
const libeufinSandbox = await LibeufinSandboxService.create(t, {
httpPort: 5010,
- databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
+ databaseJdbcUri: db.connStr,
});
await libeufinSandbox.start();
@@ -77,7 +78,7 @@ export async function createLibeufinTestEnvironment(
const libeufinNexus = await LibeufinNexusService.create(t, {
httpPort: 5011,
- databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
+ databaseJdbcUri: db.connStr,
});
await libeufinNexus.start();
@@ -202,7 +203,7 @@ export async function createLibeufinTestEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [`payto://iban/${merchantIban}?receiver-name=Merchant`],
@@ -213,13 +214,15 @@ export async function createLibeufinTestEnvironment(
console.log("setup done!");
- const wallet = new WalletCli(t);
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "default",
+ });
return {
commonDb: db,
exchange,
merchant,
- wallet,
+ walletClient,
exchangeBankAccount,
libeufinNexus,
libeufinSandbox,
@@ -232,14 +235,14 @@ export async function createLibeufinTestEnvironment(
export async function runLibeufinBasicTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, exchange, merchant, libeufinSandbox, libeufinNexus } =
+ const { walletClient, exchange, merchant, libeufinSandbox, libeufinNexus } =
await createLibeufinTestEnvironment(t);
- await wallet.client.call(WalletApiOperation.AddExchange, {
+ await walletClient.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
});
- const wr = await wallet.client.call(
+ const wr = await walletClient.call(
WalletApiOperation.AcceptManualWithdrawal,
{
exchangeBaseUrl: exchange.baseUrl,
@@ -265,9 +268,9 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
await exchange.runWirewatchOnce();
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ const bal = await walletClient.call(WalletApiOperation.GetBalances, {});
console.log("balances", JSON.stringify(bal, undefined, 2));
t.assertAmountEquals(bal.balances[0].available, "EUR:14.7");
@@ -275,10 +278,12 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
summary: "Buy me!",
amount: "EUR:5",
fulfillment_url: "taler://fulfillment-success/thx",
- wire_transfer_deadline: AbsoluteTime.toProtocolTimestamp(AbsoluteTime.now()),
+ wire_transfer_deadline: AbsoluteTime.toProtocolTimestamp(
+ AbsoluteTime.now(),
+ ),
};
- await makeTestPayment(t, { wallet, merchant, order });
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
await exchange.runAggregatorOnce();
await exchange.runTransferOnce();
diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-nexus-balance.ts b/packages/taler-harness/src/integrationtests/test-libeufin-nexus-balance.ts
index 68b0174cc..868f93759 100644
--- a/packages/taler-harness/src/integrationtests/test-libeufin-nexus-balance.ts
+++ b/packages/taler-harness/src/integrationtests/test-libeufin-nexus-balance.ts
@@ -114,4 +114,4 @@ export async function runLibeufinNexusBalanceTest(t: GlobalTestState) {
}
runLibeufinNexusBalanceTest.suites = ["libeufin"];
-runLibeufinNexusBalanceTest.excludeByDefault = true;
+runLibeufinNexusBalanceTest.experimental = true;
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts
index e18cd7a0f..2f79041d6 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts
@@ -20,6 +20,7 @@
import {
codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType,
+ MerchantApiClient,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@@ -35,16 +36,14 @@ import {
getPayto,
GlobalTestState,
harnessHttpLib,
- MerchantPrivateApi,
MerchantService,
setupDb,
- WalletCli,
} from "../harness/harness.js";
import {
+ createWalletDaemonWithClient,
FaultyMerchantTestEnvironment,
- withdrawViaBank,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/**
* Run a test case with a simple TESTKUDOS Taler environment, consisting
@@ -110,13 +109,13 @@ export async function createConfusedMerchantTestkudosEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -124,13 +123,15 @@ export async function createConfusedMerchantTestkudosEnvironment(
console.log("setup done!");
- const wallet = new WalletCli(t);
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "default",
+ });
return {
commonDb: db,
exchange,
merchant,
- wallet,
+ walletClient,
bank,
exchangeBankAccount,
faultyMerchant,
@@ -145,18 +146,20 @@ export async function createConfusedMerchantTestkudosEnvironment(
export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, faultyExchange, faultyMerchant } =
+ const { walletClient, bank, faultyExchange, faultyMerchant } =
await createConfusedMerchantTestkudosEnvironment(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange: faultyExchange,
amount: "TESTKUDOS:20",
});
+ await wres.withdrawalFinishedCond;
+
/**
* =========================================================================
* Create an order and let the wallet pay under a session ID
@@ -168,7 +171,9 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
const merchant = faultyMerchant;
- let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
+ let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -176,7 +181,7 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@@ -200,7 +205,7 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.client.call(
+ let preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: pubUnpaidStatus.taler_pay_uri,
@@ -231,12 +236,9 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
await publicOrderStatusResp.json(),
);
- const confirmPayRes = await wallet.client.call(
- WalletApiOperation.ConfirmPay,
- {
- proposalId: proposalId,
- },
- );
+ const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
+ proposalId: proposalId,
+ });
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
}
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts
index e6e5bff76..ff567d33d 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts
@@ -17,17 +17,15 @@
/**
* Imports.
*/
-import { TalerError, URL } from "@gnu-taler/taler-util";
+import { MerchantApiClient, TalerError, URL } from "@gnu-taler/taler-util";
import {
ExchangeService,
GlobalTestState,
- MerchantApiClient,
MerchantService,
- setupDb,
getPayto,
harnessHttpLib,
+ setupDb,
} from "../harness/harness.js";
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/**
* Test instance deletion and authentication for it
@@ -69,13 +67,15 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) {
// Instances should initially be empty
{
- const r = await harnessHttpLib.fetch(new URL("management/instances", baseUrl).href);
+ const r = await harnessHttpLib.fetch(
+ new URL("management/instances", baseUrl).href,
+ );
const data = await r.json();
t.assertDeepEqual(data.instances, []);
}
// Add an instance, no auth!
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -85,7 +85,7 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) {
});
// Add an instance, no auth!
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "myinst",
name: "Second Instance",
paytoUris: [getPayto("merchant-default")],
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts
index 18a09c76b..071288b0f 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts
@@ -17,17 +17,15 @@
/**
* Imports.
*/
-import { Duration } from "@gnu-taler/taler-util";
+import { Duration, MerchantApiClient } from "@gnu-taler/taler-util";
import {
ExchangeService,
GlobalTestState,
- MerchantApiClient,
MerchantService,
- setupDb,
getPayto,
harnessHttpLib,
+ setupDb,
} from "../harness/harness.js";
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/**
* Do basic checks on instance management and authentication.
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts
index f7d89c543..fd7a8ca3a 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts
@@ -17,17 +17,15 @@
/**
* Imports.
*/
-import { URL } from "@gnu-taler/taler-util";
+import { MerchantApiClient, URL } from "@gnu-taler/taler-util";
import {
ExchangeService,
GlobalTestState,
- MerchantApiClient,
MerchantService,
setupDb,
getPayto,
harnessHttpLib,
} from "../harness/harness.js";
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/**
* Do basic checks on instance management and authentication.
@@ -77,7 +75,17 @@ export async function runMerchantInstancesTest(t: GlobalTestState) {
}
// Add an instance, no auth!
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
+ id: "default",
+ name: "Default Instance",
+ paytoUris: [getPayto("merchant-default")],
+ auth: {
+ method: "external",
+ },
+ });
+
+ // Add it again, should be idempotent
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
@@ -87,7 +95,7 @@ export async function runMerchantInstancesTest(t: GlobalTestState) {
});
// Add an instance, no auth!
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "myinst",
name: "Second Instance",
paytoUris: [getPayto("merchant-default")],
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts b/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts
index 8d271c5d1..bd63a8445 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts
@@ -19,17 +19,17 @@
*/
import {
ConfirmPayResultType,
+ MerchantApiClient,
PreparePayResultType,
URL,
codecForMerchantOrderStatusUnpaid,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
+import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
} from "../harness/helpers.js";
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -50,6 +50,8 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
/**
* =========================================================================
* Create an order and let the wallet pay under a session ID
@@ -59,7 +61,7 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
* =========================================================================
*/
- let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -68,7 +70,7 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
create_token: false,
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@@ -81,7 +83,9 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
// First, request order status without longpolling
{
console.log("requesting", publicOrderStatusUrl.href);
- let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
+ let publicOrderStatusResp = await harnessHttpLib.fetch(
+ publicOrderStatusUrl.href,
+ );
if (publicOrderStatusResp.status != 402) {
throw Error(
@@ -94,7 +98,9 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
publicOrderStatusUrl.searchParams.set("timeout_ms", "500");
console.log("requesting", publicOrderStatusUrl.href);
- let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
+ let publicOrderStatusResp = await harnessHttpLib.fetch(
+ publicOrderStatusUrl.href,
+ );
if (publicOrderStatusResp.status != 402) {
throw Error(
@@ -129,7 +135,9 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
preparePayResp.contractTermsHash,
);
- let publicOrderStatusPromise = harnessHttpLib.fetch(publicOrderStatusUrl.href);
+ let publicOrderStatusPromise = harnessHttpLib.fetch(
+ publicOrderStatusUrl.href,
+ );
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts b/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts
index 8efac1fc1..1b69b9de6 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts
@@ -17,43 +17,42 @@
/**
* Imports.
*/
-import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
import {
+ Duration,
+ MerchantApiClient,
+ PreparePayResultType,
+ URL,
+ durationFromSpec,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import {
+ BankServiceHandle,
+ ExchangeServiceInterface,
GlobalTestState,
- MerchantPrivateApi,
MerchantServiceInterface,
- WalletCli,
- ExchangeServiceInterface,
+ WalletClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
+ createSimpleTestkudosEnvironmentV2,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
-import {
- URL,
- durationFromSpec,
- PreparePayResultType,
- Duration,
-} from "@gnu-taler/taler-util";
-import {
- WalletApiOperation,
- BankServiceHandle,
-} from "@gnu-taler/taler-wallet-core";
async function testRefundApiWithFulfillmentUrl(
t: GlobalTestState,
env: {
merchant: MerchantServiceInterface;
bank: BankServiceHandle;
- wallet: WalletCli;
+ walletClient: WalletClient;
exchange: ExchangeServiceInterface;
},
): Promise<void> {
- const { wallet, bank, exchange, merchant } = env;
+ const { walletClient, merchant } = env;
+
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -64,7 +63,7 @@ async function testRefundApiWithFulfillmentUrl(
),
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -75,7 +74,7 @@ async function testRefundApiWithFulfillmentUrl(
// Make wallet pay for the order
- let preparePayResult = await wallet.client.call(
+ let preparePayResult = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri,
@@ -86,19 +85,19 @@ async function testRefundApiWithFulfillmentUrl(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- await wallet.client.call(WalletApiOperation.ConfirmPay, {
+ await walletClient.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
- preparePayResult = await wallet.client.call(
+ preparePayResult = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri,
@@ -109,14 +108,14 @@ async function testRefundApiWithFulfillmentUrl(
preparePayResult.status === PreparePayResultType.AlreadyConfirmed,
);
- await MerchantPrivateApi.giveRefund(merchant, {
+ await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
orderId: orderResp.order_id,
});
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -136,7 +135,9 @@ async function testRefundApiWithFulfillmentUrl(
preparePayResult.contractTermsHash,
);
- let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
+ let publicOrderStatusResp = await harnessHttpLib.fetch(
+ publicOrderStatusUrl.href,
+ );
const respData = await publicOrderStatusResp.json();
t.assertTrue(publicOrderStatusResp.status === 200);
t.assertAmountEquals(respData.refund_amount, "TESTKUDOS:5");
@@ -158,14 +159,16 @@ async function testRefundApiWithFulfillmentMessage(
env: {
merchant: MerchantServiceInterface;
bank: BankServiceHandle;
- wallet: WalletCli;
+ walletClient: WalletClient;
exchange: ExchangeServiceInterface;
},
): Promise<void> {
- const { wallet, bank, exchange, merchant } = env;
+ const { walletClient, merchant } = env;
+
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -176,7 +179,7 @@ async function testRefundApiWithFulfillmentMessage(
),
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -187,7 +190,7 @@ async function testRefundApiWithFulfillmentMessage(
// Make wallet pay for the order
- let preparePayResult = await wallet.client.call(
+ let preparePayResult = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri,
@@ -198,19 +201,19 @@ async function testRefundApiWithFulfillmentMessage(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- await wallet.client.call(WalletApiOperation.ConfirmPay, {
+ await walletClient.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId,
});
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
- preparePayResult = await wallet.client.call(
+ preparePayResult = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri,
@@ -221,14 +224,14 @@ async function testRefundApiWithFulfillmentMessage(
preparePayResult.status === PreparePayResultType.AlreadyConfirmed,
);
- await MerchantPrivateApi.giveRefund(merchant, {
+ await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
orderId: orderResp.order_id,
});
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -248,7 +251,9 @@ async function testRefundApiWithFulfillmentMessage(
preparePayResult.contractTermsHash,
);
- let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
+ let publicOrderStatusResp = await harnessHttpLib.fetch(
+ publicOrderStatusUrl.href,
+ );
let respData = await publicOrderStatusResp.json();
console.log(respData);
t.assertTrue(publicOrderStatusResp.status === 200);
@@ -272,22 +277,28 @@ async function testRefundApiWithFulfillmentMessage(
export async function runMerchantRefundApiTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, merchant } =
- await createSimpleTestkudosEnvironment(t);
+ const { walletClient, bank, exchange, merchant } =
+ await createSimpleTestkudosEnvironmentV2(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+ await wres.withdrawalFinishedCond;
await testRefundApiWithFulfillmentUrl(t, {
- wallet,
+ walletClient,
bank,
exchange,
merchant,
});
await testRefundApiWithFulfillmentMessage(t, {
- wallet,
+ walletClient,
bank,
exchange,
merchant,
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts
index e959e813b..afae8a899 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts
@@ -19,6 +19,7 @@
*/
import {
ConfirmPayResultType,
+ MerchantApiClient,
PreparePayResultType,
URL,
encodeCrock,
@@ -29,14 +30,13 @@ import {
BankService,
ExchangeService,
GlobalTestState,
- MerchantPrivateApi,
MerchantService,
- WalletCli,
harnessHttpLib,
} from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
+ createSimpleTestkudosEnvironmentV2,
+ createWalletDaemonWithClient,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
interface Context {
@@ -52,12 +52,21 @@ async function testWithClaimToken(
t: GlobalTestState,
c: Context,
): Promise<void> {
- const wallet = new WalletCli(t, "withclaimtoken");
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "wct",
+ });
const { bank, exchange } = c;
const { merchant, merchantBaseUrl } = c;
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+ await wres.withdrawalFinishedCond;
const sessionId = "mysession";
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -104,7 +113,7 @@ async function testWithClaimToken(
console.log(r);
}
- const preparePayResp = await wallet.client.call(
+ const preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri,
@@ -166,12 +175,9 @@ async function testWithClaimToken(
t.assertDeepEqual(httpResp.status, 202);
}
- const confirmPayRes = await wallet.client.call(
- WalletApiOperation.ConfirmPay,
- {
- proposalId: proposalId,
- },
- );
+ const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
+ proposalId: proposalId,
+ });
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
@@ -238,7 +244,7 @@ async function testWithClaimToken(
t.assertDeepEqual(httpResp.status, 200);
}
- const confirmPayRes2 = await wallet.client.call(
+ const confirmPayRes2 = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
proposalId: proposalId,
@@ -249,18 +255,14 @@ async function testWithClaimToken(
t.assertTrue(confirmPayRes2.type === ConfirmPayResultType.Done);
// Create another order with identical fulfillment URL to test the "already paid" flow
- const alreadyPaidOrderResp = await MerchantPrivateApi.createOrder(
- merchant,
- "default",
- {
- order: {
- summary: "Buy me!",
- amount: "TESTKUDOS:5",
- fulfillment_url: "https://example.com/article42",
- public_reorder_url: "https://example.com/article42-share",
- },
+ const alreadyPaidOrderResp = await merchantClient.createOrder({
+ order: {
+ summary: "Buy me!",
+ amount: "TESTKUDOS:5",
+ fulfillment_url: "https://example.com/article42",
+ public_reorder_url: "https://example.com/article42-share",
},
- );
+ });
const apOrderId = alreadyPaidOrderResp.order_id;
const apToken = alreadyPaidOrderResp.token;
@@ -307,12 +309,21 @@ async function testWithoutClaimToken(
t: GlobalTestState,
c: Context,
): Promise<void> {
- const wallet = new WalletCli(t, "withoutct");
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "wnoct",
+ });
const sessionId = "mysession2";
const { bank, exchange } = c;
const { merchant, merchantBaseUrl } = c;
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+ await wres.withdrawalFinishedCond;
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -356,7 +367,7 @@ async function testWithoutClaimToken(
console.log(r);
}
- const preparePayResp = await wallet.client.call(
+ const preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri,
@@ -422,12 +433,9 @@ async function testWithoutClaimToken(
t.assertDeepEqual(httpResp.status, 402);
}
- const confirmPayRes = await wallet.client.call(
- WalletApiOperation.ConfirmPay,
- {
- proposalId: proposalId,
- },
- );
+ const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
+ proposalId: proposalId,
+ });
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
@@ -492,7 +500,7 @@ async function testWithoutClaimToken(
t.assertDeepEqual(httpResp.status, 200);
}
- const confirmPayRes2 = await wallet.client.call(
+ const confirmPayRes2 = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
proposalId: proposalId,
@@ -503,18 +511,14 @@ async function testWithoutClaimToken(
t.assertTrue(confirmPayRes2.type === ConfirmPayResultType.Done);
// Create another order with identical fulfillment URL to test the "already paid" flow
- const alreadyPaidOrderResp = await MerchantPrivateApi.createOrder(
- merchant,
- "default",
- {
- order: {
- summary: "Buy me!",
- amount: "TESTKUDOS:5",
- fulfillment_url: "https://example.com/article42",
- public_reorder_url: "https://example.com/article42-share",
- },
+ const alreadyPaidOrderResp = await merchantClient.createOrder({
+ order: {
+ summary: "Buy me!",
+ amount: "TESTKUDOS:5",
+ fulfillment_url: "https://example.com/article42",
+ public_reorder_url: "https://example.com/article42-share",
},
- );
+ });
const apOrderId = alreadyPaidOrderResp.order_id;
const apToken = alreadyPaidOrderResp.token;
@@ -564,7 +568,7 @@ async function testWithoutClaimToken(
* specification of the endpoint.
*/
export async function runMerchantSpecPublicOrdersTest(t: GlobalTestState) {
- const { bank, exchange, merchant } = await createSimpleTestkudosEnvironment(
+ const { bank, exchange, merchant } = await createSimpleTestkudosEnvironmentV2(
t,
);
@@ -572,7 +576,9 @@ export async function runMerchantSpecPublicOrdersTest(t: GlobalTestState) {
const merchantBaseUrl = merchant.makeInstanceBaseUrl();
{
- const httpResp = await httpLib.fetch(new URL("config", merchantBaseUrl).href);
+ const httpResp = await httpLib.fetch(
+ new URL("config", merchantBaseUrl).href,
+ );
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(r.currency, "TESTKUDOS");
diff --git a/packages/taler-harness/src/integrationtests/test-pay-paid.ts b/packages/taler-harness/src/integrationtests/test-pay-paid.ts
index a377b7237..3d93f6e29 100644
--- a/packages/taler-harness/src/integrationtests/test-pay-paid.ts
+++ b/packages/taler-harness/src/integrationtests/test-pay-paid.ts
@@ -17,19 +17,20 @@
/**
* Imports.
*/
-import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
import {
- withdrawViaBank,
- createFaultInjectedMerchantTestkudosEnvironment,
-} from "../harness/helpers.js";
-import {
- PreparePayResultType,
- codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType,
+ MerchantApiClient,
+ PreparePayResultType,
URL,
+ codecForMerchantOrderStatusUnpaid,
} from "@gnu-taler/taler-util";
-import { FaultInjectionRequestContext } from "../harness/faultInjection.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { FaultInjectionRequestContext } from "../harness/faultInjection.js";
+import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
+import {
+ createFaultInjectedMerchantTestkudosEnvironment,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
/**
* Run test for the wallets repurchase detection mechanism
@@ -42,18 +43,20 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
export async function runPayPaidTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, faultyExchange, faultyMerchant } =
+ const { walletClient, bank, faultyExchange, faultyMerchant } =
await createFaultInjectedMerchantTestkudosEnvironment(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange: faultyExchange,
amount: "TESTKUDOS:20",
});
+ await wres.withdrawalFinishedCond;
+
/**
* =========================================================================
* Create an order and let the wallet pay under a session ID
@@ -65,7 +68,9 @@ export async function runPayPaidTest(t: GlobalTestState) {
const merchant = faultyMerchant;
- let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
+ let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -74,7 +79,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@@ -98,7 +103,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.client.call(
+ let preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: pubUnpaidStatus.taler_pay_uri,
@@ -121,12 +126,9 @@ export async function runPayPaidTest(t: GlobalTestState) {
publicOrderStatusResp.json(),
);
- const confirmPayRes = await wallet.client.call(
- WalletApiOperation.ConfirmPay,
- {
- proposalId: proposalId,
- },
- );
+ const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
+ proposalId: proposalId,
+ });
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
@@ -147,7 +149,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
* =========================================================================
*/
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-two",
});
@@ -174,7 +176,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
},
});
- let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", {
+ let orderRespTwo = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -183,20 +185,17 @@ export async function runPayPaidTest(t: GlobalTestState) {
},
});
- let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderRespTwo.order_id,
- sessionId: "mysession-two",
- },
- );
+ let orderStatusTwo = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderRespTwo.order_id,
+ sessionId: "mysession-two",
+ });
t.assertTrue(orderStatusTwo.order_status === "unpaid");
// Pay with new taler://pay URI, which should
// have the new session ID!
// Wallet should now automatically re-play payment.
- preparePayResp = await wallet.client.call(
+ preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: orderStatusTwo.taler_pay_uri,
diff --git a/packages/taler-harness/src/integrationtests/test-payment-abort.ts b/packages/taler-harness/src/integrationtests/test-payment-abort.ts
index 05ca7a543..fe7ecbcd7 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-abort.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-abort.ts
@@ -17,41 +17,46 @@
/**
* Imports.
*/
-import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
import {
- withdrawViaBank,
- createFaultInjectedMerchantTestkudosEnvironment,
-} from "../harness/helpers.js";
-import { FaultInjectionRequestContext } from "../harness/faultInjection.js";
-import {
- codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType,
- j2s,
+ MerchantApiClient,
PreparePayResultType,
TalerErrorCode,
TalerErrorDetail,
URL,
+ codecForMerchantOrderStatusUnpaid,
+ j2s,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { FaultInjectionRequestContext } from "../harness/faultInjection.js";
+import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
+import {
+ createFaultInjectedMerchantTestkudosEnvironment,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
export async function runPaymentAbortTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, faultyMerchant, faultyExchange } =
+ const { walletClient, bank, exchange, faultyMerchant, faultyExchange } =
await createFaultInjectedMerchantTestkudosEnvironment(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange: faultyExchange,
amount: "TESTKUDOS:20",
});
- const merchant = faultyMerchant;
+ await wres.withdrawalFinishedCond;
- let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const merchantClient = new MerchantApiClient(
+ faultyMerchant.makeInstanceBaseUrl(),
+ );
+
+ let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -60,7 +65,7 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@@ -84,7 +89,7 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.client.call(
+ let preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: pubUnpaidStatus.taler_pay_uri,
@@ -124,7 +129,7 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
},
});
- const confirmPayResp = await wallet.client.call(
+ const confirmPayResp = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
proposalId,
@@ -134,19 +139,16 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
// Can't have succeeded yet, but network error results in "pending" state.
t.assertDeepEqual(confirmPayResp.type, ConfirmPayResultType.Pending);
- const txns = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+ const txns = await walletClient.call(WalletApiOperation.GetTransactions, {});
console.log(j2s(txns));
- await wallet.client.call(WalletApiOperation.AbortTransaction, {
+ await walletClient.call(WalletApiOperation.AbortTransaction, {
transactionId: txns.transactions[1].transactionId,
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- const txns2 = await wallet.client.call(
- WalletApiOperation.GetTransactions,
- {},
- );
+ const txns2 = await walletClient.call(WalletApiOperation.GetTransactions, {});
console.log(j2s(txns2));
const txTypes = txns2.transactions.map((x) => x.type);
diff --git a/packages/taler-harness/src/integrationtests/test-payment-claim.ts b/packages/taler-harness/src/integrationtests/test-payment-claim.ts
index 3e52cb5dd..b5ed89ec3 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-claim.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-claim.ts
@@ -17,13 +17,13 @@
/**
* Imports.
*/
-import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
-import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
- GlobalTestState,
- MerchantPrivateApi,
- WalletCli,
-} from "../harness/harness.js";
+ MerchantApiClient,
+ PreparePayResultType,
+ TalerErrorCode,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState, WalletCli } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -38,6 +38,8 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
const walletTwo = new WalletCli(t, "two");
// Withdraw digital cash into the wallet.
@@ -53,7 +55,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -61,7 +63,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -94,7 +96,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-payment-expired.ts b/packages/taler-harness/src/integrationtests/test-payment-expired.ts
new file mode 100644
index 000000000..176fc74f7
--- /dev/null
+++ b/packages/taler-harness/src/integrationtests/test-payment-expired.ts
@@ -0,0 +1,131 @@
+/*
+ This file is part of GNU Taler
+ (C) 2020 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Imports.
+ */
+import {
+ AbsoluteTime,
+ ConfirmPayResultType,
+ Duration,
+ MerchantApiClient,
+ MerchantContractTerms,
+ PreparePayResultType,
+ j2s,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState } from "../harness/harness.js";
+import {
+ applyTimeTravelV2,
+ createSimpleTestkudosEnvironmentV2,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
+
+/**
+ * Run a test for the following scenario:
+ *
+ * - Wallet claims an order
+ * - Merchant goes down
+ * - Wallet tried to pay, but it fails as the merchant is unavailable
+ * - The order expires
+ * - The merchant goes back up again
+ * - Instead of trying to get an abort-refund, the wallet notices that
+ * the order is expired, puts the transaction into "failed",
+ * refreshes allocated coins and thus raises the balance again.
+ */
+export async function runPaymentExpiredTest(t: GlobalTestState) {
+ // Set up test environment
+
+ const { walletClient, bank, exchange, merchant } =
+ await createSimpleTestkudosEnvironmentV2(t);
+
+ // Withdraw digital cash into the wallet.
+
+ await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
+
+ // Order that can only be paid within five minutes.
+ const order: Partial<MerchantContractTerms> = {
+ summary: "Buy me!",
+ amount: "TESTKUDOS:5",
+ fulfillment_url: "taler://fulfillment-success/thx",
+ pay_deadline: AbsoluteTime.toProtocolTimestamp(
+ AbsoluteTime.addDuration(
+ AbsoluteTime.now(),
+ Duration.fromSpec({ minutes: 5 }),
+ ),
+ ),
+ };
+
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
+ const orderResp = await merchantClient.createOrder({
+ order,
+ });
+
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ });
+
+ t.assertTrue(orderStatus.order_status === "unpaid");
+
+ const preparePayResult = await walletClient.call(
+ WalletApiOperation.PreparePayForUri,
+ {
+ talerPayUri: orderStatus.taler_pay_uri,
+ },
+ );
+
+ t.assertDeepEqual(
+ preparePayResult.status,
+ PreparePayResultType.PaymentPossible,
+ );
+
+ await applyTimeTravelV2(
+ Duration.toMilliseconds(Duration.fromSpec({ hours: 1 })),
+ { walletClient, exchange, merchant },
+ );
+
+ const confirmPayResult = await walletClient.call(
+ WalletApiOperation.ConfirmPay,
+ { transactionId: preparePayResult.transactionId },
+ );
+ console.log("confirm pay result:");
+ console.log(j2s(confirmPayResult));
+ t.assertDeepEqual(confirmPayResult.type, ConfirmPayResultType.Pending);
+ await walletClient.call(WalletApiOperation.AbortTransaction, {
+ transactionId: preparePayResult.transactionId,
+ });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
+
+ const bal = await walletClient.call(WalletApiOperation.GetBalances, {});
+ console.log(bal);
+
+ t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:18.93");
+
+ const txns = await walletClient.call(WalletApiOperation.GetTransactions, {
+ includeRefreshes: true,
+ });
+ console.log(j2s(txns));
+}
+
+runPaymentExpiredTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-payment-fault.ts b/packages/taler-harness/src/integrationtests/test-payment-fault.ts
index c1438a419..e57427fac 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-fault.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-fault.ts
@@ -22,27 +22,26 @@
* Imports.
*/
import {
- GlobalTestState,
- MerchantService,
- ExchangeService,
- setupDb,
- BankService,
- WalletCli,
- MerchantPrivateApi,
- getPayto,
-} from "../harness/harness.js";
+ BankAccessApiClient,
+ CoreApiResponse,
+ MerchantApiClient,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { defaultCoinConfig } from "../harness/denomStructures.js";
import {
FaultInjectedExchangeService,
FaultInjectionRequestContext,
FaultInjectionResponseContext,
} from "../harness/faultInjection.js";
-import { CoreApiResponse } from "@gnu-taler/taler-util";
-import { defaultCoinConfig } from "../harness/denomStructures.js";
import {
- WalletApiOperation,
- BankApi,
- BankAccessApi,
-} from "@gnu-taler/taler-wallet-core";
+ BankService,
+ ExchangeService,
+ GlobalTestState,
+ MerchantService,
+ WalletCli,
+ getPayto,
+ setupDb,
+} from "../harness/harness.js";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -114,22 +113,25 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
console.log("setup done!");
const wallet = new WalletCli(t);
// Create withdrawal operation
- const user = await BankApi.createRandomBankUser(bank);
- const wop = await BankAccessApi.createWithdrawalOperation(
- bank,
- user,
+ const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
+
+ const user = await bankClient.createRandomBankUser();
+ const wop = await bankClient.createWithdrawalOperation(
+ user.username,
"TESTKUDOS:20",
);
@@ -151,7 +153,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Confirm it
- await BankApi.confirmWithdrawalOperation(bank, user, wop);
+ await bankClient.confirmWithdrawalOperation(user.username, wop);
await wallet.runUntilDone();
@@ -161,7 +163,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -169,7 +171,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -218,7 +220,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts b/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts
index 6373c2393..65fd3a562 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts
@@ -17,9 +17,9 @@
/**
* Imports.
*/
-import { PreparePayResultType } from "@gnu-taler/taler-util";
+import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -46,9 +46,11 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -56,7 +58,7 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -102,7 +104,7 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts
index 25e19ae8e..4ef5e3bff 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts
@@ -17,19 +17,21 @@
/**
* Imports.
*/
+import { MerchantApiClient } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
import {
- GlobalTestState,
- setupDb,
BankService,
ExchangeService,
+ GlobalTestState,
MerchantService,
- WalletCli,
- MerchantPrivateApi,
getPayto,
+ setupDb,
} from "../harness/harness.js";
-import { withdrawViaBank } from "../harness/helpers.js";
-import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
-import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import {
+ createWalletDaemonWithClient,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
async function setupTest(t: GlobalTestState): Promise<{
merchant: MerchantService;
@@ -82,13 +84,13 @@ async function setupTest(t: GlobalTestState): Promise<{
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -113,15 +115,26 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
const { merchant, bank, exchange } = await setupTest(t);
- const wallet = new WalletCli(t);
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "default",
+ });
+
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:100" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:100",
+ });
+
+ await wres.withdrawalFinishedCond;
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:80",
@@ -129,7 +142,7 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -137,18 +150,17 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
+ const r1 = await walletClient.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- await wallet.client.call(WalletApiOperation.ConfirmPay, {
- // FIXME: should be validated, don't cast!
- proposalId: r1.proposalId,
+ await walletClient.call(WalletApiOperation.ConfirmPay, {
+ transactionId: r1.transactionId,
});
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-payment-share.ts b/packages/taler-harness/src/integrationtests/test-payment-share.ts
index 156571372..c4a82c917 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-share.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-share.ts
@@ -19,10 +19,11 @@
*/
import {
ConfirmPayResultType,
+ MerchantApiClient,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient,
@@ -41,6 +42,8 @@ export async function runPaymentShareTest(t: GlobalTestState) {
merchant,
} = await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
walletClient: firstWallet,
@@ -62,7 +65,7 @@ export async function runPaymentShareTest(t: GlobalTestState) {
});
await secondWallet.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- //create two orders to pay
+ // create two orders to pay
async function createOrder(amount: string) {
const order = {
summary: "Buy me!",
@@ -70,26 +73,16 @@ export async function runPaymentShareTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- const instance = "default";
const args = { order };
const auth = {};
- const orderResp = await MerchantPrivateApi.createOrder(
- merchant,
- instance,
- {
- order: args.order,
- },
- auth,
- );
+ const orderResp = await merchantClient.createOrder({
+ order: args.order,
+ });
- const orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- },
- auth,
- );
+ const orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ });
t.assertTrue(orderStatus.order_status === "unpaid");
return { id: orderResp.order_id, uri: orderStatus.taler_pay_uri };
diff --git a/packages/taler-harness/src/integrationtests/test-payment-template.ts b/packages/taler-harness/src/integrationtests/test-payment-template.ts
index 707be52e1..e77236a9a 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-template.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-template.ts
@@ -17,12 +17,17 @@
/**
* Imports.
*/
-import { ConfirmPayResultType, Duration, PreparePayResultType } from "@gnu-taler/taler-util";
+import {
+ ConfirmPayResultType,
+ Duration,
+ MerchantApiClient,
+ PreparePayResultType,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
- withdrawViaBankV2
+ withdrawViaBankV2,
} from "../harness/helpers.js";
/**
@@ -34,7 +39,9 @@ export async function runPaymentTemplateTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
- await MerchantPrivateApi.createTemplate(merchant, "default", {
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
+ await merchantClient.createTemplate({
template_id: "template1",
template_description: "my test template",
template_contract: {
@@ -50,7 +57,12 @@ export async function runPaymentTemplateTest(t: GlobalTestState) {
// Withdraw digital cash into the wallet.
- const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
await wres.withdrawalFinishedCond;
// Request a template payment
@@ -79,13 +91,10 @@ export async function runPaymentTemplateTest(t: GlobalTestState) {
// Check if payment was successful.
- const orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: preparePayResult.contractTerms.order_id,
- instance: "default",
- },
- );
+ const orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: preparePayResult.contractTerms.order_id,
+ instance: "default",
+ });
t.assertTrue(orderStatus.order_status === "paid");
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
diff --git a/packages/taler-harness/src/integrationtests/test-payment-transient.ts b/packages/taler-harness/src/integrationtests/test-payment-transient.ts
index c2a8e37c5..1911b5e92 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-transient.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-transient.ts
@@ -19,6 +19,7 @@
*/
import {
ConfirmPayResultType,
+ MerchantApiClient,
PreparePayResultType,
TalerErrorCode,
TalerErrorDetail,
@@ -27,13 +28,12 @@ import {
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { FaultInjectionResponseContext } from "../harness/faultInjection.js";
-import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
+import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
import {
createFaultInjectedMerchantTestkudosEnvironment,
- withdrawViaBank,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
-
/**
* Run test for a payment where the merchant has a transient
* failure in /pay
@@ -41,21 +41,25 @@ import {
export async function runPaymentTransientTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, faultyMerchant, faultyExchange } =
+ const { walletClient, bank, faultyMerchant, faultyExchange } =
await createFaultInjectedMerchantTestkudosEnvironment(t);
+ const merchantClient = new MerchantApiClient(
+ faultyMerchant.makeInstanceBaseUrl(),
+ );
+
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, {
- wallet,
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange: faultyExchange,
amount: "TESTKUDOS:20",
});
- const merchant = faultyMerchant;
+ await wres.withdrawalFinishedCond;
- let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -64,7 +68,7 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@@ -88,7 +92,7 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.client.call(
+ let preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: pubUnpaidStatus.taler_pay_uri,
@@ -136,7 +140,7 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
},
});
- const confirmPayResp = await wallet.client.call(
+ const confirmPayResp = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
proposalId,
@@ -148,7 +152,7 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
t.assertTrue(confirmPayResp.type === ConfirmPayResultType.Pending);
t.assertTrue(faultInjected);
- const confirmPayRespTwo = await wallet.client.call(
+ const confirmPayRespTwo = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
proposalId,
diff --git a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
index 5f63d4fac..247ec9cad 100644
--- a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
+++ b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
@@ -17,14 +17,15 @@
/**
* Imports.
*/
-import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
import {
- PreparePayResultType,
- codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType,
+ MerchantApiClient,
+ PreparePayResultType,
URL,
+ codecForMerchantOrderStatusUnpaid,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -39,6 +40,8 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@@ -59,7 +62,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
* =========================================================================
*/
- let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -70,7 +73,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const firstOrderId = orderResp.order_id;
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@@ -82,7 +85,9 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(orderStatus.already_paid_order_id === undefined);
let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
- let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
+ let publicOrderStatusResp = await harnessHttpLib.fetch(
+ publicOrderStatusUrl.href,
+ );
if (publicOrderStatusResp.status != 402) {
throw Error(
@@ -142,7 +147,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
* =========================================================================
*/
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-two",
});
@@ -169,7 +174,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
* =========================================================================
*/
- orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -181,7 +186,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const secondOrderId = orderResp.order_id;
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: secondOrderId,
sessionId: "mysession-three",
});
@@ -206,7 +211,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// The first order should now be paid under "mysession-three",
// as the wallet did re-purchase detection
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: firstOrderId,
sessionId: "mysession-three",
});
@@ -215,7 +220,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// Check that with a completely new session ID, the status would NOT
// be paid.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: firstOrderId,
sessionId: "mysession-four",
});
diff --git a/packages/taler-harness/src/integrationtests/test-peer-repair.ts b/packages/taler-harness/src/integrationtests/test-peer-repair.ts
index b09bff2dc..d457ce1e5 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-repair.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-repair.ts
@@ -130,7 +130,7 @@ export async function runPeerRepairTest(t: GlobalTestState) {
);
await wallet2.client.call(WalletApiOperation.ConfirmPeerPushCredit, {
- peerPushPaymentIncomingId: resp2.peerPushPaymentIncomingId,
+ peerPushCreditId: resp2.peerPushCreditId,
});
await peerPushCreditDone1Cond;
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
index 5b55b1de1..25c000808 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
@@ -123,7 +123,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
);
await wallet2.client.call(WalletApiOperation.ConfirmPeerPullDebit, {
- peerPullPaymentIncomingId: checkResp.peerPullPaymentIncomingId,
+ peerPullDebitId: checkResp.peerPullDebitId,
});
await peerPullCreditDoneCond;
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
index 26f70a5cc..018fa2020 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
@@ -126,7 +126,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
const acceptResp = await w2.walletClient.call(
WalletApiOperation.ConfirmPeerPushCredit,
{
- peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
+ peerPushCreditId: checkResp.peerPushCreditId,
},
);
diff --git a/packages/taler-harness/src/integrationtests/test-refund-auto.ts b/packages/taler-harness/src/integrationtests/test-refund-auto.ts
index 5648835d5..e8bfecefa 100644
--- a/packages/taler-harness/src/integrationtests/test-refund-auto.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund-auto.ts
@@ -17,9 +17,13 @@
/**
* Imports.
*/
-import { Duration, durationFromSpec } from "@gnu-taler/taler-util";
+import {
+ Duration,
+ MerchantApiClient,
+ durationFromSpec,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -34,6 +38,8 @@ export async function runRefundAutoTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@@ -46,7 +52,7 @@ export async function runRefundAutoTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -60,7 +66,7 @@ export async function runRefundAutoTest(t: GlobalTestState) {
),
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -78,13 +84,13 @@ export async function runRefundAutoTest(t: GlobalTestState) {
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
- const ref = await MerchantPrivateApi.giveRefund(merchant, {
+ const ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
diff --git a/packages/taler-harness/src/integrationtests/test-refund-gone.ts b/packages/taler-harness/src/integrationtests/test-refund-gone.ts
index 5f226c7dd..d50919934 100644
--- a/packages/taler-harness/src/integrationtests/test-refund-gone.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund-gone.ts
@@ -17,18 +17,19 @@
/**
* Imports.
*/
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
-import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
- applyTimeTravel,
-} from "../harness/helpers.js";
import {
AbsoluteTime,
Duration,
+ MerchantApiClient,
durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState } from "../harness/harness.js";
+import {
+ applyTimeTravelV2,
+ createSimpleTestkudosEnvironmentV2,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -36,16 +37,25 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
export async function runRefundGoneTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, merchant } =
- await createSimpleTestkudosEnvironment(t);
+ const { walletClient, bank, exchange, merchant } =
+ await createSimpleTestkudosEnvironmentV2(t);
+
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+
+ await wres.withdrawalFinishedCond;
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -64,7 +74,7 @@ export async function runRefundGoneTest(t: GlobalTestState) {
),
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -72,17 +82,17 @@ export async function runRefundGoneTest(t: GlobalTestState) {
// Make wallet pay for the order
- const r1 = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
+ const r1 = await walletClient.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
- const r2 = await wallet.client.call(WalletApiOperation.ConfirmPay, {
- proposalId: r1.proposalId,
+ const r2 = await walletClient.call(WalletApiOperation.ConfirmPay, {
+ transactionId: r1.transactionId,
});
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -90,11 +100,14 @@ export async function runRefundGoneTest(t: GlobalTestState) {
console.log(orderStatus);
- await applyTimeTravel(durationFromSpec({ hours: 1 }), { exchange, wallet });
+ await applyTimeTravelV2(
+ Duration.toMilliseconds(Duration.fromSpec({ hours: 1 })),
+ { exchange, walletClient: walletClient },
+ );
await exchange.runAggregatorOnce();
- const ref = await MerchantPrivateApi.giveRefund(merchant, {
+ const ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
@@ -103,16 +116,16 @@ export async function runRefundGoneTest(t: GlobalTestState) {
console.log(ref);
- await wallet.client.call(WalletApiOperation.StartRefundQuery, {
+ await walletClient.call(WalletApiOperation.StartRefundQuery, {
transactionId: r1.transactionId,
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- let r = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ let r = await walletClient.call(WalletApiOperation.GetBalances, {});
console.log(JSON.stringify(r, undefined, 2));
- const r3 = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+ const r3 = await walletClient.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(r3, undefined, 2));
await t.shutdown();
diff --git a/packages/taler-harness/src/integrationtests/test-refund-incremental.ts b/packages/taler-harness/src/integrationtests/test-refund-incremental.ts
index 8ac0948f2..e7e041ce6 100644
--- a/packages/taler-harness/src/integrationtests/test-refund-incremental.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund-incremental.ts
@@ -20,15 +20,12 @@
import {
Amounts,
Duration,
+ MerchantApiClient,
TransactionType,
durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import {
- GlobalTestState,
- MerchantPrivateApi,
- delayMs,
-} from "../harness/harness.js";
+import { GlobalTestState, delayMs } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -43,6 +40,8 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@@ -56,7 +55,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:10",
@@ -67,7 +66,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
),
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -85,13 +84,13 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
- let ref = await MerchantPrivateApi.giveRefund(merchant, {
+ let ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:2.5",
instance: "default",
justification: "foo",
@@ -120,7 +119,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// refund will be grouped with the previous one.
await delayMs(1200);
- ref = await MerchantPrivateApi.giveRefund(merchant, {
+ ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "bar",
@@ -133,7 +132,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// refund will be grouped with the previous one.
await delayMs(1200);
- ref = await MerchantPrivateApi.giveRefund(merchant, {
+ ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:10",
instance: "default",
justification: "bar",
@@ -153,7 +152,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
console.log(wr);
}
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-refund.ts b/packages/taler-harness/src/integrationtests/test-refund.ts
index 44848d88a..aeeb91f38 100644
--- a/packages/taler-harness/src/integrationtests/test-refund.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund.ts
@@ -20,11 +20,12 @@
import {
Duration,
durationFromSpec,
+ MerchantApiClient,
NotificationType,
TransactionMajorState,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -43,6 +44,8 @@ export async function runRefundTest(t: GlobalTestState) {
merchant,
} = await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
// Withdraw digital cash into the wallet.
const withdrawalRes = await withdrawViaBankV2(t, {
@@ -56,7 +59,7 @@ export async function runRefundTest(t: GlobalTestState) {
// Set up order.
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@@ -67,7 +70,7 @@ export async function runRefundTest(t: GlobalTestState) {
),
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@@ -85,13 +88,13 @@ export async function runRefundTest(t: GlobalTestState) {
// Check if payment was successful.
- orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
- const ref = await MerchantPrivateApi.giveRefund(merchant, {
+ const ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
diff --git a/packages/taler-harness/src/integrationtests/test-revocation.ts b/packages/taler-harness/src/integrationtests/test-revocation.ts
index 04707e51a..0cb6987ad 100644
--- a/packages/taler-harness/src/integrationtests/test-revocation.ts
+++ b/packages/taler-harness/src/integrationtests/test-revocation.ts
@@ -28,20 +28,22 @@ import {
BankService,
delayMs,
getPayto,
+ WalletClient,
} from "../harness/harness.js";
import {
- withdrawViaBank,
- makeTestPayment,
- SimpleTestEnvironment,
+ SimpleTestEnvironmentNg,
+ createWalletDaemonWithClient,
+ makeTestPaymentV2,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
async function revokeAllWalletCoins(req: {
- wallet: WalletCli;
+ walletClient: WalletClient;
exchange: ExchangeService;
merchant: MerchantService;
}): Promise<void> {
- const { wallet, exchange, merchant } = req;
- const coinDump = await wallet.client.call(WalletApiOperation.DumpCoins, {});
+ const { walletClient, exchange, merchant } = req;
+ const coinDump = await walletClient.call(WalletApiOperation.DumpCoins, {});
console.log(coinDump);
const usedDenomHashes = new Set<string>();
for (const coin of coinDump.coins) {
@@ -60,7 +62,7 @@ async function revokeAllWalletCoins(req: {
async function createTestEnvironment(
t: GlobalTestState,
-): Promise<SimpleTestEnvironment> {
+): Promise<SimpleTestEnvironmentNg> {
const db = await setupDb(t);
const bank = await BankService.create(t, {
@@ -120,13 +122,13 @@ async function createTestEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -136,11 +138,19 @@ async function createTestEnvironment(
const wallet = new WalletCli(t);
+ const { walletService, walletClient } = await createWalletDaemonWithClient(
+ t,
+ {
+ name: "default",
+ },
+ );
+
return {
commonDb: db,
exchange,
merchant,
- wallet,
+ walletClient,
+ walletService,
bank,
exchangeBankAccount,
};
@@ -152,24 +162,30 @@ async function createTestEnvironment(
export async function runRevocationTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, merchant } = await createTestEnvironment(t);
+ const { walletClient, bank, exchange, merchant } =
+ await createTestEnvironment(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:15",
+ });
+ await wres.withdrawalFinishedCond;
console.log("revoking first time");
- await revokeAllWalletCoins({ wallet, exchange, merchant });
+ await revokeAllWalletCoins({ walletClient, exchange, merchant });
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
// is implemented.
- await wallet.client.call(WalletApiOperation.AddExchange, {
+ await walletClient.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
forceUpdate: true,
});
- await wallet.runUntilDone();
- await wallet.runUntilDone();
- const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
+ const bal = await walletClient.call(WalletApiOperation.GetBalances, {});
console.log("wallet balance", bal);
const order = {
@@ -178,39 +194,43 @@ export async function runRevocationTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- await makeTestPayment(t, { wallet, merchant, order });
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
- wallet.deleteDatabase();
+ await walletClient.call(WalletApiOperation.ClearDb, {});
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
+ await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:15",
+ });
- const coinDump = await wallet.client.call(WalletApiOperation.DumpCoins, {});
+ const coinDump = await walletClient.call(WalletApiOperation.DumpCoins, {});
console.log(coinDump);
const coinPubList = coinDump.coins.map((x) => x.coin_pub);
- await wallet.client.call(WalletApiOperation.ForceRefresh, {
+ await walletClient.call(WalletApiOperation.ForceRefresh, {
coinPubList,
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
console.log("revoking second time");
- await revokeAllWalletCoins({ wallet, exchange, merchant });
+ await revokeAllWalletCoins({ walletClient, exchange, merchant });
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
// is implemented.
- await wallet.client.call(WalletApiOperation.AddExchange, {
+ await walletClient.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
forceUpdate: true,
});
- await wallet.runUntilDone();
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
{
- const bal = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ const bal = await walletClient.call(WalletApiOperation.GetBalances, {});
console.log("wallet balance", bal);
}
- await makeTestPayment(t, { wallet, merchant, order });
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
}
runRevocationTest.timeoutMs = 120000;
runRevocationTest.suites = ["wallet"];
-runRevocationTest.excludeByDefault = true; \ No newline at end of file
+runRevocationTest.experimental = true;
diff --git a/packages/taler-harness/src/integrationtests/test-stored-backups.ts b/packages/taler-harness/src/integrationtests/test-stored-backups.ts
new file mode 100644
index 000000000..a3a5e6ca3
--- /dev/null
+++ b/packages/taler-harness/src/integrationtests/test-stored-backups.ts
@@ -0,0 +1,112 @@
+/*
+ This file is part of GNU Taler
+ (C) 2023 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Imports.
+ */
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState } from "../harness/harness.js";
+import {
+ withdrawViaBankV2,
+ makeTestPaymentV2,
+ useSharedTestkudosEnvironment,
+} from "../harness/helpers.js";
+
+/**
+ * Test stored backup wallet-core API.
+ */
+export async function runStoredBackupsTest(t: GlobalTestState) {
+ // Set up test environment
+
+ const { walletClient, bank, exchange, merchant } =
+ await useSharedTestkudosEnvironment(t);
+
+ // Withdraw digital cash into the wallet.
+
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+
+ await wres;
+
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
+
+ const sb1Resp = await walletClient.call(
+ WalletApiOperation.CreateStoredBackup,
+ {},
+ );
+ const sbList = await walletClient.call(
+ WalletApiOperation.ListStoredBackups,
+ {},
+ );
+ t.assertTrue(sbList.storedBackups.length === 1);
+ t.assertTrue(sbList.storedBackups[0].name === sb1Resp.name);
+
+ const order = {
+ summary: "Buy me!",
+ amount: "TESTKUDOS:5",
+ fulfillment_url: "taler://fulfillment-success/thx",
+ };
+
+ await makeTestPaymentV2(t, { walletClient, merchant, order });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
+
+ const txn1 = await walletClient.call(WalletApiOperation.GetTransactions, {});
+ t.assertDeepEqual(txn1.transactions.length, 2);
+
+ // Recover from the stored backup now.
+
+ const sb2Resp = await walletClient.call(
+ WalletApiOperation.CreateStoredBackup,
+ {},
+ );
+
+ console.log("recovering backup");
+
+ await walletClient.call(WalletApiOperation.RecoverStoredBackup, {
+ name: sb1Resp.name,
+ });
+
+ console.log("first recovery done");
+
+ // Recovery went well, now we can delete the backup
+ // of the old database we stored before importing.
+ {
+ const sbl1 = await walletClient.call(
+ WalletApiOperation.ListStoredBackups,
+ {},
+ );
+ t.assertTrue(sbl1.storedBackups.length === 2);
+
+ await walletClient.call(WalletApiOperation.DeleteStoredBackup, {
+ name: sb1Resp.name,
+ });
+ const sbl2 = await walletClient.call(
+ WalletApiOperation.ListStoredBackups,
+ {},
+ );
+ t.assertTrue(sbl2.storedBackups.length === 1);
+ }
+
+ const txn2 = await walletClient.call(WalletApiOperation.GetTransactions, {});
+ // We only have the withdrawal after restoring
+ t.assertDeepEqual(txn2.transactions.length, 1);
+}
+
+runStoredBackupsTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
index 50f9cbcd3..b94f7757c 100644
--- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
+++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
@@ -21,6 +21,7 @@ import {
ConfirmPayResultType,
Duration,
durationFromSpec,
+ MerchantApiClient,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import {
@@ -31,42 +32,16 @@ import { makeNoFeeCoinConfig } from "../harness/denomStructures.js";
import {
BankService,
ExchangeService,
+ getPayto,
GlobalTestState,
- MerchantPrivateApi,
MerchantService,
setupDb,
- WalletCli,
- getPayto,
} from "../harness/harness.js";
-import { startWithdrawViaBank, withdrawViaBank } from "../harness/helpers.js";
-
-async function applyTimeTravel(
- timetravelDuration: Duration,
- s: {
- exchange?: ExchangeService;
- merchant?: MerchantService;
- wallet?: WalletCli;
- },
-): Promise<void> {
- if (s.exchange) {
- await s.exchange.stop();
- s.exchange.setTimetravel(timetravelDuration);
- await s.exchange.start();
- await s.exchange.pingUntilAvailable();
- }
-
- if (s.merchant) {
- await s.merchant.stop();
- s.merchant.setTimetravel(timetravelDuration);
- await s.merchant.start();
- await s.merchant.pingUntilAvailable();
- }
-
- if (s.wallet) {
- console.log("setting wallet time travel to", timetravelDuration);
- s.wallet.setTimetravel(timetravelDuration);
- }
-}
+import {
+ applyTimeTravelV2,
+ createWalletDaemonWithClient,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
/**
* Basic time travel test.
@@ -119,13 +94,13 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
});
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "minst1",
name: "minst1",
paytoUris: [getPayto("minst1")],
@@ -133,54 +108,70 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
console.log("setup done!");
- const wallet = new WalletCli(t);
+ const { walletClient } = await createWalletDaemonWithClient(t, {
+ name: "w1",
+ });
+
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
+ const wres = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:15",
+ });
+ await wres.withdrawalFinishedCond;
// Travel into the future, the deposit expiration is two years
// into the future.
console.log("applying first time travel");
- await applyTimeTravel(durationFromSpec({ days: 400 }), {
- wallet,
- exchange,
- merchant,
- });
+ await applyTimeTravelV2(
+ Duration.toMilliseconds(durationFromSpec({ days: 400 })),
+ {
+ walletClient,
+ exchange,
+ merchant,
+ },
+ );
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
let p: PendingOperationsResponse;
- p = await wallet.client.call(WalletApiOperation.GetPendingOperations, {});
+ p = await walletClient.call(WalletApiOperation.GetPendingOperations, {});
console.log("pending operations after first time travel");
console.log(JSON.stringify(p, undefined, 2));
- await startWithdrawViaBank(t, {
- wallet,
+ await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
// Travel into the future, the deposit expiration is two years
// into the future.
console.log("applying second time travel");
- await applyTimeTravel(durationFromSpec({ years: 2, months: 6 }), {
- wallet,
- exchange,
- merchant,
- });
+ await applyTimeTravelV2(
+ Duration.toMilliseconds(durationFromSpec({ years: 2, months: 6 })),
+ {
+ walletClient,
+ exchange,
+ merchant,
+ },
+ );
// At this point, the original coins should've been refreshed.
// It would be too late to refresh them now, as we're past
// the two year deposit expiration.
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order: {
fulfillment_url: "http://example.com",
summary: "foo",
@@ -188,17 +179,14 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
},
});
- const orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- instance: "default",
- },
- );
+ const orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ instance: "default",
+ });
t.assertTrue(orderStatus.order_status === "unpaid");
- const r = await wallet.client.call(WalletApiOperation.PreparePayForUri, {
+ const r = await walletClient.call(WalletApiOperation.PreparePayForUri, {
talerPayUri: orderStatus.taler_pay_uri,
});
@@ -206,7 +194,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
t.assertTrue(r.status === PreparePayResultType.PaymentPossible);
- const cpr = await wallet.client.call(WalletApiOperation.ConfirmPay, {
+ const cpr = await walletClient.call(WalletApiOperation.ConfirmPay, {
proposalId: r.proposalId,
});
diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-withdraw.ts b/packages/taler-harness/src/integrationtests/test-timetravel-withdraw.ts
index ca3e67647..e594d2d72 100644
--- a/packages/taler-harness/src/integrationtests/test-timetravel-withdraw.ts
+++ b/packages/taler-harness/src/integrationtests/test-timetravel-withdraw.ts
@@ -17,13 +17,16 @@
/**
* Imports.
*/
-import { Duration, TransactionMajorState, TransactionType } from "@gnu-taler/taler-util";
+import {
+ Duration,
+ TransactionMajorState,
+ TransactionType,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
- startWithdrawViaBank,
- withdrawViaBank,
+ createSimpleTestkudosEnvironmentV2,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
/**
@@ -32,12 +35,18 @@ import {
export async function runTimetravelWithdrawTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, merchant } =
- await createSimpleTestkudosEnvironment(t);
+ const { walletClient, bank, exchange, merchant } =
+ await createSimpleTestkudosEnvironmentV2(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
+ const wres1 = await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:15",
+ });
+ await wres1.withdrawalFinishedCond;
// Travel 400 days into the future,
// as the deposit expiration is two years
@@ -47,21 +56,21 @@ export async function runTimetravelWithdrawTest(t: GlobalTestState) {
};
await exchange.stop();
- exchange.setTimetravel(timetravelDuration);
+ exchange.setTimetravel(Duration.toMilliseconds(timetravelDuration));
await exchange.start();
await exchange.pingUntilAvailable();
await exchange.keyup();
await merchant.stop();
- merchant.setTimetravel(timetravelDuration);
+ merchant.setTimetravel(Duration.toMilliseconds(timetravelDuration));
await merchant.start();
await merchant.pingUntilAvailable();
console.log("starting withdrawal via bank");
// This should fail, as the wallet didn't time travel yet.
- await startWithdrawViaBank(t, {
- wallet,
+ await withdrawViaBankV2(t, {
+ walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
@@ -71,10 +80,7 @@ export async function runTimetravelWithdrawTest(t: GlobalTestState) {
// Check that transactions are correct for the failed withdrawal
{
- console.log("running until done (should run into maxRetries limit)");
- await wallet.runUntilDone({ maxRetries: 5 });
- console.log("wallet done running");
- const transactions = await wallet.client.call(
+ const transactions = await walletClient.call(
WalletApiOperation.GetTransactions,
{},
);
@@ -88,7 +94,9 @@ export async function runTimetravelWithdrawTest(t: GlobalTestState) {
// Now we also let the wallet time travel
- wallet.setTimetravel(timetravelDuration);
+ walletClient.call(WalletApiOperation.TestingSetTimetravel, {
+ offsetMs: Duration.toMilliseconds(timetravelDuration),
+ });
// This doesn't work yet, see https://bugs.taler.net/n/6585
diff --git a/packages/taler-harness/src/integrationtests/test-tipping.ts b/packages/taler-harness/src/integrationtests/test-tipping.ts
index 53d7f08c8..4140311ab 100644
--- a/packages/taler-harness/src/integrationtests/test-tipping.ts
+++ b/packages/taler-harness/src/integrationtests/test-tipping.ts
@@ -19,17 +19,15 @@
*/
import {
BankAccessApiClient,
- WalletApiOperation,
+ MerchantApiClient,
+ TransactionMajorState,
WireGatewayApiClient,
-} from "@gnu-taler/taler-wallet-core";
+} from "@gnu-taler/taler-util";
import {
- GlobalTestState,
- MerchantApiClient,
- MerchantPrivateApi,
- getWireMethodForTest,
-} from "../harness/harness.js";
+ WalletApiOperation,
+} from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState, getWireMethodForTest } from "../harness/harness.js";
import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
-import { TransactionMajorState } from "@gnu-taler/taler-util";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -40,18 +38,12 @@ export async function runTippingTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant, exchangeBankAccount } =
await createSimpleTestkudosEnvironmentV2(t);
- const bankAccessApiClient = new BankAccessApiClient({
- allowHttp: true,
- baseUrl: bank.bankAccessApiBaseUrl,
- });
+ const bankAccessApiClient = new BankAccessApiClient(
+ bank.bankAccessApiBaseUrl,
+ );
const mbu = await bankAccessApiClient.createRandomBankUser();
- const merchantClient = new MerchantApiClient(
- merchant.makeInstanceBaseUrl("default"),
- {
- method: "external",
- },
- );
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const tipReserveResp = await merchantClient.createTippingReserve({
exchange_url: exchange.baseUrl,
@@ -66,12 +58,15 @@ export async function runTippingTest(t: GlobalTestState) {
exchangeBankAccount.accountPaytoUri,
);
- const wireGatewayApiClient = new WireGatewayApiClient({
- wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
- accountName: exchangeBankAccount.accountName,
- accountPassword: exchangeBankAccount.accountPassword,
- allowHttp: true,
- });
+ const wireGatewayApiClient = new WireGatewayApiClient(
+ exchangeBankAccount.wireGatewayApiBaseUrl,
+ {
+ auth: {
+ username: exchangeBankAccount.accountName,
+ password: exchangeBankAccount.accountPassword,
+ },
+ },
+ );
await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:10",
@@ -85,7 +80,7 @@ export async function runTippingTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- const r = await MerchantPrivateApi.queryTippingReserves(merchant, "default");
+ const r = await merchantClient.queryTippingReserves();
console.log("tipping reserves:", JSON.stringify(r, undefined, 2));
t.assertTrue(r.reserves.length === 1);
@@ -94,7 +89,7 @@ export async function runTippingTest(t: GlobalTestState) {
r.reserves[0].merchant_initial_amount,
);
- const tip = await MerchantPrivateApi.giveTip(merchant, "default", {
+ const tip = await merchantClient.giveTip({
amount: "TESTKUDOS:5",
justification: "why not?",
next_url: "https://example.com/after-tip",
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-backup-basic.ts b/packages/taler-harness/src/integrationtests/test-wallet-backup-basic.ts
index 5321cf5c7..21ac662c2 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-backup-basic.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-backup-basic.ts
@@ -21,9 +21,8 @@ import { j2s } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, WalletCli } from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
createSimpleTestkudosEnvironmentV2,
- withdrawViaBank,
+ createWalletDaemonWithClient,
withdrawViaBankV2,
} from "../harness/helpers.js";
import { SyncService } from "../harness/sync.js";
@@ -112,40 +111,42 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
const txs = await walletClient.call(WalletApiOperation.GetTransactions, {});
console.log(`backed up transactions ${j2s(txs)}`);
- const wallet2 = new WalletCli(t, "wallet2");
+ const { walletClient: walletClient2 } = await createWalletDaemonWithClient(t, {
+ name: "w2"
+ });
// Check that the second wallet is a fresh wallet.
{
- const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {});
+ const bal = await walletClient2.call(WalletApiOperation.GetBalances, {});
t.assertTrue(bal.balances.length === 0);
}
- await wallet2.client.call(WalletApiOperation.ImportBackupRecovery, {
+ await walletClient2.call(WalletApiOperation.ImportBackupRecovery, {
recovery: backupRecovery,
});
- await wallet2.client.call(WalletApiOperation.RunBackupCycle, {});
+ await walletClient2.call(WalletApiOperation.RunBackupCycle, {});
// Check that now the old balance is available!
{
- const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {});
+ const bal = await walletClient2.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 txs = await wallet2.client.call(
+ const txs = await walletClient2.call(
WalletApiOperation.GetTransactions,
{},
);
console.log(`restored transactions ${j2s(txs)}`);
- const bal1 = await wallet2.client.call(WalletApiOperation.GetBalances, {});
+ const bal1 = await walletClient2.call(WalletApiOperation.GetBalances, {});
t.assertAmountEquals(bal1.balances[0].available, "TESTKUDOS:14.1");
- await withdrawViaBank(t, {
- wallet: wallet2,
+ await withdrawViaBankV2(t, {
+ walletClient: walletClient2,
bank,
exchange,
amount: "TESTKUDOS:10",
@@ -153,15 +154,15 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
await exchange.runWirewatchOnce();
- await wallet2.runUntilDone();
+ await walletClient2.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- const txs2 = await wallet2.client.call(
+ const txs2 = await walletClient2.call(
WalletApiOperation.GetTransactions,
{},
);
console.log(`tx after withdraw after restore ${j2s(txs2)}`);
- const bal2 = await wallet2.client.call(WalletApiOperation.GetBalances, {});
+ const bal2 = await walletClient2.call(WalletApiOperation.GetBalances, {});
t.assertAmountEquals(bal2.balances[0].available, "TESTKUDOS:23.82");
}
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts b/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts
index e3e18d5a4..c761c4fb0 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts
@@ -17,18 +17,14 @@
/**
* Imports.
*/
-import { PreparePayResultType } from "@gnu-taler/taler-util";
+import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import {
- GlobalTestState,
- MerchantPrivateApi,
- WalletCli,
-} from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
+ createWalletDaemonWithClient,
makeTestPaymentV2,
- withdrawViaBank,
- withdrawViaBankV2
+ withdrawViaBankV2,
} from "../harness/helpers.js";
import { SyncService } from "../harness/sync.js";
@@ -38,6 +34,8 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
const { commonDb, merchant, walletClient, bank, exchange } =
await createSimpleTestkudosEnvironmentV2(t);
+ const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
+
const sync = await SyncService.create(t, {
currency: "TESTKUDOS",
annualFee: "TESTKUDOS:0.5",
@@ -58,7 +56,12 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
name: sync.baseUrl,
});
- await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:10" });
+ await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:10",
+ });
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
@@ -71,13 +74,16 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
{},
);
- const wallet2 = new WalletCli(t, "wallet2");
+ const { walletClient: walletClientTwo } = await createWalletDaemonWithClient(
+ t,
+ { name: "default" },
+ );
- await wallet2.client.call(WalletApiOperation.ImportBackupRecovery, {
+ await walletClientTwo.call(WalletApiOperation.ImportBackupRecovery, {
recovery: backupRecovery,
});
- await wallet2.client.call(WalletApiOperation.RunBackupCycle, {});
+ await walletClientTwo.call(WalletApiOperation.RunBackupCycle, {});
console.log(
"wallet1 balance before spend:",
@@ -103,7 +109,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
{
console.log(
"wallet2 balance:",
- await wallet2.client.call(WalletApiOperation.GetBalances, {}),
+ await walletClientTwo.call(WalletApiOperation.GetBalances, {}),
);
}
@@ -112,7 +118,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
{
const instance = "default";
- const orderResp = await MerchantPrivateApi.createOrder(merchant, instance, {
+ const orderResp = await merchantClient.createOrder({
order: {
amount: "TESTKUDOS:8",
summary: "bla",
@@ -120,12 +126,9 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
},
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
- merchant,
- {
- orderId: orderResp.order_id,
- },
- );
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
+ orderId: orderResp.order_id,
+ });
t.assertTrue(orderStatus.order_status === "unpaid");
@@ -134,11 +137,11 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
{
console.log(
"wallet2 balance before preparePay:",
- await wallet2.client.call(WalletApiOperation.GetBalances, {}),
+ await walletClientTwo.call(WalletApiOperation.GetBalances, {}),
);
}
- const preparePayResult = await wallet2.client.call(
+ const preparePayResult = await walletClientTwo.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: orderStatus.taler_pay_uri,
@@ -150,25 +153,28 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
PreparePayResultType.PaymentPossible,
);
- const res = await wallet2.client.call(WalletApiOperation.ConfirmPay, {
- proposalId: preparePayResult.proposalId,
+ const res = await walletClientTwo.call(WalletApiOperation.ConfirmPay, {
+ transactionId: preparePayResult.transactionId,
});
console.log(res);
// FIXME: wait for a notification that indicates insufficient funds!
- await withdrawViaBank(t, {
- wallet: wallet2,
+ await withdrawViaBankV2(t, {
+ walletClient: walletClientTwo,
bank,
exchange,
amount: "TESTKUDOS:50",
});
- const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {});
+ const bal = await walletClientTwo.call(WalletApiOperation.GetBalances, {});
console.log("bal", bal);
- await wallet2.runUntilDone();
+ await walletClientTwo.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
}
}
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-balance.ts b/packages/taler-harness/src/integrationtests/test-wallet-balance.ts
index 15b0fd427..fc2774adf 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-balance.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-balance.ts
@@ -17,9 +17,15 @@
/**
* Imports.
*/
-import { Amounts, PreparePayResultType } from "@gnu-taler/taler-util";
+import {
+ Amounts,
+ Duration,
+ MerchantApiClient,
+ MerchantContractTerms,
+ PreparePayResultType,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@@ -37,6 +43,19 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
const { merchant, walletClient, exchange, bank } =
await createSimpleTestkudosEnvironmentV2(t);
+ await merchant.addInstanceWithWireAccount({
+ id: "myinst",
+ name: "My Instance",
+ paytoUris: ["payto://void/foo"],
+ defaultWireTransferDelay: Duration.toTalerProtocolDuration(
+ Duration.fromSpec({ minutes: 1 }),
+ ),
+ });
+
+ const merchantClient = new MerchantApiClient(
+ merchant.makeInstanceBaseUrl("myinst"),
+ );
+
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@@ -48,17 +67,17 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
- const order = {
+ const order: Partial<MerchantContractTerms> = {
summary: "Buy me!",
amount: "TESTKUDOS:5",
fulfillment_url: "taler://fulfillment-success/thx",
};
- const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
+ const orderResp = await merchantClient.createOrder({
order,
});
- let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts
index c70fd51d4..9a0eb77ae 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts
@@ -18,14 +18,12 @@
* Imports.
*/
import {
+ BankAccessApiClient,
Duration,
NotificationType,
TransactionMajorState,
} from "@gnu-taler/taler-util";
-import {
- BankAccessApiClient,
- WalletApiOperation,
-} from "@gnu-taler/taler-wallet-core";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import {
ExchangeService,
@@ -92,7 +90,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {
// Fakebank uses x-taler-bank, but merchant is configured to only accept sepa!
const label = "mymerchant";
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [
@@ -123,10 +121,9 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {
skipDefaults: true,
});
- const bankAccessApiClient = new BankAccessApiClient({
- allowHttp: true,
- baseUrl: bank.bankAccessApiBaseUrl,
- });
+ const bankAccessApiClient = new BankAccessApiClient(
+ bank.bankAccessApiBaseUrl,
+ );
const user = await bankAccessApiClient.createRandomBankUser();
bankAccessApiClient.setAuth(user);
const wop = await bankAccessApiClient.createWithdrawalOperation(
diff --git a/packages/taler-harness/src/integrationtests/test-wallettesting.ts b/packages/taler-harness/src/integrationtests/test-wallettesting.ts
index a856df79f..4fa870f1c 100644
--- a/packages/taler-harness/src/integrationtests/test-wallettesting.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallettesting.ts
@@ -91,7 +91,7 @@ export async function createMyEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
+ await merchant.addInstanceWithWireAccount({
id: "default",
name: "Default Instance",
paytoUris: [getPayto("merchant-default")],
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts
index c3069c317..aa5e2b770 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts
@@ -17,13 +17,10 @@
/**
* Imports.
*/
-import { TalerErrorCode } from "@gnu-taler/taler-util";
-import {
- WalletApiOperation,
- BankAccessApiClient,
-} from "@gnu-taler/taler-wallet-core";
+import { BankAccessApiClient, TalerErrorCode } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
-import { createSimpleTestkudosEnvironment } from "../harness/helpers.js";
+import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -31,14 +28,14 @@ import { createSimpleTestkudosEnvironment } from "../harness/helpers.js";
export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange } = await createSimpleTestkudosEnvironment(t);
+ const { walletClient, bank, exchange } =
+ await createSimpleTestkudosEnvironmentV2(t);
// Create a withdrawal operation
- const bankAccessApiClient = new BankAccessApiClient({
- allowHttp: true,
- baseUrl: bank.bankAccessApiBaseUrl,
- });
+ const bankAccessApiClient = new BankAccessApiClient(
+ bank.bankAccessApiBaseUrl,
+ );
const user = await bankAccessApiClient.createRandomBankUser();
bankAccessApiClient.setAuth(user);
const wop = await bankAccessApiClient.createWithdrawalOperation(
@@ -48,11 +45,11 @@ export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
// Hand it to the wallet
- await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
+ await walletClient.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
talerWithdrawUri: wop.taler_withdraw_uri,
});
- await wallet.runPending();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
// Abort it
@@ -67,13 +64,10 @@ export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
// WHY ?!
//
const e = await t.assertThrowsTalerErrorAsync(async () => {
- await wallet.client.call(
- WalletApiOperation.AcceptBankIntegratedWithdrawal,
- {
- exchangeBaseUrl: exchange.baseUrl,
- talerWithdrawUri: wop.taler_withdraw_uri,
- },
- );
+ await walletClient.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
+ exchangeBaseUrl: exchange.baseUrl,
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ });
});
t.assertDeepEqual(
e.errorDetail.code,
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts
index 61687ec02..232b6d7c2 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts
@@ -17,10 +17,8 @@
/**
* Imports.
*/
-import { GlobalTestState } from "../harness/harness.js";
-import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
-import { BankAccessApiClient, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
+ BankAccessApiClient,
j2s,
NotificationType,
TransactionMajorState,
@@ -28,6 +26,9 @@ import {
TransactionType,
WithdrawalType,
} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState } from "../harness/harness.js";
+import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -40,10 +41,9 @@ export async function runWithdrawalBankIntegratedTest(t: GlobalTestState) {
// Create a withdrawal operation
- const bankAccessApiClient = new BankAccessApiClient({
- allowHttp: true,
- baseUrl: bank.bankAccessApiBaseUrl,
- });
+ const bankAccessApiClient = new BankAccessApiClient(
+ bank.bankAccessApiBaseUrl,
+ );
const user = await bankAccessApiClient.createRandomBankUser();
bankAccessApiClient.setAuth(user);
const wop = await bankAccessApiClient.createWithdrawalOperation(
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts
index 06355b964..bc2946a18 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts
@@ -17,22 +17,16 @@
/**
* Imports.
*/
+import { BankAccessApiClient, j2s } from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { CoinConfig } from "../harness/denomStructures.js";
import {
+ BankService,
+ ExchangeService,
GlobalTestState,
WalletCli,
setupDb,
- ExchangeService,
- BankService,
} from "../harness/harness.js";
-import {
- BankAccessApi,
- BankAccessApiClient,
- BankApi,
- WalletApiOperation,
-} from "@gnu-taler/taler-wallet-core";
-import { CoinConfig } from "../harness/denomStructures.js";
-import { j2s, URL } from "@gnu-taler/taler-util";
-import { withdrawViaBank } from "../harness/helpers.js";
const coinRsaCommon = {
cipher: "RSA" as const,
@@ -113,13 +107,15 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) {
const amount = "TESTKUDOS:7.5";
- const bankAccessApiClient = new BankAccessApiClient({
- allowHttp: true,
- baseUrl: bank.bankAccessApiBaseUrl,
- });
+ const bankAccessApiClient = new BankAccessApiClient(
+ bank.bankAccessApiBaseUrl,
+ );
const user = await bankAccessApiClient.createRandomBankUser();
bankAccessApiClient.setAuth(user);
- const wop = await bankAccessApiClient.createWithdrawalOperation(user.username, amount);
+ const wop = await bankAccessApiClient.createWithdrawalOperation(
+ user.username,
+ amount,
+ );
// Hand it to the wallet
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
index a9d544ee0..8777b19e2 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
@@ -114,4 +114,5 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) {
}
runWithdrawalHugeTest.suites = ["wallet-perf"];
-runWithdrawalHugeTest.excludeByDefault = true;
+// FIXME: Should not be "experimental" but "slow" or something similar.
+runWithdrawalHugeTest.experimental = true;
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts
index d49235f89..1d98cd46e 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts
@@ -17,12 +17,14 @@
/**
* Imports.
*/
-import { AbsoluteTime, Logger, j2s } from "@gnu-taler/taler-util";
import {
+ AbsoluteTime,
BankAccessApiClient,
- WalletApiOperation,
+ Logger,
WireGatewayApiClient,
-} from "@gnu-taler/taler-wallet-core";
+ j2s,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
@@ -39,10 +41,9 @@ export async function runWithdrawalManualTest(t: GlobalTestState) {
// Create a withdrawal operation
- const bankAccessApiClient = new BankAccessApiClient({
- baseUrl: bank.bankAccessApiBaseUrl,
- allowHttp: true,
- });
+ const bankAccessApiClient = new BankAccessApiClient(
+ bank.bankAccessApiBaseUrl,
+ );
const user = await bankAccessApiClient.createRandomBankUser();
@@ -74,12 +75,15 @@ export async function runWithdrawalManualTest(t: GlobalTestState) {
const reservePub: string = wres.reservePub;
- const wireGatewayApiClient = new WireGatewayApiClient({
- wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
- accountName: exchangeBankAccount.accountName,
- accountPassword: exchangeBankAccount.accountPassword,
- allowHttp: true,
- });
+ const wireGatewayApiClient = new WireGatewayApiClient(
+ exchangeBankAccount.wireGatewayApiBaseUrl,
+ {
+ auth: {
+ username: exchangeBankAccount.accountName,
+ password: exchangeBankAccount.accountPassword,
+ },
+ },
+ );
await wireGatewayApiClient.adminAddIncoming({
amount: "TESTKUDOS:10",
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts
index 501af98a4..66bd87a59 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -14,39 +14,39 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import {
- CancellationToken,
- Logger,
- minimatch,
- setGlobalLogLevelFromString,
-} from "@gnu-taler/taler-util";
+import { CancellationToken, Logger, minimatch } from "@gnu-taler/taler-util";
import * as child_process from "child_process";
+import { spawnSync } from "child_process";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import url from "url";
import {
GlobalTestState,
- runCommand,
+ TestRunResult,
runTestWithState,
shouldLingerInTest,
- TestRunResult,
} from "../harness/harness.js";
-import { spawnSync } from "child_process";
+import { getSharedTestDir } from "../harness/helpers.js";
import { runAgeRestrictionsMerchantTest } from "./test-age-restrictions-merchant.js";
+import { runAgeRestrictionsMixedMerchantTest } from "./test-age-restrictions-mixed-merchant.js";
+import { runAgeRestrictionsPeerTest } from "./test-age-restrictions-peer.js";
import { runBankApiTest } from "./test-bank-api.js";
import { runClaimLoopTest } from "./test-claim-loop.js";
import { runClauseSchnorrTest } from "./test-clause-schnorr.js";
import { runDenomUnofferedTest } from "./test-denom-unoffered.js";
import { runDepositTest } from "./test-deposit.js";
+import { runExchangeDepositTest } from "./test-exchange-deposit.js";
import { runExchangeManagementTest } from "./test-exchange-management.js";
+import { runExchangePurseTest } from "./test-exchange-purse.js";
import { runExchangeTimetravelTest } from "./test-exchange-timetravel.js";
import { runFeeRegressionTest } from "./test-fee-regression.js";
import { runForcedSelectionTest } from "./test-forced-selection.js";
+import { runKycTest } from "./test-kyc.js";
import { runLibeufinApiBankaccountTest } from "./test-libeufin-api-bankaccount.js";
import { runLibeufinApiBankconnectionTest } from "./test-libeufin-api-bankconnection.js";
-import { runLibeufinApiFacadeTest } from "./test-libeufin-api-facade.js";
import { runLibeufinApiFacadeBadRequestTest } from "./test-libeufin-api-facade-bad-request.js";
+import { runLibeufinApiFacadeTest } from "./test-libeufin-api-facade.js";
import { runLibeufinApiPermissionsTest } from "./test-libeufin-api-permissions.js";
import { runLibeufinApiSandboxCamtTest } from "./test-libeufin-api-sandbox-camt.js";
import { runLibeufinApiSandboxTransactionsTest } from "./test-libeufin-api-sandbox-transactions.js";
@@ -58,62 +58,58 @@ import { runLibeufinC5xTest } from "./test-libeufin-c5x.js";
import { runLibeufinAnastasisFacadeTest } from "./test-libeufin-facade-anastasis.js";
import { runLibeufinKeyrotationTest } from "./test-libeufin-keyrotation.js";
import { runLibeufinNexusBalanceTest } from "./test-libeufin-nexus-balance.js";
-import { runLibeufinRefundTest } from "./test-libeufin-refund.js";
import { runLibeufinRefundMultipleUsersTest } from "./test-libeufin-refund-multiple-users.js";
+import { runLibeufinRefundTest } from "./test-libeufin-refund.js";
import { runLibeufinSandboxWireTransferCliTest } from "./test-libeufin-sandbox-wire-transfer-cli.js";
import { runLibeufinTutorialTest } from "./test-libeufin-tutorial.js";
import { runMerchantExchangeConfusionTest } from "./test-merchant-exchange-confusion.js";
-import { runMerchantInstancesTest } from "./test-merchant-instances.js";
import { runMerchantInstancesDeleteTest } from "./test-merchant-instances-delete.js";
import { runMerchantInstancesUrlsTest } from "./test-merchant-instances-urls.js";
+import { runMerchantInstancesTest } from "./test-merchant-instances.js";
import { runMerchantLongpollingTest } from "./test-merchant-longpolling.js";
import { runMerchantRefundApiTest } from "./test-merchant-refund-api.js";
import { runMerchantSpecPublicOrdersTest } from "./test-merchant-spec-public-orders.js";
import { runPayPaidTest } from "./test-pay-paid.js";
-import { runPaymentTest } from "./test-payment.js";
+import { runPaymentAbortTest } from "./test-payment-abort.js";
import { runPaymentClaimTest } from "./test-payment-claim.js";
+import { runPaymentExpiredTest } from "./test-payment-expired.js";
import { runPaymentFaultTest } from "./test-payment-fault.js";
import { runPaymentForgettableTest } from "./test-payment-forgettable.js";
import { runPaymentIdempotencyTest } from "./test-payment-idempotency.js";
import { runPaymentMultipleTest } from "./test-payment-multiple.js";
+import { runPaymentShareTest } from "./test-payment-share.js";
+import { runPaymentTemplateTest } from "./test-payment-template.js";
import { runPaymentTransientTest } from "./test-payment-transient.js";
import { runPaymentZeroTest } from "./test-payment-zero.js";
+import { runPaymentTest } from "./test-payment.js";
import { runPaywallFlowTest } from "./test-paywall-flow.js";
+import { runPeerRepairTest } from "./test-peer-repair.js";
import { runPeerToPeerPullTest } from "./test-peer-to-peer-pull.js";
import { runPeerToPeerPushTest } from "./test-peer-to-peer-push.js";
-import { runRefundTest } from "./test-refund.js";
import { runRefundAutoTest } from "./test-refund-auto.js";
import { runRefundGoneTest } from "./test-refund-gone.js";
import { runRefundIncrementalTest } from "./test-refund-incremental.js";
+import { runRefundTest } from "./test-refund.js";
import { runRevocationTest } from "./test-revocation.js";
+import { runSimplePaymentTest } from "./test-simple-payment.js";
+import { runStoredBackupsTest } from "./test-stored-backups.js";
import { runTimetravelAutorefreshTest } from "./test-timetravel-autorefresh.js";
import { runTimetravelWithdrawTest } from "./test-timetravel-withdraw.js";
import { runTippingTest } from "./test-tipping.js";
+import { runTermOfServiceFormatTest } from "./test-tos-format.js";
import { runWalletBackupBasicTest } from "./test-wallet-backup-basic.js";
import { runWalletBackupDoublespendTest } from "./test-wallet-backup-doublespend.js";
+import { runWalletBalanceTest } from "./test-wallet-balance.js";
+import { runWalletCryptoWorkerTest } from "./test-wallet-cryptoworker.js";
import { runWalletDblessTest } from "./test-wallet-dbless.js";
+import { runWalletNotificationsTest } from "./test-wallet-notifications.js";
import { runWallettestingTest } from "./test-wallettesting.js";
import { runWithdrawalAbortBankTest } from "./test-withdrawal-abort-bank.js";
import { runWithdrawalBankIntegratedTest } from "./test-withdrawal-bank-integrated.js";
import { runWithdrawalFakebankTest } from "./test-withdrawal-fakebank.js";
-import { runWithdrawalManualTest } from "./test-withdrawal-manual.js";
-import { runAgeRestrictionsPeerTest } from "./test-age-restrictions-peer.js";
-import { runWalletNotificationsTest } from "./test-wallet-notifications.js";
-import { runAgeRestrictionsMixedMerchantTest } from "./test-age-restrictions-mixed-merchant.js";
-import { runWalletCryptoWorkerTest } from "./test-wallet-cryptoworker.js";
-import { runWithdrawalHugeTest } from "./test-withdrawal-huge.js";
-import { runKycTest } from "./test-kyc.js";
-import { runPaymentAbortTest } from "./test-payment-abort.js";
import { runWithdrawalFeesTest } from "./test-withdrawal-fees.js";
-import { runWalletBalanceTest } from "./test-wallet-balance.js";
-import { runPaymentTemplateTest } from "./test-payment-template.js";
-import { runExchangeDepositTest } from "./test-exchange-deposit.js";
-import { runPeerRepairTest } from "./test-peer-repair.js";
-import { runPaymentShareTest } from "./test-payment-share.js";
-import { runSimplePaymentTest } from "./test-simple-payment.js";
-import { runTermOfServiceFormatTest } from "./test-tos-format.js";
-import { runExchangePurseTest } from "./test-exchange-purse.js";
-import { getSharedTestDir } from "../harness/helpers.js";
+import { runWithdrawalHugeTest } from "./test-withdrawal-huge.js";
+import { runWithdrawalManualTest } from "./test-withdrawal-manual.js";
/**
* Test runner.
@@ -126,7 +122,6 @@ const logger = new Logger("testrunner.ts");
interface TestMainFunction {
(t: GlobalTestState): Promise<void>;
timeoutMs?: number;
- excludeByDefault?: boolean;
experimental?: boolean;
suites?: string[];
}
@@ -212,6 +207,8 @@ const allTests: TestMainFunction[] = [
runWithdrawalFeesTest,
runWithdrawalHugeTest,
runTermOfServiceFormatTest,
+ runStoredBackupsTest,
+ runPaymentExpiredTest,
];
export interface TestRunSpec {
@@ -228,7 +225,6 @@ export interface TestRunSpec {
export interface TestInfo {
name: string;
suites: string[];
- excludeByDefault: boolean;
experimental: boolean;
}
@@ -333,19 +329,16 @@ export async function runTests(spec: TestRunSpec) {
continue;
}
+ if (testCase.experimental && !spec.includeExperimental) {
+ continue;
+ }
+
if (suites) {
const ts = new Set(testCase.suites ?? []);
const intersection = new Set([...suites].filter((x) => ts.has(x)));
if (intersection.size === 0) {
continue;
}
- } else {
- if (testCase.excludeByDefault) {
- continue;
- }
- if (testCase.experimental && !spec.includeExperimental) {
- continue;
- }
}
if (spec.dryRun) {
@@ -521,7 +514,6 @@ export function getTestInfo(): TestInfo[] {
return allTests.map((x) => ({
name: getTestName(x),
suites: x.suites ?? [],
- excludeByDefault: x.excludeByDefault ?? false,
experimental: x.experimental ?? false,
}));
}
diff --git a/packages/taler-harness/src/lint.ts b/packages/taler-harness/src/lint.ts
index 6d8e679db..a45e6db9d 100644
--- a/packages/taler-harness/src/lint.ts
+++ b/packages/taler-harness/src/lint.ts
@@ -55,7 +55,6 @@ interface PubkeyConf {
const httpLib = createPlatformHttpLib({
enableThrottling: false,
- allowHttp: true,
});
interface ShellResult {