Testing harness.

No need to import modules dynamically, in order to
provide the euFin implementation of the BankServiceInterface.
This commit is contained in:
ms 2021-11-01 14:25:43 +01:00
parent 404c8c8a73
commit ea2acd1d3c
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
2 changed files with 107 additions and 119 deletions

View File

@ -607,29 +607,9 @@ export namespace BankApi {
}
}
/**
* Method explained here:
* https://github.com/microsoft/TypeScript/issues/2552
*/
module BankServices {
export class PybankService implements BankServiceInterface {
export class BankService implements BankServiceInterface {
proc: ProcessWrapper | undefined;
static fromExistingConfig(gc: GlobalTestState): BankService {
const cfgFilename = gc.testDir + "/bank.conf";
console.log("reading bank config from", cfgFilename);
const config = Configuration.load(cfgFilename);
const bc: BankConfig = {
allowRegistrations: config
.getYesNo("bank", "allow_registrations")
.required(),
currency: config.getString("taler", "currency").required(),
database: config.getString("bank", "database").required(),
httpPort: config.getNumber("bank", "http_port").required(),
};
return new BankService(gc, bc, cfgFilename);
}
static async create(
gc: GlobalTestState,
bc: BankConfig,
@ -724,9 +704,17 @@ module BankServices {
await pingProc(this.proc, url, "bank");
}
}
}
import BankService = BankServices.PybankService;
export { BankService };
/**
* euFin migration:
*
* if (process.env.WALLET_HARNESS_WITH_EUFIN) {
* BankService.prototype = {
* // methods from euFin ..
* };
* }
*
*/
export class FakeBankService {
proc: ProcessWrapper | undefined;

View File

@ -63,7 +63,7 @@ export interface SimpleTestEnvironment {
}
export function getRandomIban(countryCode: string): string {
return `${countryCode}715001051796${Math.floor(Math.random() * 1000000)}`;
return `${countryCode}715001051796${(Math.random().toString().substring(2, 8))}`
}
export function getRandomString(): string {