gnunet-svn
[Top][All Lists]
Advanced

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

[taler-sync] branch master updated (778c222 -> 4df7d81)


From: gnunet
Subject: [taler-sync] branch master updated (778c222 -> 4df7d81)
Date: Sat, 30 Nov 2019 00:11:12 +0100

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

grothoff pushed a change to branch master
in repository sync.

    from 778c222  fix issues
     new 03d8657  propper handling of URIs
     new 70bd8df  DCE
     new 4df7d81  dce

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/lib/sync_api_upload.c               | 10 +++++
 src/lib/test_sync_api.c                 | 68 +++++++--------------------------
 src/lib/test_sync_api.conf              |  6 +++
 src/lib/testing_api_cmd_backup_upload.c | 37 +++++++++++++++++-
 src/sync/sync-httpd_backup_post.c       |  6 +--
 5 files changed, 67 insertions(+), 60 deletions(-)

diff --git a/src/lib/sync_api_upload.c b/src/lib/sync_api_upload.c
index 33ff381..31a7d08 100644
--- a/src/lib/sync_api_upload.c
+++ b/src/lib/sync_api_upload.c
@@ -219,8 +219,18 @@ handle_header (char *buffer,
   if (0 == strcasecmp (hdr_type,
                        "Taler"))
   {
+    size_t len;
+
     /* found payment URI we care about! */
     uo->pay_uri = GNUNET_strdup (hdr_val);
+    len = strlen (uo->pay_uri);
+    while ( (len > 0) &&
+            ( ('\n' == uo->pay_uri[len - 1]) ||
+              ('\r' == uo->pay_uri[len - 1]) ) )
+    {
+      len--;
+      uo->pay_uri[len] = '\0';
+    }
   }
   GNUNET_free (ndup);
   return total;
diff --git a/src/lib/test_sync_api.c b/src/lib/test_sync_api.c
index 6f6ac77..cae8068 100644
--- a/src/lib/test_sync_api.c
+++ b/src/lib/test_sync_api.c
@@ -47,8 +47,6 @@
  */
 #define EXCHANGE_URL "http://localhost:8081/";
 
-static const char *pickup_amounts_1[] = {"EUR:5", NULL};
-
 /**
  * URL of the fakebank.
  */
@@ -156,59 +154,6 @@ static char *auditor_url;
     subject)
 
 
-static struct GNUNET_CONTAINER_MultiHashMap *interned_strings;
-
-static const char *
-intern (const char *str)
-{
-  struct GNUNET_HashCode hash;
-  const char *hs;
-
-  if (NULL == interned_strings)
-    interned_strings = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO);
-  GNUNET_assert (NULL != interned_strings);
-  GNUNET_CRYPTO_hash (str, strlen (str), &hash);
-  hs = GNUNET_CONTAINER_multihashmap_get (interned_strings, &hash);
-  if (NULL != hs)
-    return hs;
-  hs = GNUNET_strdup (str);
-  GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (
-                   interned_strings,
-                   &hash,
-                   (void *) hs,
-                   GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-  return hs;
-}
-
-
-#define BUF_SZ 512
-
-static const char *
-merchant_url_internal (const char *instance_id)
-{
-  char buf[BUF_SZ];
-  if (NULL == instance_id)
-    GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%s", merchant_url));
-  else
-    GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%sinstances/%s/", merchant_url,
-                                 instance_id));
-  return intern (buf);
-}
-
-
-static const char *
-merchant_url_external (const char *instance_id)
-{
-  char buf[BUF_SZ];
-  if (NULL == instance_id)
-    GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%spublic/", merchant_url));
-  else
-    GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%spublic/instances/%s/",
-                                 merchant_url, instance_id));
-  return intern (buf);
-}
-
-
 /**
  * Main function that will tell the interpreter what commands to
  * run.
@@ -249,6 +194,19 @@ run (void *cls,
                                     MHD_HTTP_PAYMENT_REQUIRED,
                                     "Test-1",
                                     strlen ("Test-1")),
+    TALER_TESTING_cmd_proposal_lookup ("fetch-proposal",
+                                       merchant_url,
+                                       MHD_HTTP_OK,
+                                       "backup-upload-1",
+                                       NULL),
+    TALER_TESTING_cmd_pay ("pay-account",
+                           merchant_url,
+                           MHD_HTTP_OK,
+                           "fetch-proposal",
+                           "withdraw-coin-1",
+                           "EUR:5",
+                           "EUR:4.99", /* must match ANNUAL_FEE in config! */
+                           "EUR:0.01"),
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/lib/test_sync_api.conf b/src/lib/test_sync_api.conf
index c767b72..eb9d7ca 100644
--- a/src/lib/test_sync_api.conf
+++ b/src/lib/test_sync_api.conf
@@ -18,6 +18,12 @@ PORT = 8084
 # Where does our payment backend run?  Must match PORT under [merchant]
 PAYMENT_BACKEND_URL = http://localhost:8080/
 
+# Annual fee we charge.
+ANNUAL_FEE = EUR:4.99
+
+# Upload limit
+UPLOAD_LIMIT_MB = 1
+
 [syncdb-postgres]
 CONFIG = postgres:///synccheck
 
diff --git a/src/lib/testing_api_cmd_backup_upload.c 
b/src/lib/testing_api_cmd_backup_upload.c
index 02d66fb..6ed228a 100644
--- a/src/lib/testing_api_cmd_backup_upload.c
+++ b/src/lib/testing_api_cmd_backup_upload.c
@@ -151,7 +151,42 @@ backup_upload_cb (void *cls,
       }
       break;
     case SYNC_US_PAYMENT_REQUIRED:
-      bus->payment_order_id = GNUNET_strdup (ud->details.payment_request);
+      {
+        const char *m;
+
+        if (0 != strncmp (ud->details.payment_request,
+                          "taler://pay/http",
+                          strlen ("taler://pay/http")))
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Did not find `%s' in `%s'\n",
+                      "/-/-/",
+                      ud->details.payment_request);
+          TALER_TESTING_interpreter_fail (bus->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);
+          TALER_TESTING_interpreter_fail (bus->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;
+        }
+        bus->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                    "Order ID from Sync service is `%s'\n",
+                    bus->payment_order_id);
+      }
       break;
     case SYNC_US_CONFLICTING_BACKUP:
       {
diff --git a/src/sync/sync-httpd_backup_post.c 
b/src/sync/sync-httpd_backup_post.c
index 8137910..6562b0e 100644
--- a/src/sync/sync-httpd_backup_post.c
+++ b/src/sync/sync-httpd_backup_post.c
@@ -290,12 +290,11 @@ proposal_cb (void *cls,
                                          "backend-http-status",
                                          (json_int_t) http_status);
     GNUNET_assert (NULL != bc->resp);
-    fprintf (stderr, "SET: %p - %p\n", bc, (NULL != bc) ? bc->resp : NULL);
     bc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Storing payment request for order %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Storing payment request for order `%s'\n",
               order_id);
   qs = db->store_payment_TR (db->cls,
                              &bc->account,
@@ -609,7 +608,6 @@ sync_handler_backup_post (struct MHD_Connection *connection,
   struct BackupContext *bc;
 
   bc = *con_cls;
-  fprintf (stderr, "%p - %p\n", bc, (NULL != bc) ? bc->resp : NULL);
   if (NULL == bc)
   {
     /* first call, setup internals */

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



reply via email to

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