aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli/src/integrationtests/harness.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-cli/src/integrationtests/harness.ts')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/harness.ts61
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;