diff options
Diffstat (limited to 'packages/taler-integrationtests/src/harness.ts')
-rw-r--r-- | packages/taler-integrationtests/src/harness.ts | 38 |
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") { |