allow repeats in test case

This commit is contained in:
Florian Dold 2020-08-08 16:52:45 +05:30
parent 3321e40bff
commit e8c0a43dd3
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 49 additions and 26 deletions

View File

@ -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>,

View File

@ -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();
});