gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (faee881 -> 2e062ed)


From: gnunet
Subject: [taler-merchant] branch master updated (faee881 -> 2e062ed)
Date: Tue, 24 Dec 2019 23:36:03 +0100

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

grothoff pushed a change to branch master
in repository merchant.

    from faee881  partially adjusting date format for tests.
     new e5f305c  fix release date
     new 21cad09  fix time parser, why was this ever written
     new 2e062ed  fix a few more Date() problems

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:
 ChangeLog                           |  2 +-
 src/lib/test_merchant_api.c         | 20 ++++++------
 src/lib/test_merchant_api_twisted.c | 40 +++++++++++------------
 src/lib/testing_api_cmd_history.c   | 65 ++++++-------------------------------
 4 files changed, 41 insertions(+), 86 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8425aa0..e74413a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-Fri 20 Dec 2019 08:36:03 PM CET
+Tue 24 Dec 2019 11:01:21 PM CET
        Releasing taler-merchant 0.6.0. -CG
 
 Sat 17 Aug 2019 10:03:38 PM CEST
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index ec94287..10471ce 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -527,8 +527,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"1-unpaid\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":5,\
@@ -591,8 +591,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"unincreased-proposal\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":5,\
@@ -801,8 +801,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"1-tip\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":5,\
@@ -876,8 +876,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"10\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":10,\
@@ -955,8 +955,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"11\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":10,\
diff --git a/src/lib/test_merchant_api_twisted.c 
b/src/lib/test_merchant_api_twisted.c
index 25bd570..462c33d 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -241,8 +241,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"5719TRIGGER\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
@@ -286,8 +286,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"fail-check-payment-1\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
@@ -387,8 +387,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"1\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":5,\
@@ -413,8 +413,8 @@ run (void *cls,
            \"fraction\":50000000},\
          \"fulfillment_url\": \"https://example.com/\",\
          \"order_id\":\"2\",\
-         \"refund_deadline\":\"\\/Date(0)\\/\",\
-         \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+         \"refund_deadline\":{\"t_ms\":0},\
+         \"pay_deadline\":{\"t_ms\":99999999999},\
          \"amount\":\
            {\"currency\":\"EUR\",\
             \"value\":5,\
@@ -469,8 +469,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"5\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":5,\
@@ -639,8 +639,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"5383\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
@@ -729,8 +729,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"11\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
@@ -842,8 +842,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"abort-one\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
@@ -928,8 +928,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"DS-1\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
@@ -947,8 +947,8 @@ run (void *cls,
            \"value\":0,\
            \"fraction\":50000000},\
         \"order_id\":\"DS-2\",\
-        \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+        \"refund_deadline\":{\"t_ms\":0},\
+        \"pay_deadline\":{\"t_ms\":99999999999},\
         \"fulfillment_url\": \"https://example.com/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
diff --git a/src/lib/testing_api_cmd_history.c 
b/src/lib/testing_api_cmd_history.c
index 5a776fc..2f4702a 100644
--- a/src/lib/testing_api_cmd_history.c
+++ b/src/lib/testing_api_cmd_history.c
@@ -86,56 +86,6 @@ struct HistoryState
   unsigned int nresult;
 };
 
-/**
- * Parse given JSON object to absolute time.
- *
- * @param root the json object representing data
- * @param[out] ret where to write the data
- * @return #GNUNET_OK upon successful parsing;
- *         #GNUNET_SYSERR upon error
- */
-static int
-parse_abs_time (json_t *root,
-                struct GNUNET_TIME_Absolute *ret)
-{
-  const char *val;
-  unsigned long long int tval;
-
-  val = json_string_value (root);
-  if (NULL == val)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  if ( (0 == strcasecmp (val,
-                         "/forever/")) ||
-       (0 == strcasecmp (val,
-                         "/end of time/")) ||
-       (0 == strcasecmp (val,
-                         "/never/")) )
-  {
-    *ret = GNUNET_TIME_UNIT_FOREVER_ABS;
-    return GNUNET_OK;
-  }
-  if (1 != sscanf (val,
-                   "/Date(%llu)/",
-                   &tval))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  /* Time is in seconds in JSON, but in microseconds in
-   * GNUNET_TIME_Absolute */
-  ret->abs_value_us = tval * 1000LL * 1000LL;
-  if ( (ret->abs_value_us) / 1000LL / 1000LL != tval)
-  {
-    /* Integer overflow */
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  return GNUNET_OK;
-}
-
 
 /**
  * Callback for a /history request; checks that (1) HTTP status
@@ -193,12 +143,17 @@ history_cb (void *cls,
     size_t index;
     json_array_foreach (arr, index, entry)
     {
-      json_t *timestamp;
-
-      timestamp = json_object_get (entry, "timestamp");
-      if (GNUNET_OK != parse_abs_time (timestamp, &entry_timestamp))
+      struct GNUNET_JSON_Specification spec[] = {
+        GNUNET_JSON_spec_absolute_time ("timestamp",
+                                        &entry_timestamp),
+        GNUNET_JSON_spec_end ()
+      };
+
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (entry,
+                             spec,
+                             NULL, NULL))
         TALER_TESTING_FAIL (hs->is);
-
       if (last_timestamp.abs_value_us < entry_timestamp.abs_value_us)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,

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



reply via email to

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