gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (fe0d697 -> bf6a766)


From: gnunet
Subject: [taler-anastasis] branch master updated (fe0d697 -> bf6a766)
Date: Thu, 10 Dec 2020 11:29:33 +0100

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

dennis-neufeld pushed a change to branch master
in repository anastasis.

    from fe0d697  worked on payment
     new fca0da2  fix policy payment url
     new dbd2459  worked on policy upload payment
     new bf6a766  worked on payment...

The 3 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:
 src/backend/anastasis-httpd_policy_upload.c        | 41 +++++++++++---
 src/cli/test_anastasis_reducer_enter_secret.sh     | 63 +++++++++++++++++----
 src/cli/test_anastasis_reducer_initialize_state.sh | 46 +--------------
 src/cli/test_anastasis_reducer_select_continent.sh | 44 +--------------
 src/lib/Makefile.am                                |  2 +
 src/lib/anastasis.c                                | 65 +++++-----------------
 src/lib/anastasis_api_backup_redux.c               | 27 ++++-----
 src/lib/testing_api_cmd_policy_store.c             | 38 +++----------
 src/lib/testing_api_cmd_truth_store.c              | 34 ++++-------
 src/lib/testing_cmd_secret_share.c                 | 39 ++++---------
 10 files changed, 146 insertions(+), 253 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 4c077ec..331f20a 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -244,18 +244,45 @@ make_payment_request (const char *order_id)
   resp = MHD_create_response_from_buffer (0,
                                           NULL,
                                           MHD_RESPMEM_PERSISTENT);
-  GNUNET_break (MHD_YES ==
-                MHD_add_response_header (resp,
-                                         
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
-                                         "*"));
+  TALER_MHD_add_global_headers (resp);
   {
     char *hdr;
+    char *pfx;
+    char *hn;
+
+    if (0 == strncasecmp ("https://";,
+                          AH_backend_url,
+                          strlen ("https://";)))
+    {
+      pfx = "taler://";
+      hn = &AH_backend_url[strlen ("https://";)];
+    }
+    else if (0 == strncasecmp ("http://";,
+                               AH_backend_url,
+                               strlen ("http://";)))
+    {
+      pfx = "taler+http://";;
+      hn = &AH_backend_url[strlen ("http://";)];
+    }
+    else
+    {
+      GNUNET_break (0);
+      MHD_destroy_response (resp);
+      return NULL;
+    }
+    if (0 == strlen (hn))
+    {
+      GNUNET_break (0);
+      MHD_destroy_response (resp);
+      return NULL;
+    }
 
-    /* TODO: support instances? */
     GNUNET_asprintf (&hdr,
-                     "taler://pay/%s/-/-/%s",
-                     AH_backend_url,
+                     "%spay/%s%s/",
+                     pfx,
+                     hn,
                      order_id);
+
     GNUNET_break (MHD_YES ==
                   MHD_add_response_header (resp,
                                            "Taler",
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh 
b/src/cli/test_anastasis_reducer_enter_secret.sh
index 7d1e753..ef6e28f 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -1,4 +1,9 @@
 #!/bin/bash
+## Coloring style Text shell script
+COLOR='\033[0;35m'
+NOCOLOR='\033[0m'
+BOLD="$(tput bold)"
+NORM="$(tput sgr0)"
 
 set -eu
 
@@ -22,11 +27,13 @@ function cleanup()
         kill $n 2> /dev/null || true
     done
     rm -f $CONF $CONF_1 $CONF_2 $CONF_3 $CONF_4 $WALLET_DB
+    rm -r $TMP_DIR
     wait
 }
 
 # Install cleanup handler (except for kill -9)
-WALLET_DB=`mktemp test_reducer_walletXXXXXX.wdb`
+TMP_DIR=`mktemp -d keys-tmp-XXXXXX`
+WALLET_DB=`mktemp test_reducer_walletXXXXXX.json`
 CONF=`mktemp test_reducerXXXXXX.conf`
 CONF_1=`mktemp test_reducerXXXXXX_1.conf`
 CONF_2=`mktemp test_reducerXXXXXX_2.conf`
@@ -58,6 +65,19 @@ echo -n "Testing for anastasis-httpd"
 anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
 echo " FOUND"
 
+if [ -e $SFILE ]
+then
+    echo " "
+    echo "Ressources existing"
+else
+    echo " "
+    echo "Ressources not existing..."
+    echo "Setting up ressources..."
+    # run other tests before to set up ressources
+    make check 
+    echo "Ressources created"
+fi
+
 # Name of the Postgres database we will use for the script.
 # Will be dropped, do NOT use anything that might be used
 # elsewhere
@@ -114,6 +134,7 @@ taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V 
postgres:///$TALER_DB
 taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TALER_DB
 taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
 taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
+taler-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
 
 # setup exchange
 echo "Setting up exchange"
@@ -187,11 +208,11 @@ echo " ANASTASIS SETUP DONE"
 echo " "
 echo " "
 echo " "
-echo "Beginning with actual reducer test"
+echo -e $COLOR$BOLD"Beginning with actual reducer test"$NORM$NOCOLOR
 
 # Test enter secret in a backup state
 echo " "
-echo "Test enter secret in a backup state"
+echo -e $COLOR$BOLD"Test enter secret in a backup state"$NORM$NOCOLOR
 mkdir -p ressources
 touch $TFILE
 ./anastasis-reducer -a \
@@ -212,22 +233,42 @@ then
 fi
 
 echo " "
-echo "Current state of policy uploads:"
+echo -e $COLOR$BOLD"Current state of policy uploads:"$NORM$NOCOLOR
 POLICY_UPLOADS=`jq -r -e .recovery_document_uploads < $TFILE`
 echo $POLICY_UPLOADS
 #Pay
 echo " "
-echo "Try to pay for upload"
+echo -e $COLOR$BOLD"Try to pay for upload"$NORM$NOCOLOR
+#First make a withdraw to wallet
+echo " "
+echo -e $COLOR$BOLD"Withdrawing amount to wallet"$NORM$NOCOLOR
+taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 
'withdrawTestBalance' \
+  "$(jq -n '
+    {
+        amount: "TESTKUDOS:20",
+        bankBaseUrl: $BANK_URL,
+        exchangeBaseUrl: $EXCHANGE_URL
+    }' \
+    --arg BANK_URL "$BANK_URL" \
+    --arg EXCHANGE_URL "$EXCHANGE_URL"
+  )"
+taler-wallet-cli --wallet-db=$WALLET_DB run-until-done
+
+echo " "
+echo -e $COLOR$BOLD"Parsing policy uploads for payment-uri"$NORM$NOCOLOR
 ARRAY_LENGTH=`jq -r -e '.recovery_document_uploads | length' < $TFILE`
 for ((INDEX=0; INDEX < $ARRAY_LENGTH; INDEX++))
 do
-    PAY_URL=`jq -r -e .recovery_document_uploads[$INDEX].pay_url < $TFILE`
-    echo "PAY_URL: $PAY_URL"
+    PAY_URI=`jq -r -e .recovery_document_uploads[$INDEX].pay_url < $TFILE`
+    echo " "
+    echo "[$INDEX] PAY_URI: $PAY_URI"
     # run wallet CLI
-    echo "Running wallet"
-    taler-wallet-cli --no-throttle handle-uri $PAY_URL
+    echo " "
+    echo -e $COLOR$BOLD"[$INDEX] Running wallet handle-uri"$NORM$NOCOLOR
+    taler-wallet-cli --wallet-db=$WALLET_DB handle-uri $PAY_URI -y
 done
-taler-wallet-cli run-pending
-
+echo " "
+echo -e $COLOR$BOLD"Running wallet run-pending"$NORM$NOCOLOR
+taler-wallet-cli --wallet-db=$WALLET_DB run-pending
 
 exit 0
diff --git a/src/cli/test_anastasis_reducer_initialize_state.sh 
b/src/cli/test_anastasis_reducer_initialize_state.sh
index 2a730e8..87f45e9 100755
--- a/src/cli/test_anastasis_reducer_initialize_state.sh
+++ b/src/cli/test_anastasis_reducer_initialize_state.sh
@@ -21,12 +21,11 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $SFILE $TFILE $CONF
+    rm -f $SFILE $TFILE
     wait
 }
 
 # Install cleanup handler (except for kill -9)
-CONF=`mktemp test_reducerXXXXXX.conf`
 SFILE=`mktemp test_reducer_stateXXXXXX`
 TFILE=`mktemp test_reducer_stateXXXXXX`
 
@@ -37,52 +36,9 @@ echo -n "Testing for jq"
 jq -h > /dev/null || exit_skip "jq required"
 echo " FOUND"
 
-echo -n "Testing for anastasis-httpd"
-anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
-echo " FOUND"
-
-
-# Name of the Postgres database we will use for the script.
-# Will be dropped, do NOT use anything that might be used
-# elsewhere
-TARGET_DB=anastasischeck
-
-# Configuration file will be edited, so we create one
-# from the template.
-cp test_anastasis_reducer.conf $CONF
-
-# reset database
-dropdb $TARGET_DB >/dev/null 2>/dev/null || true
-createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
-
-# Launch services
-echo "Launching anastasis service"
-anastasis-httpd -c $CONF 2> anastasis-httpd.log &
-
-# Wait for anastasis service to be available
-for n in `seq 1 50`
-do
-    echo -n "."
-    sleep 0.1
-    OK=0
-    # anastasis
-    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
-    OK=1
-    break
-done
-
-if [ 1 != $OK ]
-then
-    exit_skip "Failed to launch anastasis service"
-fi
-
-echo " ANASTASIS SETUP DONE"
-echo " "
-echo " "
 echo " "
 echo "Beginning with actual reducer test"
 
-
 echo " "
 echo "Test initialization of a backup state"
 ./anastasis-reducer -b $SFILE
diff --git a/src/cli/test_anastasis_reducer_select_continent.sh 
b/src/cli/test_anastasis_reducer_select_continent.sh
index cf0a437..404c58c 100755
--- a/src/cli/test_anastasis_reducer_select_continent.sh
+++ b/src/cli/test_anastasis_reducer_select_continent.sh
@@ -21,7 +21,7 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $SFILE $TFILE $CONF
+    rm -f $SFILE $TFILE
     wait
 }
 
@@ -37,48 +37,6 @@ echo -n "Testing for jq"
 jq -h > /dev/null || exit_skip "jq required"
 echo " FOUND"
 
-echo -n "Testing for anastasis-httpd"
-anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
-echo " FOUND"
-
-
-# Name of the Postgres database we will use for the script.
-# Will be dropped, do NOT use anything that might be used
-# elsewhere
-TARGET_DB=anastasischeck
-
-# Configuration file will be edited, so we create one
-# from the template.
-cp test_anastasis_reducer.conf $CONF
-
-# reset database
-dropdb $TARGET_DB >/dev/null 2>/dev/null || true
-createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
-
-# Launch services
-echo "Launching anastasis service"
-anastasis-httpd -c $CONF 2> anastasis-httpd.log &
-
-# Wait for anastasis service to be available
-for n in `seq 1 50`
-do
-    echo -n "."
-    sleep 0.1
-    OK=0
-    # anastasis
-    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
-    OK=1
-    break
-done
-
-if [ 1 != $OK ]
-then
-    exit_skip "Failed to launch anastasis service"
-fi
-
-echo " ANASTASIS SETUP DONE"
-echo " "
-echo " "
 echo " "
 echo "Beginning with actual reducer test"
 
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index c254cae..44fae35 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -55,6 +55,7 @@ libanastasis_la_LIBADD = \
   -lgnunetutil \
   -ljansson \
   -ltalerutil \
+  -ltalermerchant \
   $(XLIB)
 
 libanastasistesting_la_LDFLAGS = \
@@ -117,6 +118,7 @@ libanastasisredux_la_LIBADD = \
   -lgnunetutil \
   -ltalermhd \
   -ltalerutil \
+  -ltalermerchant \
   -ltalerjson \
   -ljansson \
   $(XLIB)
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index cb2b4a5..2cb7703 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -23,6 +23,7 @@
 #include "anastasis.h"
 #include <taler/taler_json_lib.h>
 #include <gnunet/gnunet_util_lib.h>
+#include <taler/taler_merchant_service.h>
 
 
 /**
@@ -1095,12 +1096,11 @@ truth_store_callback (void *cls,
       break;
     case ANASTASIS_US_PAYMENT_REQUIRED:
       {
-        /* FIXME: Payment required handling */
-        const char *m;
+        struct TALER_MERCHANT_PayUriData pd;
 
-        if (0 != strncmp (ud->details.payment_request,
-                          "taler://pay/http",
-                          strlen ("taler://pay/http")))
+        if (GNUNET_OK !=
+            TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
+                                          &pd))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                       "Did not find `%s' in `%s'\n",
@@ -1109,26 +1109,11 @@ truth_store_callback (void *cls,
           GNUNET_break (0);
           return;
         }
-        m = strstr (ud->details.payment_request, "/-/-/");
-        if (NULL == m)
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Did not find `%s' in `%s'\n",
-                      "/-/-/",
-                      ud->details.payment_request);
-          GNUNET_break (0);
-          /* NOTE: The above is a simplifying assumption for the
-             test-logic, hitting this code merely means that
-             the assumptions for the test (i.e. no instance) are
-             not satisfied, it is not inherently the case that
-             the above token must appear in the payment request!
-
-             So if you hit this, you might just want to modify
-             the code here to handle this better! */return;
-        }
-        tu->paid_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+        tu->paid_order_id = GNUNET_strdup (pd.order_id);
+        TALER_MERCHANT_parse_pay_uri_free (&pd);
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "Order ID from Anastasis service is `%s'\n",
+                    "At %s:%d Order ID from Anastasis service is %s\n",
+                    __FILE__, __LINE__,
                     tu->paid_order_id);
       }
       break;
@@ -1683,13 +1668,11 @@ policy_store_cb (void *cls,
       break;
     case ANASTASIS_US_PAYMENT_REQUIRED:
       {
-        /* FIXME: Payment required handling */
-
-        const char *m;
+        struct TALER_MERCHANT_PayUriData pd;
 
-        if (0 != strncmp (ud->details.payment_request,
-                          "taler://pay/http",
-                          strlen ("taler://pay/http")))
+        if (GNUNET_OK !=
+            TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
+                                          &pd))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                       "Did not find `%s' in `%s'\n",
@@ -1698,30 +1681,12 @@ policy_store_cb (void *cls,
           GNUNET_break (0);
           return;
         }
-        m = strstr (ud->details.payment_request, "/-/-/");
-        if (NULL == m)
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Did not find `%s' in `%s'\n",
-                      "/-/-/",
-                      ud->details.payment_request);
-          /* NOTE: The above is a simplifying assumption for the
-             test-logic, hitting this code merely means that
-             the assumptions for the test (i.e. no instance) are
-             not satisfied, it is not inherently the case that
-             the above token must appear in the payment request!
-
-             So if you hit this, you might just want to modify
-             the code here to handle this better! */
-          GNUNET_break (0);
-          return;
-        }
-        pss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+        pss->payment_order_id = GNUNET_strdup (pd.order_id);
+        TALER_MERCHANT_parse_pay_uri_free (&pd);
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "At %s:%d Order ID from Anastasis service is %s\n",
                     __FILE__, __LINE__,
                     pss->payment_order_id);
-
         memset (&pss->curr_hash,
                 0,
                 sizeof (struct GNUNET_HashCode));
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 23deab8..5e3efe9 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -25,6 +25,7 @@
 #include <jansson.h>
 #include <taler/taler_json_lib.h>
 #include <taler/taler_util.h>
+#include <taler/taler_merchant_service.h>
 #include "anastasis_redux.h"
 #include "anastasis_error_codes.h"
 #include "anastasis_api_redux.h"
@@ -1325,7 +1326,6 @@ secret_share_payment_cb (void *cls,
               __FILE__, __LINE__,
               taler_pay_url);
 
-  const char *m;
   size_t index;
   json_t *upload;
   struct SecretShareState *sss = cls;
@@ -1349,32 +1349,29 @@ secret_share_payment_cb (void *cls,
       GNUNET_assert (0 ==
                      json_object_set (upload,
                                       "pay_url",
-                                      json_string (strcat (taler_pay_url,
-                                                           "/"))));
+                                      json_string (taler_pay_url)));
       break;
     }
   }
 
-  m = strstr (taler_pay_url, "/-/-/");
-  if (NULL == m)
+  struct TALER_MERCHANT_PayUriData pd;
+
+  if (GNUNET_OK !=
+      TALER_MERCHANT_parse_pay_uri (taler_pay_url,
+                                    &pd))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Did not find `%s' in `%s'\n",
                 "/-/-/",
                 taler_pay_url);
     GNUNET_break (0);
-    /* NOTE: The above is a simplifying assumption for the
-        test-logic, hitting this code merely means that
-        the assumptions for the test (i.e. no instance) are
-        not satisfied, it is not inherently the case that
-        the above token must appear in the payment request!
-
-        So if you hit this, you might just want to modify
-        the code here to handle this better! */
     return;
   }
-  sss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
-
+  sss->payment_order_id = GNUNET_strdup (pd.order_id);
+  TALER_MERCHANT_parse_pay_uri_free (&pd);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Order ID from Anastasis service is `%s'\n",
+              sss->payment_order_id);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "At %s:%d Order ID from Anastasis service is %s\n",
               __FILE__, __LINE__,
diff --git a/src/lib/testing_api_cmd_policy_store.c 
b/src/lib/testing_api_cmd_policy_store.c
index 0b3216b..3934662 100644
--- a/src/lib/testing_api_cmd_policy_store.c
+++ b/src/lib/testing_api_cmd_policy_store.c
@@ -29,6 +29,8 @@
 #include "anastasis_testing_lib.h"
 #include <taler/taler_util.h>
 #include <taler/taler_testing_lib.h>
+#include <taler/taler_merchant_service.h>
+
 
 /**
  * State for a "policy store" CMD.
@@ -178,43 +180,21 @@ policy_store_cb (void *cls,
       break;
     case ANASTASIS_US_PAYMENT_REQUIRED:
       {
-        /* FIXME: Payment required handling */
-        const char *m;
+        struct TALER_MERCHANT_PayUriData pd;
 
-        if (0 != strncmp (ud->details.payment_request,
-                          "taler://pay/http",
-                          strlen ("taler://pay/http")))
+        if (GNUNET_OK !=
+            TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
+                                          &pd))
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Did not find `%s' in `%s'\n",
-                      "/-/-/",
-                      ud->details.payment_request);
-          TALER_TESTING_interpreter_fail (pss->is);
-          return;
-        }
-        m = strstr (ud->details.payment_request, "/-/-/");
-        if (NULL == m)
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Did not find `%s' in `%s'\n",
-                      "/-/-/",
-                      ud->details.payment_request);
+          GNUNET_break (0);
           TALER_TESTING_interpreter_fail (pss->is);
-          /* NOTE: The above is a simplifying assumption for the
-             test-logic, hitting this code merely means that
-             the assumptions for the test (i.e. no instance) are
-             not satisfied, it is not inherently the case that
-             the above token must appear in the payment request!
-
-             So if you hit this, you might just want to modify
-             the code here to handle this better! */
           return;
         }
-        pss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+        pss->payment_order_id = GNUNET_strdup (pd.order_id);
+        TALER_MERCHANT_parse_pay_uri_free (&pd);
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Order ID from Anastasis service is `%s'\n",
                     pss->payment_order_id);
-
         memset (&pss->curr_hash,
                 0,
                 sizeof (struct GNUNET_HashCode));
diff --git a/src/lib/testing_api_cmd_truth_store.c 
b/src/lib/testing_api_cmd_truth_store.c
index 1bba214..fb860dc 100644
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@ -23,6 +23,7 @@
 #include "anastasis_testing_lib.h"
 #include <taler/taler_util.h>
 #include <taler/taler_testing_lib.h>
+#include <taler/taler_merchant_service.h>
 
 /**
  * State for a "truth store" CMD.
@@ -132,40 +133,25 @@ truth_store_cb (void *cls,
       break;
     case ANASTASIS_US_PAYMENT_REQUIRED:
       {
-        /* FIXME: Payment required handling */
-        const char *m;
+        struct TALER_MERCHANT_PayUriData pd;
 
-        if (0 != strncmp (ud->details.payment_request,
-                          "taler://pay/http",
-                          strlen ("taler://pay/http")))
+        if (GNUNET_OK !=
+            TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
+                                          &pd))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                       "Did not find `%s' in `%s'\n",
                       "/-/-/",
                       ud->details.payment_request);
           TALER_TESTING_interpreter_fail (tss->is);
+          GNUNET_break (0);
           return;
         }
-        m = strstr (ud->details.payment_request, "/-/-/");
-        if (NULL == m)
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Did not find `%s' in `%s'\n",
-                      "/-/-/",
-                      ud->details.payment_request);
-          TALER_TESTING_interpreter_fail (tss->is);
-          /* NOTE: The above is a simplifying assumption for the
-             test-logic, hitting this code merely means that
-             the assumptions for the test (i.e. no instance) are
-             not satisfied, it is not inherently the case that
-             the above token must appear in the payment request!
-
-             So if you hit this, you might just want to modify
-             the code here to handle this better! */return;
-        }
-        tss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+        tss->payment_order_id = GNUNET_strdup (pd.order_id);
+        TALER_MERCHANT_parse_pay_uri_free (&pd);
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "Order ID from Anastasis service is `%s'\n",
+                    "At %s:%d Order ID from Anastasis service is %s\n",
+                    __FILE__, __LINE__,
                     tss->payment_order_id);
 
         memset (&tss->curr_hash,
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index 253efcd..5a6b6c5 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -25,6 +25,7 @@
 #include "anastasis_testing_lib.h"
 #include <taler/taler_util.h>
 #include <taler/taler_testing_lib.h>
+#include <taler/taler_merchant_service.h>
 
 
 /**
@@ -128,7 +129,6 @@ secret_share_payment_cb (void *cls,
                          const char *server_url,
                          enum TALER_ErrorCode ec)
 {
-  const char *m;
   struct SecretShareState *sss = cls;
   sss->sso = NULL;
 
@@ -152,39 +152,20 @@ secret_share_payment_cb (void *cls,
     return;
   }
 
-  if (0 != strncmp (taler_pay_url,
-                    "taler://pay/http",
-                    strlen ("taler://pay/http")))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Did not find `%s' in `%s'\n",
-                "/-/-/",
-                taler_pay_url);
-    TALER_TESTING_interpreter_fail (sss->is);
-    return;
-  }
-  m = strstr (taler_pay_url, "/-/-/");
-  if (NULL == m)
+  struct TALER_MERCHANT_PayUriData pd;
+
+  if (GNUNET_OK !=
+      TALER_MERCHANT_parse_pay_uri (taler_pay_url,
+                                    &pd))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Did not find `%s' in `%s'\n",
-                "/-/-/",
-                taler_pay_url);
+    GNUNET_break (0);
     TALER_TESTING_interpreter_fail (sss->is);
-    /* NOTE: The above is a simplifying assumption for the
-        test-logic, hitting this code merely means that
-        the assumptions for the test (i.e. no instance) are
-        not satisfied, it is not inherently the case that
-        the above token must appear in the payment request!
-
-        So if you hit this, you might just want to modify
-        the code here to handle this better! */
     return;
   }
-  sss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+  sss->payment_order_id = GNUNET_strdup (pd.order_id);
+  TALER_MERCHANT_parse_pay_uri_free (&pd);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "At %s:%d Order ID from Anastasis service is %s\n",
-              __FILE__, __LINE__,
+              "Order ID from Anastasis service is `%s'\n",
               sss->payment_order_id);
 
   TALER_TESTING_interpreter_next (sss->is);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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