diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-08-08 16:52:45 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-08-08 16:52:45 +0530 |
commit | e8c0a43dd37f34ae8227d02c87b1ed7ab368d03c (patch) | |
tree | f077e1ff0a16b1e3ea3c775ca17a0389afe29a50 | |
parent | 3321e40bffc5fe47133342d63f706a005a652273 (diff) |
allow repeats in test case
-rw-r--r-- | packages/taler-integrationtests/src/harness.ts | 9 | ||||
-rw-r--r-- | packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts | 66 |
2 files changed, 49 insertions, 26 deletions
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<string, unknown>, 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<void> { 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(); }); |