diff options
Diffstat (limited to 'packages/taler-harness/src/harness/harness.ts')
-rw-r--r-- | packages/taler-harness/src/harness/harness.ts | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 68c0744fc..136ec3d15 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -25,7 +25,6 @@ * Imports */ import { - AccountAddDetails, AccountRestriction, AmountJson, Amounts, @@ -36,8 +35,10 @@ import { Logger, MerchantInstanceConfig, PartialMerchantInstanceConfig, + PaytoString, TalerCorebankApiClient, TalerError, + TalerMerchantApi, WalletNotification, createEddsaKeyPair, eddsaGetPublic, @@ -651,7 +652,7 @@ export class FakebankService config.setString("bank", "max_debt", bc.maxDebt ?? `${bc.currency}:100`); config.setString("bank", "ram_limit", `${1024}`); const cfgFilename = testDir + "/bank.conf"; - config.write(cfgFilename, { excludeDefaults: true }); + config.writeTo(cfgFilename, { excludeDefaults: true }); return new FakebankService(gc, bc, cfgFilename); } @@ -680,7 +681,7 @@ export class FakebankService } const config = Configuration.load(this.configFile); config.setString("bank", "suggested_exchange", e.baseUrl); - config.write(this.configFile, { excludeDefaults: true }); + config.writeTo(this.configFile, { excludeDefaults: true }); } get baseUrl(): string { @@ -779,6 +780,17 @@ export class LibeufinBankService config.setString("libeufin-bank", "currency", bc.currency); config.setString("libeufin-bank", "port", `${bc.httpPort}`); config.setString("libeufin-bank", "serve", "tcp"); + config.setString("libeufin-bank", "wire_type", "x-taler-bank"); + config.setString( + "libeufin-bank", + "x_taler_bank_payto_hostname", + "localhost", + ); + config.setString( + "libeufin-bank", + "default_debt_limit", + bc.maxDebt ?? `${bc.currency}:100`, + ); config.setString( "libeufin-bank", "DEFAULT_DEBT_LIMIT", @@ -790,7 +802,7 @@ export class LibeufinBankService `${bc.currency}:100`, ); const cfgFilename = testDir + "/bank.conf"; - config.write(cfgFilename, { excludeDefaults: true }); + config.writeTo(cfgFilename, { excludeDefaults: true }); return new LibeufinBankService(gc, bc, cfgFilename); } @@ -828,7 +840,7 @@ export class LibeufinBankService "suggested_withdrawal_exchange", e.baseUrl, ); - config.write(this.configFile, { excludeDefaults: true }); + config.writeTo(this.configFile, { excludeDefaults: true }); } get baseUrl(): string { @@ -887,15 +899,21 @@ export class LibeufinBankService } // Use libeufin bank instead of pybank. -const useLibeufinBank = false; +export const useLibeufinBank = process.env["WITH_LIBEUFIN"] === "1"; export interface BankServiceHandle { readonly corebankApiBaseUrl: string; readonly http: HttpRequestLibrary; + + setSuggestedExchange(exchange: ExchangeService, exchangePayto: string): void; + start(): Promise<void>; + pingUntilAvailable(): Promise<void>; } export type BankService = BankServiceHandle; -export const BankService = FakebankService; +export const BankService = useLibeufinBank + ? LibeufinBankService + : FakebankService; export interface ExchangeConfig { name: string; @@ -1052,7 +1070,7 @@ export class ExchangeService implements ExchangeServiceInterface { changeConfig(f: (config: Configuration) => void) { const config = Configuration.load(this.configFilename); f(config); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } static create(gc: GlobalTestState, e: ExchangeConfig) { @@ -1118,7 +1136,7 @@ export class ExchangeService implements ExchangeServiceInterface { fs.writeFileSync(masterPrivFile, Buffer.from(exchangeMasterKey.eddsaPriv)); const cfgFilename = testDir + `/exchange-${e.name}.conf`; - config.write(cfgFilename, { excludeDefaults: true }); + config.writeTo(cfgFilename, { excludeDefaults: true }); return new ExchangeService(gc, e, cfgFilename, exchangeMasterKey); } @@ -1127,13 +1145,13 @@ export class ExchangeService implements ExchangeServiceInterface { offeredCoins.forEach((cc) => setCoin(config, cc(this.exchangeConfig.currency)), ); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } addCoinConfigList(ccs: CoinConfig[]) { const config = Configuration.load(this.configFilename); ccs.forEach((cc) => setCoin(config, cc)); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } enableAgeRestrictions(maskStr: string) { @@ -1144,7 +1162,7 @@ export class ExchangeService implements ExchangeServiceInterface { "age_groups", maskStr, ); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } get masterPub() { @@ -1165,7 +1183,7 @@ export class ExchangeService implements ExchangeServiceInterface { ): Promise<void> { const config = Configuration.load(this.configFilename); await f(config); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } async addBankAccount( @@ -1206,7 +1224,7 @@ export class ExchangeService implements ExchangeServiceInterface { "password", exchangeBankAccount.accountPassword, ); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } exchangeHttpProc: ProcessWrapper | undefined; @@ -1701,7 +1719,7 @@ export class MerchantService implements MerchantServiceInterface { config.setString("merchantdb-postgres", "config", mc.database); // Do not contact demo.taler.net exchange in tests config.setString("merchant-exchange-kudos", "disabled", "yes"); - config.write(cfgFilename, { excludeDefaults: true }); + config.writeTo(cfgFilename, { excludeDefaults: true }); return new MerchantService(gc, mc, cfgFilename); } @@ -1719,7 +1737,7 @@ export class MerchantService implements MerchantServiceInterface { this.merchantConfig.currency, ); config.setString(`merchant-exchange-${e.name}`, "master_key", e.masterPub); - config.write(this.configFilename, { excludeDefaults: true }); + config.writeTo(this.configFilename, { excludeDefaults: true }); } async addDefaultInstance(): Promise<void> { @@ -1770,8 +1788,8 @@ export class MerchantService implements MerchantServiceInterface { 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 accountReq: TalerMerchantApi.AccountAddDetails = { + payto_uri: paytoUri as PaytoString, }; const acctResp = await harnessHttpLib.fetch(accountCreateUrl, { method: "POST", @@ -2234,7 +2252,6 @@ export function generateRandomTestIban(salt: string | null = null): string { } export function getWireMethodForTest(): string { - if (useLibeufinBank) return "iban"; return "x-taler-bank"; } @@ -2243,10 +2260,6 @@ export function getWireMethodForTest(): string { * on whether the banking is served by euFin or Pybank. */ export function generateRandomPayto(label: string): string { - if (useLibeufinBank) - return `payto://iban/SANDBOXX/${generateRandomTestIban( - label, - )}?receiver-name=${label}`; return `payto://x-taler-bank/localhost/${label}?receiver-name=${label}`; } |