gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/02: Add test for refund and tip, fix cli testing


From: gnunet
Subject: [taler-wallet-core] 02/02: Add test for refund and tip, fix cli testing gen-*-uri
Date: Fri, 08 May 2020 15:14:31 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository wallet-core.

commit 122574fe05a7f568d4fa968ff4fcde0c403c8a4d
Author: Torsten Grote <address@hidden>
AuthorDate: Fri May 8 10:13:52 2020 -0300

    Add test for refund and tip, fix cli testing gen-*-uri
---
 integrationtests/template.conf   |  3 +++
 integrationtests/test-refund.sh  | 24 ++++++++++++++++++++++++
 integrationtests/test-tip.sh     | 19 +++++++++++++++++++
 src/headless/taler-wallet-cli.ts | 22 +++++++++++++++++-----
 4 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/integrationtests/template.conf b/integrationtests/template.conf
index 99721d3d..306a9c67 100644
--- a/integrationtests/template.conf
+++ b/integrationtests/template.conf
@@ -36,6 +36,9 @@ FORCE_AUDIT = YES
 [instance-default]
 KEYFILE = ${TALER_DATA_HOME}/merchant/default.priv
 NAME = Merchant Inc.
+TIP_EXCHANGE = http://localhost:8081/
+# TODO necessary to specify a different key here?
+TIP_RESERVE_PRIV_FILENAME = ${TALER_DATA_HOME}/merchant/default.priv
 
 [auditor]
 DB = postgres
diff --git a/integrationtests/test-refund.sh b/integrationtests/test-refund.sh
new file mode 100755
index 00000000..40dc65f5
--- /dev/null
+++ b/integrationtests/test-refund.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Script to check that the wallet can handle refund URIs and actually process 
the refund
+
+source "common.sh"
+normal_start_and_wait "refund"
+
+echo "Withdraw TESTKUDOS"
+taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing withdraw -e 
"$EXCHANGE_URL" -b "$BANK_URL" -a "TESTKUDOS:10" >>"$LOG" 2>>"$LOG"
+echo -n "Balance after withdrawal: "
+taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
+REFUND_URI=$(taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing 
gen-refund-uri \
+    -m "$MERCHANT_URL" -k sandbox \
+    -s "first refund" -a "TESTKUDOS:8" -r "TESTKUDOS:2" 2>>"$LOG" | grep -E -m 
1 -o "taler://refund.*insecure=1")
+echo -n "Balance after payment: "
+taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
+echo "Handling refund: $REFUND_URI"
+taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle handle-uri 
"$REFUND_URI" 2>"$LOG"
+taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done 2>>"$LOG" >>"$LOG"
+echo -n "Balance after first refund: "
+taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
+# TODO how to test second refund for same purchase?
+
+echo "SUCCESS"
+exit 0
diff --git a/integrationtests/test-tip.sh b/integrationtests/test-tip.sh
new file mode 100755
index 00000000..1a0ea281
--- /dev/null
+++ b/integrationtests/test-tip.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Script to check that the wallet can handle tip URIs and actually process the 
tips
+
+source "common.sh"
+normal_start_and_wait "tip"
+
+# TODO fund exchange tipping reserve: 404 tipping reserve unknown at exchange
+TIP_URI=$(taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing 
gen-tip-uri \
+    -m "$MERCHANT_URL" -k sandbox -a "TESTKUDOS:5" 2>>"$LOG" | grep -E -m 1 -o 
"taler://tip.*insecure=1")
+echo -n "Balance after tip: "
+taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
+echo "Handling tip: $TIP_URI"
+taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle handle-uri "$TIP_URI" 
2>"$LOG"
+taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done 2>>"$LOG" >>"$LOG"
+echo -n "Balance after first tip: "
+taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
+
+echo "SUCCESS"
+exit 0
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index 3da01a2d..483a9e7c 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -623,12 +623,18 @@ testCli
   .requiredOption("amount", ["-a", "--amount"], clk.STRING, {
     default: "TESTKUDOS:10",
   })
+  .maybeOption("merchant", ["-m", "--merchant"], clk.STRING, {
+    default: "https://backend.test.taler.net/";,
+  })
+  .maybeOption("merchantApiKey", ["-k", "--merchant-api-key"], clk.STRING, {
+    default: "sandbox",
+  })
   .action(async (args) => {
     const merchantBackend = new MerchantBackendConnection(
-      "https://backend.test.taler.net/";,
-      "sandbox",
+      args.genTipUri.merchant ?? "https://backend.test.taler.net/";,
+      args.genTipUri.merchantApiKey ?? "sandbox",
     );
-    const tipUri = await merchantBackend.authorizeTip("TESTKUDOS:10", "test");
+    const tipUri = await merchantBackend.authorizeTip(args.genTipUri.amount, 
"test");
     console.log(tipUri);
   });
 
@@ -662,11 +668,17 @@ testCli
   .requiredOption("summary", ["-s", "--summary"], clk.STRING, {
     default: "Test Payment (for refund)",
   })
+  .maybeOption("merchant", ["-m", "--merchant"], clk.STRING, {
+    default: "https://backend.test.taler.net/";,
+  })
+  .maybeOption("merchantApiKey", ["-k", "--merchant-api-key"], clk.STRING, {
+    default: "sandbox",
+  })
   .action(async (args) => {
     const cmdArgs = args.genRefundUri;
     const merchantBackend = new MerchantBackendConnection(
-      "https://backend.test.taler.net/";,
-      "sandbox",
+      cmdArgs.merchant ?? "https://backend.test.taler.net/";,
+      cmdArgs.merchantApiKey ?? "sandbox",
     );
     const orderResp = await merchantBackend.createOrder(
       cmdArgs.amount,

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]