summaryrefslogtreecommitdiff
path: root/packages/taler-integrationtests/src/harness.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-09-01 20:37:50 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-09-01 20:37:50 +0530
commit044b7236572089b98a9f230499bb4cd9ad0342a3 (patch)
treef80955c0fdf6e7dc5e836d8b811e43ce637093ab /packages/taler-integrationtests/src/harness.ts
parent7f4ebca0c4330805ea8f3821dba075b34dd2be58 (diff)
downloadwallet-core-044b7236572089b98a9f230499bb4cd9ad0342a3.tar.gz
wallet-core-044b7236572089b98a9f230499bb4cd9ad0342a3.tar.bz2
wallet-core-044b7236572089b98a9f230499bb4cd9ad0342a3.zip
correct refund amounts and better testing
Diffstat (limited to 'packages/taler-integrationtests/src/harness.ts')
-rw-r--r--packages/taler-integrationtests/src/harness.ts38
1 files changed, 37 insertions, 1 deletions
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<ApplyRefundResponse> {
+ 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<PreparePayResult> {
const resp = await this.apiRequest("preparePay", req);
if (resp.type === "response") {