summaryrefslogtreecommitdiff
path: root/packages/taler-integrationtests/src/harness.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-integrationtests/src/harness.ts')
-rw-r--r--packages/taler-integrationtests/src/harness.ts51
1 files changed, 50 insertions, 1 deletions
diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts
index e8a0941d2..0cf769163 100644
--- a/packages/taler-integrationtests/src/harness.ts
+++ b/packages/taler-integrationtests/src/harness.ts
@@ -44,6 +44,12 @@ import {
codecForPreparePayResultPaymentPossible,
codecForPreparePayResult,
OperationFailedError,
+ AddExchangeRequest,
+ ExchangesListRespose,
+ codecForExchangesListResponse,
+ GetWithdrawalDetailsForUriRequest,
+ WithdrawUriInfoResponse,
+ codecForWithdrawUriInfoResponse,
} from "taler-wallet-core";
import { URL } from "url";
import axios from "axios";
@@ -60,6 +66,7 @@ import {
eddsaGetPublic,
createEddsaKeyPair,
} from "taler-wallet-core/lib/crypto/talerCrypto";
+import { WithdrawalDetails } from "taler-wallet-core/lib/types/transactions";
const exec = util.promisify(require("child_process").exec);
@@ -244,6 +251,22 @@ export class GlobalTestState {
process.on("uncaughtException", () => this.shutdownSync());
}
+ async assertThrowsOperationErrorAsync(
+ block: () => Promise<void>,
+ ): Promise<OperationFailedError> {
+ try {
+ await block();
+ } catch (e) {
+ if (e instanceof OperationFailedError) {
+ return e;
+ }
+ throw Error(`expected OperationFailedError to be thrown, but got ${e}`);
+ }
+ throw Error(
+ `expected OperationFailedError to be thrown, but block finished without throwing`,
+ );
+ }
+
assertTrue(b: boolean): asserts b {
if (!b) {
throw Error("test assertion failed");
@@ -488,7 +511,7 @@ export class BankService {
return new BankService(gc, bc, cfgFilename);
}
- setSuggestedExchange(e: ExchangeService, exchangePayto: string) {
+ setSuggestedExchange(e: ExchangeServiceInterface, exchangePayto: string) {
const config = Configuration.load(this.configFile);
config.setString("bank", "suggested_exchange", e.baseUrl);
config.setString("bank", "suggested_exchange_payto", exchangePayto);
@@ -1153,4 +1176,30 @@ export class WalletCli {
}
throw new OperationFailedError(resp.error);
}
+
+ async addExchange(req: AddExchangeRequest): Promise<void> {
+ const resp = await this.apiRequest("addExchange", req);
+ if (resp.type === "response") {
+ return;
+ }
+ throw new OperationFailedError(resp.error);
+ }
+
+ async listExchanges(): Promise<ExchangesListRespose> {
+ const resp = await this.apiRequest("listExchanges", {});
+ if (resp.type === "response") {
+ return codecForExchangesListResponse().decode(resp.result);
+ }
+ throw new OperationFailedError(resp.error);
+ }
+
+ async getWithdrawalDetailsForUri(
+ req: GetWithdrawalDetailsForUriRequest,
+ ): Promise<WithdrawUriInfoResponse> {
+ const resp = await this.apiRequest("getWithdrawalDetailsForUri", req);
+ if (resp.type === "response") {
+ return codecForWithdrawUriInfoResponse().decode(resp.result);
+ }
+ throw new OperationFailedError(resp.error);
+ }
}