gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 01/02: allow permutations in order of reserves returned


From: gnunet
Subject: [taler-merchant] 01/02: allow permutations in order of reserves returned to still count as acceptable
Date: Fri, 29 Jan 2021 18:12:38 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

commit 38b8097d94f794287c0dea3fbbe1f80cac46a69f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Jan 29 18:11:58 2021 +0100

    allow permutations in order of reserves returned to still count as 
acceptable
---
 src/testing/testing_api_cmd_get_reserves.c | 111 +++++++++++++++++------------
 1 file changed, 66 insertions(+), 45 deletions(-)

diff --git a/src/testing/testing_api_cmd_get_reserves.c 
b/src/testing/testing_api_cmd_get_reserves.c
index 22e0e1cd..f673d70b 100644
--- a/src/testing/testing_api_cmd_get_reserves.c
+++ b/src/testing/testing_api_cmd_get_reserves.c
@@ -74,6 +74,8 @@ get_reserves_cb (void *cls,
 {
   /* FIXME, deeper checks should be implemented here. */
   struct GetReservesState *grs = cls;
+  bool matched[reserves_length];
+  bool fail = false;
 
   grs->rgh = NULL;
   if (grs->http_status != hr->http_status)
@@ -97,60 +99,79 @@ get_reserves_cb (void *cls,
       return;
     }
     // FIXME: check if the data returned matches that from the POST / PATCH
+    memset (matched, 0, sizeof (matched));
     for (unsigned int i = 0; i < reserves_length; ++i)
-    {
-      const struct TALER_TESTING_Command *reserve_cmd;
-
-      reserve_cmd = TALER_TESTING_interpreter_lookup_command (
-        grs->is,
-        grs->reserves[i]);
+      for (unsigned int j = 0; j < reserves_length; ++j)
       {
-        const struct TALER_ReservePublicKeyP *reserve_pub;
+        const struct TALER_TESTING_Command *reserve_cmd;
+        bool match = true;
 
-        if (GNUNET_OK !=
-            TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
-                                                 0,
-                                                 &reserve_pub))
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Could not fetch reserve public key\n");
-          TALER_TESTING_interpreter_fail (grs->is);
-          return;
-        }
-        if (0 != GNUNET_memcmp (&reserves[i].reserve_pub,
-                                reserve_pub))
+        reserve_cmd = TALER_TESTING_interpreter_lookup_command (
+          grs->is,
+          grs->reserves[j]);
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Reserve public key does not match\n");
-          TALER_TESTING_interpreter_fail (grs->is);
-          return;
-        }
-      }
-      {
-        const struct TALER_Amount *initial;
+          const struct TALER_ReservePublicKeyP *reserve_pub;
 
-        if (GNUNET_OK !=
-            TALER_TESTING_get_trait_amount_obj (reserve_cmd,
-                                                0,
-                                                &initial))
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Could not fetch reserve initial balance\n");
-          TALER_TESTING_interpreter_fail (grs->is);
-          return;
+          if (GNUNET_OK !=
+              TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
+                                                   0,
+                                                   &reserve_pub))
+          {
+            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                        "Could not fetch reserve public key\n");
+            TALER_TESTING_interpreter_fail (grs->is);
+            return;
+          }
+          if (0 != GNUNET_memcmp (&reserves[i].reserve_pub,
+                                  reserve_pub))
+          {
+            GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                        "Reserve public key does not match, got %s\n",
+                        TALER_B2S (&reserves[i].reserve_pub));
+            GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                        "Reserve public key does not match, expected %s\n",
+                        TALER_B2S (reserve_pub));
+            match = false;
+          }
         }
-        if ((GNUNET_OK != TALER_amount_cmp_currency (
-               &reserves[i].merchant_initial_amount,
-               initial)) ||
-            (0 != TALER_amount_cmp (&reserves[i].merchant_initial_amount,
-                                    initial)))
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Reserve initial amount does not match\n");
-          TALER_TESTING_interpreter_fail (grs->is);
-          return;
+          const struct TALER_Amount *initial;
+
+          if (GNUNET_OK !=
+              TALER_TESTING_get_trait_amount_obj (reserve_cmd,
+                                                  0,
+                                                  &initial))
+          {
+            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                        "Could not fetch reserve initial balance\n");
+            TALER_TESTING_interpreter_fail (grs->is);
+            return;
+          }
+          if ((GNUNET_OK !=
+               TALER_amount_cmp_currency (&reserves[i].merchant_initial_amount,
+                                          initial)) ||
+              (0 != TALER_amount_cmp (&reserves[i].merchant_initial_amount,
+                                      initial)))
+          {
+            GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                        "Reserve initial amount does not match, got %s\n",
+                        TALER_amount2s (&reserves[i].merchant_initial_amount));
+            GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                        "Reserve initial amount does not match, wanted %s\n",
+                        TALER_amount2s (initial));
+            match = false;
+          }
         }
+        if (match)
+          matched[i] = true;
       }
+    for (unsigned int i = 0; i < reserves_length; ++i)
+      if (! matched[i])
+        fail = true;
+    if (fail)
+    {
+      TALER_TESTING_interpreter_fail (grs->is);
+      return;
     }
     break;
   default:

-- 
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]