From 044b7236572089b98a9f230499bb4cd9ad0342a3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 1 Sep 2020 20:37:50 +0530 Subject: correct refund amounts and better testing --- packages/taler-integrationtests/src/harness.ts | 38 +++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'packages/taler-integrationtests/src/harness.ts') diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index 93999c871..0b41923a4 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -42,7 +42,6 @@ import { CoreApiResponse, PreparePayResult, PreparePayRequest, - codecForPreparePayResultPaymentPossible, codecForPreparePayResult, OperationFailedError, AddExchangeRequest, @@ -67,6 +66,8 @@ import { codecForTransactionsResponse, WithdrawTestBalanceRequest, AmountString, + ApplyRefundRequest, + codecForApplyRefundResponse, } from "taler-wallet-core"; import { URL } from "url"; import axios, { AxiosError } from "axios"; @@ -77,6 +78,7 @@ import { PostOrderResponse, MerchantOrderPrivateStatusResponse, } from "./merchantApiTypes"; +import { ApplyRefundResponse } from "taler-wallet-core"; const exec = util.promisify(require("child_process").exec); @@ -384,6 +386,32 @@ export class GlobalTestState { } } + assertAmountLeq( + amtExpected: string | AmountJson, + amtActual: string | AmountJson, + ): void { + let ja1: AmountJson; + let ja2: AmountJson; + if (typeof amtExpected === "string") { + ja1 = Amounts.parseOrThrow(amtExpected); + } else { + ja1 = amtExpected; + } + if (typeof amtActual === "string") { + ja2 = Amounts.parseOrThrow(amtActual); + } else { + ja2 = amtActual; + } + + if (Amounts.cmp(ja1, ja2) > 0) { + throw Error( + `test assertion failed: expected ${Amounts.stringify( + ja1, + )} to be less or equal (leq) than ${Amounts.stringify(ja2)}`, + ); + } + } + private shutdownSync(): void { for (const s of this.servers) { s.close(); @@ -1512,6 +1540,14 @@ export class WalletCli { ); } + async applyRefund(req: ApplyRefundRequest): Promise { + const resp = await this.apiRequest("applyRefund", req); + if (resp.type === "response") { + return codecForApplyRefundResponse().decode(resp.result); + } + throw new OperationFailedError(resp.error); + } + async preparePay(req: PreparePayRequest): Promise { const resp = await this.apiRequest("preparePay", req); if (resp.type === "response") { -- cgit v1.2.3