taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 6ea3ea72762e367ab8b86f13c013f31ad104b1f0
parent b2d329d2f3d8cadf7ed17be360a80ae1781a4e57
Author: Florian Dold <florian@dold.me>
Date:   Mon, 14 Apr 2025 12:14:48 +0200

harness: run depositcheck in test mode for kyc-merchant-deposit-rewrite

Diffstat:
Mpackages/taler-harness/src/harness/harness.ts | 15+++++++++++++--
Mpackages/taler-harness/src/integrationtests/test-kyc-merchant-deposit-rewrite.ts | 41++++++++++++++++-------------------------
2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts @@ -319,7 +319,7 @@ export class GlobalTestState { block: Promise<unknown>, ): Promise<TalerError> { try { - await block + await block; } catch (e) { if (e instanceof TalerError) { return e; @@ -1913,6 +1913,15 @@ export class MerchantService implements MerchantServiceInterface { ); } + async runDepositcheckOnce() { + await runCommand( + this.globalState, + `merchant-${this.name}-depositcheck-once`, + "taler-merchant-depositcheck", + [...this.timetravelArgArr, "-LINFO", "-c", this.configFilename, "-t"], + ); + } + /** * Start the merchant. * Waits for the service to become fully available. @@ -2379,7 +2388,9 @@ export class WalletClient { } async getTx(id: TransactionIdStr): Promise<Transaction> { - return this.call(WalletApiOperation.GetTransactionById, {transactionId: id}) + return this.call(WalletApiOperation.GetTransactionById, { + transactionId: id, + }); } waitForNotificationCond<T>( diff --git a/packages/taler-harness/src/integrationtests/test-kyc-merchant-deposit-rewrite.ts b/packages/taler-harness/src/integrationtests/test-kyc-merchant-deposit-rewrite.ts @@ -18,39 +18,23 @@ * Imports. */ import { - codecForAccountKycRedirects, - codecForKycProcessClientInformation, Configuration, Duration, encodeCrock, - failOrThrow, hashNormalizedPaytoUri, - HttpStatusCode, j2s, Logger, MerchantAccountKycRedirectsResponse, MerchantAccountKycStatus, succeedOrThrow, - TalerCoreBankHttpClient, TalerMerchantApi, - TalerMerchantInstanceHttpClient, - TalerWireGatewayHttpClient, - UserAndToken, } from "@gnu-taler/taler-util"; import { - readResponseJsonOrThrow, - readSuccessResponseJsonOrThrow, -} from "@gnu-taler/taler-util/http"; -import { configureCommonKyc, createKycTestkudosEnvironment, postAmlDecisionNoRules, } from "../harness/environments.js"; -import { - delayMs, - GlobalTestState, - harnessHttpLib, -} from "../harness/harness.js"; +import { delayMs, GlobalTestState } from "../harness/harness.js"; const logger = new Logger(`test-kyc-merchant-deposit-rewrite.ts`); @@ -83,6 +67,7 @@ function adjustExchangeConfig(config: Configuration) { config.setString("KYC-CHECK-C1", "fallback", "FREEZE"); } +// FIXME: This is not very readable, replace it with "retryUntilTrue". async function retryUntil<T, X extends T>( fx: () => Promise<T>, condition: (x: T, i: number) => boolean, @@ -124,10 +109,12 @@ export async function runKycMerchantDepositRewriteTest(t: GlobalTestState) { let merchantBankAccount: string | undefined; { const kycStatus = await retryUntil( - async () => - succeedOrThrow<MerchantAccountKycRedirectsResponse | void>( + async () => { + await merchant.runDepositcheckOnce(); + return succeedOrThrow<MerchantAccountKycRedirectsResponse | void>( await merchantApi.getCurrentInstanceKycStatus(undefined), - ), + ); + }, (x) => !!x, ); @@ -199,10 +186,12 @@ export async function runKycMerchantDepositRewriteTest(t: GlobalTestState) { let merchantAmlAccount; { const kycStatus = await retryUntil( - async () => - succeedOrThrow<MerchantAccountKycRedirectsResponse | void>( + async () => { + await merchant.runDepositcheckOnce(); + return succeedOrThrow<MerchantAccountKycRedirectsResponse | void>( await merchantApi.getCurrentInstanceKycStatus(undefined), - ), + ); + }, (x) => !!x && !x.kyc_data[0].payto_kycauths, ); logger.info(`kyc resp 2: ${j2s(kycStatus)}`); @@ -240,13 +229,15 @@ export async function runKycMerchantDepositRewriteTest(t: GlobalTestState) { }); await merchant.stop(); - merchant.setTimetravel(Duration.toMilliseconds(Duration.fromSpec({days: 7}))); + merchant.setTimetravel( + Duration.toMilliseconds(Duration.fromSpec({ days: 7 })), + ); await merchant.start(); - await merchant.pingUntilAvailable(); { const kycStatus = await retryUntil( async () => { + await merchant.runDepositcheckOnce(); // Now we can check the status return succeedOrThrow<MerchantAccountKycRedirectsResponse | void>( await merchantApi.getCurrentInstanceKycStatus(undefined),