summaryrefslogtreecommitdiff
path: root/packages/taler-integrationtests/src/harness.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-08-10 16:48:38 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-08-10 16:48:38 +0530
commit66d76a35912d7687d76b349f1cac462306306d3f (patch)
tree3cdfce8178c3928dbcfc13263f8752b3f9ca9c7b /packages/taler-integrationtests/src/harness.ts
parent5f8714091aac80144be118fa6427d65222e7509c (diff)
downloadwallet-core-66d76a35912d7687d76b349f1cac462306306d3f.tar.gz
wallet-core-66d76a35912d7687d76b349f1cac462306306d3f.tar.bz2
wallet-core-66d76a35912d7687d76b349f1cac462306306d3f.zip
simplify refunds a bit, show in transaction history, add integration tests
Diffstat (limited to 'packages/taler-integrationtests/src/harness.ts')
-rw-r--r--packages/taler-integrationtests/src/harness.ts39
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(