gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (4bd37277 -> 122574fe)


From: gnunet
Subject: [taler-wallet-core] branch master updated (4bd37277 -> 122574fe)
Date: Fri, 08 May 2020 15:14:29 +0200

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

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

    from 4bd37277 wallet DB version
     new 06aa5abc clean up integration test shell library
     new 122574fe Add test for refund and tip, fix cli testing gen-*-uri

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 integrationtests/common.sh            | 41 ++++++++++++++++++++---------------
 integrationtests/template.conf        |  3 +++
 integrationtests/test-base.sh         |  5 +----
 integrationtests/test-double-link.sh  |  5 +----
 integrationtests/test-double-spend.sh |  5 +----
 integrationtests/test-refund.sh       | 24 ++++++++++++++++++++
 integrationtests/test-tip.sh          | 19 ++++++++++++++++
 src/headless/taler-wallet-cli.ts      | 22 ++++++++++++++-----
 8 files changed, 90 insertions(+), 34 deletions(-)
 create mode 100755 integrationtests/test-refund.sh
 create mode 100755 integrationtests/test-tip.sh

diff --git a/integrationtests/common.sh b/integrationtests/common.sh
index 4b42531b..8036b825 100644
--- a/integrationtests/common.sh
+++ b/integrationtests/common.sh
@@ -11,7 +11,7 @@ function setup_config() {
     echo " FOUND"
     echo -n "Testing for taler-merchant-httpd"
     # TODO "taler-merchant-httpd -v" should not return an error
-    [[ "$(taler-merchant-httpd -v)" =~ "taler-merchant-httpd v" ]]  || 
exit_skip " MISSING"
+    [[ "$(taler-merchant-httpd -v)" =~ "taler-merchant-httpd v" ]] || 
exit_skip " MISSING"
     echo " FOUND"
 
     trap shutdown_services EXIT
@@ -31,8 +31,11 @@ function setup_config() {
     export CONF=test-${SCRIPT_NAME}.conf
     cp template.conf "$CONF"
 
+    export LOG=test-${SCRIPT_NAME}.log
+    rm "$LOG" 2>/dev/null || true
+
     export WALLET_DB=wallet-${SCRIPT_NAME}.json
-    rm "$WALLET_DB" 2> /dev/null || true
+    rm "$WALLET_DB" 2>/dev/null || true
 
     # Clean up
     DATA_DIR=$(taler-config -f -c "$CONF" -s PATHS -o TALER_HOME)
@@ -46,7 +49,7 @@ function setup_config() {
     MASTER_PRIV_FILE=$(taler-config -f -c "$CONF" -s EXCHANGE -o 
MASTER_PRIV_FILE)
     MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
     mkdir -p "$MASTER_PRIV_DIR"
-    gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null
+    gnunet-ecc -g1 "$MASTER_PRIV_FILE" >/dev/null
     MASTER_PUB=$(gnunet-ecc -p "$MASTER_PRIV_FILE")
     EXCHANGE_URL=$(taler-config -c "$CONF" -s EXCHANGE -o BASE_URL)
     MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
@@ -70,8 +73,8 @@ function setup_services() {
     # setup exchange
     echo "Setting up exchange"
     taler-exchange-dbinit -c "$CONF"
-    taler-exchange-wire -c "$CONF" 2> taler-exchange-wire.log
-    taler-exchange-keyup -L INFO -c "$CONF" -o e2a.dat 2> 
taler-exchange-keyup.log
+    taler-exchange-wire -c "$CONF" 2>taler-exchange-wire.log
+    taler-exchange-keyup -L INFO -c "$CONF" -o e2a.dat 
2>taler-exchange-keyup.log
 
     # setup auditor
     echo "Setting up auditor"
@@ -89,21 +92,20 @@ function setup_services() {
 function launch_services() {
     # Launch services
     echo "Launching services"
-    taler-bank-manage-testing "$CONF" "postgres:///$TARGET_DB" serve-http &> 
bank-"$SCRIPT_NAME".log &
-    taler-exchange-httpd -c "$CONF" 2> taler-exchange-httpd.log &
+    taler-bank-manage-testing "$CONF" "postgres:///$TARGET_DB" serve-http 
&>bank-"$SCRIPT_NAME".log &
+    taler-exchange-httpd -c "$CONF" 2>taler-exchange-httpd.log &
     # shellcheck disable=SC2034
     EXCHANGE_PID=$!
-    taler-merchant-httpd -c "$CONF" -L INFO 2> taler-merchant-httpd.log &
+    taler-merchant-httpd -c "$CONF" -L INFO 2>taler-merchant-httpd.log &
     # shellcheck disable=SC2034
     MERCHANT_PID=$!
-    taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log &
-    taler-auditor-httpd -c "$CONF" 2> taler-auditor-httpd.log &
+    taler-exchange-wirewatch -c "$CONF" 2>taler-exchange-wirewatch.log &
+    taler-auditor-httpd -c "$CONF" 2>taler-auditor-httpd.log &
 }
 
 function wait_for_services() {
     # Wait for bank to be available (usually the slowest)
-    for _ in $(seq 1 50)
-    do
+    for _ in $(seq 1 50); do
         echo -n "."
         sleep 0.2
         OK=0
@@ -113,8 +115,7 @@ function wait_for_services() {
         break
     done
     # Wait for all other services to be available
-    for _ in $(seq 1 50)
-    do
+    for _ in $(seq 1 50); do
         echo -n "."
         sleep 0.1
         OK=0
@@ -127,14 +128,20 @@ function wait_for_services() {
         OK=1
         break
     done
-    if [ 1 != $OK ]
-    then
+    if [ 1 != $OK ]; then
         shutdown_services
         exit_skip "Failed to launch services"
     fi
     echo " DONE"
 }
 
+function normal_start_and_wait() {
+    setup_config "$1"
+    setup_services
+    launch_services
+    wait_for_services
+}
+
 function shutdown_services() {
     echo "Shutting down services"
     jobs -p | xargs --no-run-if-empty kill || true
@@ -144,7 +151,7 @@ function shutdown_services() {
     echo "Final clean up"
     dropdb "$TARGET_DB" >/dev/null 2>/dev/null || true
 
-    rm "$WALLET_DB" 2> /dev/null || true
+    rm "$WALLET_DB" 2>/dev/null || true
 
     rm -rf "$DATA_DIR" || true
     rm "$CONF"
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-base.sh b/integrationtests/test-base.sh
index 80ac466f..32187dd2 100755
--- a/integrationtests/test-base.sh
+++ b/integrationtests/test-base.sh
@@ -4,10 +4,7 @@
 # wallet and merchant.
 
 source "common.sh"
-setup_config "base"
-setup_services
-launch_services
-wait_for_services
+normal_start_and_wait "base"
 
 # run wallet CLI
 echo "Running wallet"
diff --git a/integrationtests/test-double-link.sh 
b/integrationtests/test-double-link.sh
index 5522b94e..62c15273 100755
--- a/integrationtests/test-double-link.sh
+++ b/integrationtests/test-double-link.sh
@@ -2,10 +2,7 @@
 # Script to check that Uris are properly handled when used a second time
 
 source "common.sh"
-setup_config "double-link"
-setup_services
-launch_services
-wait_for_services
+normal_start_and_wait  "double-link"
 
 echo "Getting pay taler:// Uri"
 PAY_URI=$(taler-wallet-cli testing gen-pay-uri -m "$MERCHANT_URL" -k sandbox 
-a "TESTKUDOS:1" -s "foo" | grep -E -o 'taler://.*')
diff --git a/integrationtests/test-double-spend.sh 
b/integrationtests/test-double-spend.sh
index ee2a966f..6edf22a2 100755
--- a/integrationtests/test-double-spend.sh
+++ b/integrationtests/test-double-spend.sh
@@ -2,10 +2,7 @@
 # Script to check that the wallet can not double spend coins and handles this 
error well
 
 source "common.sh"
-setup_config "double-spend"
-setup_services
-launch_services
-wait_for_services
+normal_start_and_wait  "double-spend"
 
 echo "Withdraw TESTKUDOS"
 taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing withdraw -e 
"$EXCHANGE_URL" -b "$BANK_URL" -a "TESTKUDOS:10" >/dev/null
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]