diff options
author | Florian Dold <florian@dold.me> | 2021-10-14 11:36:43 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-10-14 11:36:43 +0200 |
commit | c53264869451ccbfbaf1976e01df8c7636163068 (patch) | |
tree | a6f4359d4fcd558ee443991111404bc095642e5b /packages/taler-wallet-cli/src/integrationtests/harness.ts | |
parent | 6f4c0a6fb244b8e42b6d91edd3c5901ae39f2202 (diff) | |
download | wallet-core-c53264869451ccbfbaf1976e01df8c7636163068.tar.xz |
implement fakebank withdrawal
Diffstat (limited to 'packages/taler-wallet-cli/src/integrationtests/harness.ts')
-rw-r--r-- | packages/taler-wallet-cli/src/integrationtests/harness.ts | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts b/packages/taler-wallet-cli/src/integrationtests/harness.ts index a3a6e9e1c..6644e567f 100644 --- a/packages/taler-wallet-cli/src/integrationtests/harness.ts +++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts @@ -395,6 +395,11 @@ export interface BankConfig { maxDebt?: string; } +export interface FakeBankConfig { + currency: string; + httpPort: number; +} + function setTalerPaths(config: Configuration, home: string) { config.setString("paths", "taler_home", home); // We need to make sure that the path of taler_runtime_dir isn't too long, @@ -714,6 +719,62 @@ export class BankService implements BankServiceInterface { } } +export class FakeBankService { + proc: ProcessWrapper | undefined; + + static fromExistingConfig(gc: GlobalTestState): FakeBankService { + const cfgFilename = gc.testDir + "/bank.conf"; + console.log("reading fakebank config from", cfgFilename); + const config = Configuration.load(cfgFilename); + const bc: FakeBankConfig = { + currency: config.getString("taler", "currency").required(), + httpPort: config.getNumber("bank", "http_port").required(), + }; + return new FakeBankService(gc, bc, cfgFilename); + } + + static async create( + gc: GlobalTestState, + bc: FakeBankConfig, + ): Promise<FakeBankService> { + const config = new Configuration(); + setTalerPaths(config, gc.testDir + "/talerhome"); + config.setString("taler", "currency", bc.currency); + config.setString("bank", "http_port", `${bc.httpPort}`); + const cfgFilename = gc.testDir + "/bank.conf"; + config.write(cfgFilename); + return new FakeBankService(gc, bc, cfgFilename); + } + + get baseUrl(): string { + return `http://localhost:${this.bankConfig.httpPort}/`; + } + + get port() { + return this.bankConfig.httpPort; + } + + private constructor( + private globalTestState: GlobalTestState, + private bankConfig: FakeBankConfig, + private configFile: string, + ) {} + + async start(): Promise<void> { + this.proc = this.globalTestState.spawnService( + "taler-fakebank-run", + ["-c", this.configFile], + "fakebank", + ); + } + + async pingUntilAvailable(): Promise<void> { + // Fakebank doesn't have "/config", so we ping just "/". + const url = `http://localhost:${this.bankConfig.httpPort}/`; + await pingProc(this.proc, url, "bank"); + } +} + export interface BankUser { username: string; password: string; |