diff options
Diffstat (limited to 'packages/taler-integrationtests/src/harness.ts')
-rw-r--r-- | packages/taler-integrationtests/src/harness.ts | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index 027869d15..2507d12f7 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -50,7 +50,7 @@ import { EddsaKeyPair } from "taler-wallet-core/lib/crypto/talerCrypto"; const exec = util.promisify(require("child_process").exec); -async function delay(ms: number): Promise<void> { +export async function delayMs(ms: number): Promise<void> { return new Promise((resolve, reject) => { setTimeout(() => resolve(), ms); }); @@ -410,7 +410,7 @@ async function pingProc( return; } catch (e) { console.log(`service ${serviceName} not ready:`, e.toString()); - await delay(1000); + await delayMs(1000); } if (!proc || proc.proc.exitCode !== null) { throw Error(`service process ${serviceName} stopped unexpectedly`); @@ -951,14 +951,39 @@ export class MerchantService { } async queryPrivateOrderStatus(instanceName: string, orderId: string) { - let url; + const reqUrl = new URL( + `private/orders/${orderId}`, + this.makeInstanceBaseUrl(instanceName), + ); + const resp = await axios.get(reqUrl.href); + return codecForMerchantOrderPrivateStatusResponse().decode(resp.data); + } + + makeInstanceBaseUrl(instanceName: string): string { if (instanceName === "default") { - url = `http://localhost:${this.merchantConfig.httpPort}/private/orders/${orderId}`; + return `http://localhost:${this.merchantConfig.httpPort}/`; } else { - url = `http://localhost:${this.merchantConfig.httpPort}/instances/${instanceName}/private/orders/${orderId}`; + return `http://localhost:${this.merchantConfig.httpPort}/instances/${instanceName}/`; + } + } + + async giveRefund(r: { + instance: string; + orderId: string; + amount: string; + justification: string; + }): Promise<{ talerRefundUri: string }> { + const reqUrl = new URL( + `private/orders/${r.orderId}/refund`, + this.makeInstanceBaseUrl(r.instance), + ); + const resp = await axios.post(reqUrl.href, { + refund: r.amount, + reason: r.justification, + }); + return { + talerRefundUri: resp.data.taler_refund_uri, } - const resp = await axios.get(url); - return codecForMerchantOrderPrivateStatusResponse().decode(resp.data); } async createOrder( |