diff options
author | Florian Dold <florian@dold.me> | 2022-04-19 17:12:43 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-04-27 00:50:17 +0200 |
commit | a165afa6824980c409d7c2e22e24171e536800e0 (patch) | |
tree | 0e8491f092aba2280655ee4728fef0ca02bb8387 /packages/taler-wallet-cli/src/harness/helpers.ts | |
parent | 9b85d139bf7bdc360ea0894e09f6115cd9d472d8 (diff) | |
download | wallet-core-a165afa6824980c409d7c2e22e24171e536800e0.tar.xz |
wallet-core: implement age restriction support
Diffstat (limited to 'packages/taler-wallet-cli/src/harness/helpers.ts')
-rw-r--r-- | packages/taler-wallet-cli/src/harness/helpers.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/taler-wallet-cli/src/harness/helpers.ts b/packages/taler-wallet-cli/src/harness/helpers.ts index 3840dcf94..db66efbb6 100644 --- a/packages/taler-wallet-cli/src/harness/helpers.ts +++ b/packages/taler-wallet-cli/src/harness/helpers.ts @@ -65,6 +65,13 @@ export interface SimpleTestEnvironment { wallet: WalletCli; } +export interface EnvOptions { + /** + * If provided, enable age restrictions with the specified age mask string. + */ + ageMaskSpec?: string; +} + /** * Run a test case with a simple TESTKUDOS Taler environment, consisting * of one exchange, one bank and one merchant. @@ -72,6 +79,7 @@ export interface SimpleTestEnvironment { export async function createSimpleTestkudosEnvironment( t: GlobalTestState, coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")), + opts: EnvOptions = {}, ): Promise<SimpleTestEnvironment> { const db = await setupDb(t); @@ -108,7 +116,17 @@ export async function createSimpleTestkudosEnvironment( await bank.pingUntilAvailable(); - exchange.addCoinConfigList(coinConfig); + const ageMaskSpec = opts.ageMaskSpec; + + if (ageMaskSpec) { + exchange.enableAgeRestrictions(ageMaskSpec); + // Enable age restriction for all coins. + exchange.addCoinConfigList( + coinConfig.map((x) => ({ ...x, ageRestricted: true })), + ); + } else { + exchange.addCoinConfigList(coinConfig); + } await exchange.start(); await exchange.pingUntilAvailable(); @@ -259,6 +277,7 @@ export async function startWithdrawViaBank( bank: BankService; exchange: ExchangeServiceInterface; amount: AmountString; + restrictAge?: number; }, ): Promise<void> { const { wallet, bank, exchange, amount } = p; @@ -270,6 +289,7 @@ export async function startWithdrawViaBank( await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, { talerWithdrawUri: wop.taler_withdraw_uri, + restrictAge: p.restrictAge, }); await wallet.runPending(); @@ -279,6 +299,7 @@ export async function startWithdrawViaBank( await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, { exchangeBaseUrl: exchange.baseUrl, talerWithdrawUri: wop.taler_withdraw_uri, + restrictAge: p.restrictAge, }); // Confirm it @@ -299,6 +320,7 @@ export async function withdrawViaBank( bank: BankService; exchange: ExchangeServiceInterface; amount: AmountString; + restrictAge?: number; }, ): Promise<void> { const { wallet } = p; |