taler-typescript-core

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

commit 0a92e4bbb88c2cb3d0d5d4b34be46bc271c5ef1b
parent 2c3cc9b99363c4e114abb478fa8169157c9e7359
Author: Florian Dold <dold@taler.net>
Date:   Tue, 24 Nov 2026 12:03:56 +0100

taler-harness: test Android withdrawals across the TOPS SMS KYC limit

Diffstat:
Mpackages/taler-harness/Makefile | 2+-
Mpackages/taler-harness/android/README.md | 20+++++++++++++++++++-
Apackages/taler-harness/android/deliver-test-sms.sh | 24++++++++++++++++++++++++
Apackages/taler-harness/android/flows/kyc-open.yaml | 41+++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-harness/android/flows/kyc-visit.yaml | 27+++------------------------
Apackages/taler-harness/android/flows/tops-sms-request.yaml | 26++++++++++++++++++++++++++
Apackages/taler-harness/android/flows/tops-sms-verify.yaml | 25+++++++++++++++++++++++++
Apackages/taler-harness/android/flows/withdraw-finished.yaml | 23+++++++++++++++++++++++
Mpackages/taler-harness/android/flows/withdraw.yaml | 13++++++++++---
Mpackages/taler-harness/src/harness/android-wallet.ts | 30++++++++++++++----------------
Apackages/taler-harness/src/integrationtests/test-wallet-android-tops-kyc.ts | 192+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-harness/src/integrationtests/testrunner.ts | 2++
Mpackages/taler-harness/src/integrationtests/wallet-android-test-support.ts | 35+++++++++++++++++++++++------------
13 files changed, 403 insertions(+), 57 deletions(-)

diff --git a/packages/taler-harness/Makefile b/packages/taler-harness/Makefile @@ -36,7 +36,7 @@ install-nodeps: install ./README.md $(DESTDIR)$(NODEDIR)/ install -d $(DESTDIR)$(NODEDIR)/android/flows install -m 644 ./android/README.md $(DESTDIR)$(NODEDIR)/android/ - install ./android/build-nightly.sh $(DESTDIR)$(NODEDIR)/android/ + install ./android/build-nightly.sh ./android/deliver-test-sms.sh $(DESTDIR)$(NODEDIR)/android/ install -m 644 ./android/flows/*.yaml $(DESTDIR)$(NODEDIR)/android/flows/ ln -sf ../lib/taler-harness/node_modules/taler-harness/bin/taler-harness.mjs $(DESTDIR)$(BINDIR)/taler-harness deps: diff --git a/packages/taler-harness/android/README.md b/packages/taler-harness/android/README.md @@ -105,6 +105,24 @@ taler-harness run-integrationtests --suites wallet-android \ --test-dir /tmp/android-ui-installed-results ``` +## TOPS withdrawal with SMS KYC + +Install Challenger (`challenger-dbinit`, `challenger-admin`, `challenger-httpd` +and its web UI), the TOPS AML helpers, and `jq`. Port 6002 must also be available +on the host and for adb reverse. With the disposable emulator selected: + +```sh +export TALER_HARNESS_WALLET_APK=/tmp/wallet-nightly-local.apk +packages/taler-harness/bin/taler-harness.mjs run-integrationtests \ + wallet-android-tops-kyc-withdrawal --suites wallet-android --test-dir /tmp/android-tops-results +``` + +The test withdraws CHF 190 and CHF 20 from one account within the TOPS 30-day +window. The second withdrawal opens Swiss SMS registration through **Complete +KYC**. Challenger delivers the generated TAN for `+41700000006` into a fresh +`sms-*/` directory under the test result. Maestro enters it in the browser and +checks the completed withdrawal and credited wallet balance. + ## Coverage and diagnostics - Bank withdrawal: accept terms, confirm, authorize at the bank, check the @@ -136,7 +154,7 @@ The additional scenarios exercise one outcome per fresh wallet: | Actions | Abort an unclaimed P2P payment | Recover funds and retain the aborted transaction after restart | | Actions | Abort a proposed purchase | No merchant payment and no wallet balance change | -KYC uses a deterministic exchange INFO requirement. Maestro opens the real +The generic KYC scenarios use a deterministic exchange INFO requirement. Maestro opens the real exchange KYC web UI and checks its instructions; the harness then acts as the reviewer through the exchange AML API. These scenarios cover the Android handoff and transaction continuation, not an external identity provider's forms. diff --git a/packages/taler-harness/android/deliver-test-sms.sh b/packages/taler-harness/android/deliver-test-sms.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# This file is part of GNU Taler +# (C) 2026 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/> + +set -euo pipefail + +# Challenger supplies the address as JSON and the formatted SMS on stdin. +phone=$(jq -er '.CONTACT_PHONE' <<<"$1") +[[ "$phone" == "$TALER_TEST_PHONE" ]] +message=$(mktemp "$TALER_TEST_SMS_DIR/.sms.XXXXXX") +trap 'rm -f "$message"' EXIT +cat > "$message" +mv "$message" "$TALER_TEST_SMS_DIR/$phone.txt" diff --git a/packages/taler-harness/android/flows/kyc-open.yaml b/packages/taler-harness/android/flows/kyc-open.yaml @@ -0,0 +1,41 @@ +# This file is part of GNU Taler +# (C) 2026 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/> + +appId: ${APP_ID} +--- +- runFlow: kyc-required.yaml +- tapOn: "Complete KYC" +- extendedWaitUntil: + visible: "Use without an account|${REQUIREMENT}" + timeout: 60000 +# A fresh emulator may still have Chrome's first-run screens. +- runFlow: + when: + visible: "Use without an account" + commands: + - tapOn: "Use without an account" +- runFlow: + when: + visible: "No thanks" + commands: + - tapOn: "No thanks" +- runFlow: + when: + visible: "Got it" + commands: + - tapOn: "Got it" +- extendedWaitUntil: + visible: "${REQUIREMENT}" + timeout: 60000 +- takeScreenshot: exchange-kyc-instructions diff --git a/packages/taler-harness/android/flows/kyc-visit.yaml b/packages/taler-harness/android/flows/kyc-visit.yaml @@ -14,30 +14,9 @@ appId: ${APP_ID} --- -- runFlow: kyc-required.yaml -- tapOn: "Complete KYC" -- extendedWaitUntil: - visible: "Use without an account|Android identity check: contact the test exchange[.]" - timeout: 60000 -# A fresh emulator may still have Chrome's first-run screens. - runFlow: - when: - visible: "Use without an account" - commands: - - tapOn: "Use without an account" -- runFlow: - when: - visible: "No thanks" - commands: - - tapOn: "No thanks" -- runFlow: - when: - visible: "Got it" - commands: - - tapOn: "Got it" -- extendedWaitUntil: - visible: "Android identity check: contact the test exchange[.]" - timeout: 60000 -- takeScreenshot: exchange-kyc-instructions + file: kyc-open.yaml + env: + REQUIREMENT: "Android identity check: contact the test exchange[.]" - back - assertVisible: "Complete KYC" diff --git a/packages/taler-harness/android/flows/tops-sms-request.yaml b/packages/taler-harness/android/flows/tops-sms-request.yaml @@ -0,0 +1,26 @@ +# This file is part of GNU Taler +# (C) 2026 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/> + +appId: ${APP_ID} +--- +- runFlow: + file: kyc-open.yaml + env: + REQUIREMENT: "Confirm Swiss mobile phone number via SMS TAN" +- tapOn: "Confirm Swiss mobile phone number via SMS TAN" +- tapOn: "Phone" +- inputText: ${PHONE} +- hideKeyboard +- tapOn: "Send verification code" +- assertVisible: "Verify code" diff --git a/packages/taler-harness/android/flows/tops-sms-verify.yaml b/packages/taler-harness/android/flows/tops-sms-verify.yaml @@ -0,0 +1,25 @@ +# This file is part of GNU Taler +# (C) 2026 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/> + +appId: ${APP_ID} +--- +- tapOn: "Verification code" +- inputText: ${CODE} +- hideKeyboard +- tapOn: "Verify code" +- extendedWaitUntil: + visible: "You can close this window now." + timeout: 60000 +- takeScreenshot: sms-verified +- tapOn: "Close tab" diff --git a/packages/taler-harness/android/flows/withdraw-finished.yaml b/packages/taler-harness/android/flows/withdraw-finished.yaml @@ -0,0 +1,23 @@ +# This file is part of GNU Taler +# (C) 2026 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/> + +appId: ${APP_ID} +--- +- runFlow: + file: transaction-state.yaml + env: + STATE: "This transaction was completed successfully" +- assertVisible: ".*${NET}" +- assertNotVisible: "Complete KYC" +- takeScreenshot: completed-withdrawal diff --git a/packages/taler-harness/android/flows/withdraw.yaml b/packages/taler-harness/android/flows/withdraw.yaml @@ -18,8 +18,15 @@ appId: ${APP_ID} file: open-uri.yaml env: URI: ${WITHDRAW_URI} -- tapOn: "Terms of Service" -- assertVisible: "Android UI test exchange terms." -- tapOn: "Accept Terms of Service" +- extendedWaitUntil: + visible: "Terms of Service|Confirm withdrawal" + timeout: 30000 +- runFlow: + when: + visible: "Terms of Service" + commands: + - tapOn: "Terms of Service" + - assertVisible: "Android UI test exchange terms." + - tapOn: "Accept Terms of Service" - tapOn: "Confirm withdrawal" - assertVisible: "Authorize in bank" diff --git a/packages/taler-harness/src/harness/android-wallet.ts b/packages/taler-harness/src/harness/android-wallet.ts @@ -19,6 +19,16 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; import { GlobalTestState, runCommand } from "./harness.js"; +/** Locate Android assets in the bundled, unbundled, or installed harness. */ +export function androidResource(name: string): string { + const moduleDir = path.dirname(fileURLToPath(import.meta.url)); + for (const base of ["../android", "../../android"]) { + const resource = path.resolve(moduleDir, base, name); + if (fs.existsSync(resource)) return resource; + } + throw Error(`Android harness resource missing: ${name}`); +} + /** A disposable, explicitly selected device running the release nightly APK. */ export class AndroidWallet { readonly appId = "net.taler.wallet.nightly"; @@ -43,7 +53,7 @@ export class AndroidWallet { ]); } - async prepare(): Promise<void> { + async prepare(extraPorts: number[] = []): Promise<void> { const apk = process.env.TALER_HARNESS_WALLET_APK; if (!apk || !fs.existsSync(apk) || !fs.statSync(apk).isFile()) { throw Error( @@ -60,7 +70,7 @@ export class AndroidWallet { await this.adb("uninstall", this.appId); } await this.adb("install", apk); - for (const port of [8081, 8082, 8083]) { + for (const port of [8081, 8082, 8083, ...extraPorts]) { await this.adb("reverse", "--no-rebind", `tcp:${port}`, `tcp:${port}`); this.ports.push(port); } @@ -72,19 +82,7 @@ export class AndroidWallet { } async flow(name: string, env: Record<string, string> = {}): Promise<void> { - const moduleDir = path.dirname(fileURLToPath(import.meta.url)); - // Bundles live in dist/; unbundled modules live in src/harness/ or lib/harness/. - const roots = [ - path.resolve(moduleDir, "../android/flows"), - path.resolve(moduleDir, "../../android/flows"), - ]; - const root = roots.find((candidate) => - fs.existsSync(path.join(candidate, `${name}.yaml`)), - ); - if (!root) - throw Error( - `Android flow ${name} not found; build/install taler-harness with its android directory`, - ); + const flowFile = androidResource(`flows/${name}.yaml`); const step = `${++this.step}-${name}`; this.t.logStep(`Android: ${step}`); const artifacts = path.resolve(this.t.testDir, "android", step); @@ -105,7 +103,7 @@ export class AndroidWallet { ...Object.entries({ APP_ID: this.appId, ...env }).flatMap( ([key, value]) => ["-e", `${key}=${value}`], ), - path.join(root, `${name}.yaml`), + flowFile, ], `android-${step}`, { diff --git a/packages/taler-harness/src/integrationtests/test-wallet-android-tops-kyc.ts b/packages/taler-harness/src/integrationtests/test-wallet-android-tops-kyc.ts @@ -0,0 +1,192 @@ +/* + This file is part of GNU Taler + (C) 2026 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/> + */ + +import fs from "node:fs"; +import path from "node:path"; +import { Amounts, Configuration } from "@gnu-taler/taler-util"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { createChallengerAdminRegistrar } from "../challenger-tester.js"; +import { AndroidWallet, androidResource } from "../harness/android-wallet.js"; +import { + GlobalTestState, + pingProc, + runCommand, + setupDb, + waitMs, +} from "../harness/harness.js"; +import { createTopsEnvironment } from "../harness/tops.js"; +import { + configureAndroidTerms, + startAndroidWithdrawal, + confirmAndroidWithdrawal, +} from "./wallet-android-test-support.js"; + +const phone = "+41700000006"; +const challengerPort = 6002; +const exchangeUrl = "http://localhost:8081/"; + +// Only SMS delivery is simulated. Challenger generates and verifies the PIN. +async function startSmsChallenger(t: GlobalTestState) { + const db = await setupDb(t, { nameSuffix: "android-challenger" }); + const config = new Configuration(); + const baseUrl = `http://localhost:${challengerPort}/`; + config.setString("challenger", "BASE_URL", baseUrl); + config.setString("challenger", "PORT", String(challengerPort)); + config.setString("challenger", "ADDRESS_TYPE", "phone"); + config.setString("challenger", "ADDRESS_HINT", "Swiss mobile phone number"); + config.setString("challenger", "TOKEN_EXPIRATION", "1 h"); + config.setString( + "challenger", + "AUTH_COMMAND", + androidResource("deliver-test-sms.sh"), + ); + config.setString("challengerdb-postgres", "CONFIG", db.connStr); + const configFile = path.join(t.testDir, "challenger.conf"); + fs.writeFileSync(configFile, config.stringify()); + await runCommand(t, "challenger-dbinit", "challenger-dbinit", [ + "-c", + configFile, + ]); + const clientSecret = "secret-token:test-sms-secret"; + const { clientId } = await createChallengerAdminRegistrar( + configFile, + ).register({ + callbackUrl: new URL("kyc-proof/sms-challenger", exchangeUrl).href, + clientSecret, + }); + const smsDir = fs.mkdtempSync(path.join(t.testDir, "sms-")); + const proc = t.spawnService( + "challenger-httpd", + ["-c", configFile], + "challenger", + { + ...process.env, + TALER_TEST_SMS_DIR: smsDir, + TALER_TEST_PHONE: phone, + }, + ); + await pingProc(proc, new URL("config", baseUrl).href, "SMS Challenger"); + return { + clientId, + clientSecret, + messageFile: path.join(smsDir, phone + ".txt"), + }; +} + +async function readSmsCode(messageFile: string): Promise<string> { + const deadline = Date.now() + 30_000; + while (!fs.existsSync(messageFile)) { + if (Date.now() >= deadline) + throw Error(`No SMS delivered to ${messageFile}`); + await waitMs(200); + } + const code = /\bTAN ([0-9]+)\b/.exec( + fs.readFileSync(messageFile, "utf8"), + )?.[1]; + if (!code) throw Error(`Missing TAN in ${messageFile}`); + return code; +} + +export async function runWalletAndroidTopsKycWithdrawalTest( + t: GlobalTestState, +) { + const wallet = new AndroidWallet(t); + try { + await wallet.prepare([challengerPort]); + const sms = await startSmsChallenger(t); + t.allowLog({ + file: /^exchange-(aggregator|httpd)-testexchange-1-stderr[.]log$/, + level: "WARNING", + message: + /^KYC_OAUTH2_DEBUG_MODE is set: accepting plaintext http:\/\/ endpoint `http:\/\/localhost:600[123]\/(authorize#setup|info|token)' in option `KYC_OAUTH2_(AUTHORIZE|INFO|TOKEN)_URL' of section `kyc-provider-(postal|sms|email)-challenger'; the client secret, authorization codes and access tokens will be transmitted in the clear[.] Never use this in production!$/, + maxOccurrences: 18, + justification: + "Both exchange services load the nine loopback OAuth endpoints in the TOPS test configuration.", + }); + const env = await createTopsEnvironment(t, { + adjustExchangeConfig(config) { + configureAndroidTerms(t, config); + const rule = "kyc-rule-withdraw-limit-low"; + t.assertDeepEqual( + config.getString(rule, "THRESHOLD").required(), + "CHF:200", + ); + t.assertDeepEqual(config.getYesNo(rule, "EXPOSED").required(), true); + t.assertDeepEqual( + config.getString(rule, "TIMEFRAME").required(), + "30 days", + ); + const provider = "kyc-provider-sms-challenger"; + config.setString(provider, "KYC_OAUTH2_CLIENT_ID", sms.clientId); + config.setString( + provider, + "KYC_OAUTH2_CLIENT_SECRET", + sms.clientSecret, + ); + config.setString( + provider, + "KYC_OAUTH2_POST_URL", + exchangeUrl + "kyc-spa/index.html#/completed", + ); + }, + }); + await wallet.flow("setup"); + // Obtain the expected net values from the local exchange's denominations and fees. + await env.walletClient.call(WalletApiOperation.AddExchange, { + uri: env.exchange.baseUrl, + }); + const preview = (amount: "CHF:190" | "CHF:20") => + env.walletClient.call(WalletApiOperation.GetWithdrawalDetailsForAmount, { + exchangeBaseUrl: env.exchange.baseUrl, + amount, + }); + const firstNet = (await preview("CHF:190")).amountEffective; + const secondNet = (await preview("CHF:20")).amountEffective; + const display = (amount: typeof firstNet) => + Amounts.stringifyValue(amount, 2).replace(".", "[.]"); + const first = await startAndroidWithdrawal(wallet, env, "CHF:190"); + await confirmAndroidWithdrawal(env, first); + await wallet.flow("withdraw-finished", { + NET: display(firstNet), + }); + await wallet.flow("balance-amount", { AMOUNT: display(firstNet) }); + + const second = await startAndroidWithdrawal( + wallet, + env, + "CHF:20", + first.user, + ); + await confirmAndroidWithdrawal(env, second); + await wallet.flow("tops-sms-request", { PHONE: phone }); + await wallet.flow("tops-sms-verify", { + CODE: await readSmsCode(sms.messageFile), + }); + await wallet.flow("withdraw-finished", { + NET: display(secondNet), + }); + await wallet.flow("balance-amount", { + AMOUNT: display( + Amounts.stringify(Amounts.add(firstNet, secondNet).amount), + ), + }); + } finally { + await wallet.close(); + } +} + +runWalletAndroidTopsKycWithdrawalTest.suites = ["wallet-android"]; +runWalletAndroidTopsKycWithdrawalTest.timeoutMs = 600_000; diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -295,6 +295,7 @@ import { runWalletWebUiPwaCashAcceptorTest } from "./test-wallet-web-ui-pwa-cash import { runWalletWebUiPwaStartupTest } from "./test-wallet-web-ui-pwa-startup.js"; import { runWalletWebUiPwaLifecycleTest } from "./test-wallet-web-ui-pwa-lifecycle.js"; import { androidWalletTests } from "./test-wallet-android.js"; +import { runWalletAndroidTopsKycWithdrawalTest } from "./test-wallet-android-tops-kyc.js"; import { androidWalletKycTests } from "./test-wallet-android-kyc.js"; import { androidWalletTransactionTests } from "./test-wallet-android-transactions.js"; import { runWalletWebUiPwaStorybookTest } from "./test-wallet-web-ui-pwa-storybook.js"; @@ -632,6 +633,7 @@ const allTests: TestMainFunction[] = [ runWalletWebUiPwaLifecycleTest, ...androidWalletTests, ...androidWalletKycTests, + runWalletAndroidTopsKycWithdrawalTest, ...androidWalletTransactionTests, runWalletWebUiPwaStorybookTest, runWalletWebUiDemoTest, diff --git a/packages/taler-harness/src/integrationtests/wallet-android-test-support.ts b/packages/taler-harness/src/integrationtests/wallet-android-test-support.ts @@ -17,6 +17,8 @@ import fs from "node:fs"; import path from "node:path"; import { + AmountString, + Configuration, createEddsaKeyPair, EddsaPrivP, encodeCrock, @@ -47,6 +49,20 @@ export type AndroidBankUser = Awaited< >; export type AndroidKycOperation = "withdraw" | "merge" | "deposit"; +export function configureAndroidTerms( + t: GlobalTestState, + config: Configuration, +) { + const terms = path.resolve(t.testDir, "terms"); + fs.mkdirSync(path.join(terms, "en"), { recursive: true }); + fs.writeFileSync( + path.join(terms, "en", "v1.txt"), + "Android UI test exchange terms.\n", + ); + config.setString("exchange", "terms_etag", "v1"); + config.setString("exchange", "terms_dir", terms); +} + /** Fresh services and app data per scenario; only the counterparty uses wallet RPC. */ export async function withAndroidWallet( t: GlobalTestState, @@ -64,18 +80,11 @@ export async function withAndroidWallet( const wallet = new AndroidWallet(t); try { await wallet.prepare(); - const terms = path.resolve(t.testDir, "terms"); - fs.mkdirSync(path.join(terms, "en"), { recursive: true }); - fs.writeFileSync( - path.join(terms, "en", "v1.txt"), - "Android UI test exchange terms.\n", - ); const env = await createSimpleTestkudosEnvironmentV3(t, undefined, { forceLibeufin: options.bank === "libeufin", additionalExchangeConfig(exchange) { exchange.changeConfig((config) => { - config.setString("exchange", "terms_etag", "v1"); - config.setString("exchange", "terms_dir", terms); + configureAndroidTerms(t, config); if (options.kycOperation) { configureSimpleKycInfoRule(config, options.kycOperation); config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:1"); @@ -105,20 +114,22 @@ export async function withAndroidWallet( /** Stop at bank authorization, so the scenario controls completion or abort. */ export async function startAndroidWithdrawal( wallet: AndroidWallet, - env: AndroidEnvironment, + env: Pick<AndroidEnvironment, "bankClient">, + amount: AmountString = "TESTKUDOS:10", + account?: AndroidBankUser, ) { - const user = await env.bankClient.createRandomBankUser(); + const user = account ?? (await env.bankClient.createRandomBankUser()); env.bankClient.setAuth(user); const operation = await env.bankClient.createWithdrawalOperation( user.username, - "TESTKUDOS:10", + amount, ); await wallet.flow("withdraw", { WITHDRAW_URI: operation.taler_withdraw_uri }); return { user, operation }; } export async function confirmAndroidWithdrawal( - env: AndroidEnvironment, + env: Pick<AndroidEnvironment, "bankClient">, withdrawal: Awaited<ReturnType<typeof startAndroidWithdrawal>>, ) { env.bankClient.setAuth(withdrawal.user);