diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index 18a88d260..d092a9733 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -591,9 +591,7 @@ export class ExchangeService implements ExchangeServiceInterface { name: exchangeName, roundUnit: config.getString("taler", "currency_round_unit").required(), }; - const privFile = config - .getPath("exchange", "master_priv_file") - .required(); + const privFile = config.getPath("exchange", "master_priv_file").required(); const eddsaPriv = fs.readFileSync(privFile); const keyPair: EddsaKeyPair = { eddsaPriv, @@ -991,6 +989,11 @@ function shellWrap(s: string) { export class WalletCli { constructor(private globalTestState: GlobalTestState) {} + deleteDatabase() { + const wdb = this.globalTestState.testDir + "/walletdb.json"; + fs.unlinkSync(wdb); + } + async apiRequest( request: string, payload: Record, diff --git a/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts b/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts index 967b53910..a755aa939 100644 --- a/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts +++ b/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts @@ -41,29 +41,13 @@ const prevT = new GlobalTestState({ testDir: existingTestDir, }); -/** - * Run test. - */ -runTestWithState(prevT, async (t: GlobalTestState) => { - // Set up test environment - - const bank = BankService.fromExistingConfig(t); - const exchange = ExchangeService.fromExistingConfig(t, "testexchange-1"); - const merchant = MerchantService.fromExistingConfig(t, "testmerchant-1"); - - await bank.start(); - await exchange.start(); - await merchant.start(); - await Promise.all([ - bank.pingUntilAvailable(), - merchant.pingUntilAvailable(), - exchange.pingUntilAvailable(), - ]); - - const wallet = new WalletCli(t); - - // Withdraw digital cash into the wallet. - +async function withdrawAndPay( + t: GlobalTestState, + wallet: WalletCli, + bank: BankService, + exchange: ExchangeService, + merchant: MerchantService, +): Promise { await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:100" }); // Set up order. @@ -104,6 +88,42 @@ runTestWithState(prevT, async (t: GlobalTestState) => { ); t.assertTrue(orderStatus.order_status === "paid"); +} + +/** + * Run test. + */ +runTestWithState(prevT, async (t: GlobalTestState) => { + // Set up test environment + + const bank = BankService.fromExistingConfig(t); + const exchange = ExchangeService.fromExistingConfig(t, "testexchange-1"); + const merchant = MerchantService.fromExistingConfig(t, "testmerchant-1"); + + await bank.start(); + await exchange.start(); + await merchant.start(); + await Promise.all([ + bank.pingUntilAvailable(), + merchant.pingUntilAvailable(), + exchange.pingUntilAvailable(), + ]); + + const wallet = new WalletCli(t); + + // Withdraw digital cash into the wallet. + + const repetitions = Number.parseInt(process.env["TALER_TEST_REPEAT"] ?? "1"); + + for (let rep = 0; rep < repetitions; rep++) { + console.log("repetition", rep); + try { + wallet.deleteDatabase(); + await withdrawAndPay(t, wallet, bank, exchange, merchant); + } catch (e) { + console.log("ignoring exception", e); + } + } await t.shutdown(); });