gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -implement first draft of testin


From: gnunet
Subject: [taler-exchange] branch master updated: -implement first draft of testing_api_cmd_reserve_get_attestable.c
Date: Sat, 01 Oct 2022 16:25:09 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 538ab875 -implement first draft of 
testing_api_cmd_reserve_get_attestable.c
538ab875 is described below

commit 538ab8753c28c4767eacb49e04343411ed83932d
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Oct 1 16:25:06 2022 +0200

    -implement first draft of testing_api_cmd_reserve_get_attestable.c
---
 contrib/gana                                       |  2 +-
 src/testing/Makefile.am                            |  1 +
 .../testing_api_cmd_reserve_get_attestable.c       | 81 +++++++++++++++-------
 3 files changed, 58 insertions(+), 26 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 9dee7d6e..d402af78 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 9dee7d6e8f967fdc58ae224e19ec03989ac35c52
+Subproject commit d402af78f6d360841db53baa46dddae13590ec33
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 78d4cdce..82c786c3 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -86,6 +86,7 @@ libtalertesting_la_SOURCES = \
   testing_api_cmd_refund.c \
   testing_api_cmd_refresh.c \
   testing_api_cmd_reserve_get.c \
+  testing_api_cmd_reserve_get_attestable.c \
   testing_api_cmd_reserve_history.c \
   testing_api_cmd_reserve_open.c \
   testing_api_cmd_reserve_purse.c \
diff --git a/src/testing/testing_api_cmd_reserve_get_attestable.c 
b/src/testing/testing_api_cmd_reserve_get_attestable.c
index c0cae832..29c8f6a3 100644
--- a/src/testing/testing_api_cmd_reserve_get_attestable.c
+++ b/src/testing/testing_api_cmd_reserve_get_attestable.c
@@ -41,17 +41,17 @@ struct GetAttestableState
   /**
    * Handle to the "reserve get_attestable" operation.
    */
-  struct TALER_EXCHANGE_ReservesGetAttestableHandle *rsh;
+  struct TALER_EXCHANGE_ReservesGetAttestHandle *rgah;
 
   /**
-   * Expected reserve balance.
+   * Expected attestable attributes.
    */
-  const char *expected_balance;
+  const char **expected_attestables;
 
   /**
-   * Private key of the reserve being analyzed.
+   * Length of the @e expected_attestables array.
    */
-  const struct TALER_ReservePrivateKeyP *reserve_priv;
+  unsigned int expected_attestables_length;
 
   /**
    * Public key of the reserve being analyzed.
@@ -78,14 +78,14 @@ struct GetAttestableState
  * @param rs HTTP response details
  */
 static void
-reserve_get_attestable_cb (void *cls,
-                           const struct TALER_EXCHANGE_ReserveGetAttestable 
*rs)
+reserve_get_attestable_cb (
+  void *cls,
+  const struct TALER_EXCHANGE_ReserveGetAttestResult *rs)
 {
   struct GetAttestableState *ss = cls;
   struct TALER_TESTING_Interpreter *is = ss->is;
-  struct TALER_Amount eb;
 
-  ss->rsh = NULL;
+  ss->rgah = NULL;
   if (ss->expected_response_code != rs->hr.http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -104,6 +104,7 @@ reserve_get_attestable_cb (void *cls,
     TALER_TESTING_interpreter_next (is);
     return;
   }
+  // FIXME: check returned list matches expectations!
   TALER_TESTING_interpreter_next (is);
 }
 
@@ -122,6 +123,8 @@ get_attestable_run (void *cls,
 {
   struct GetAttestableState *ss = cls;
   const struct TALER_TESTING_Command *create_reserve;
+  const struct TALER_ReservePrivateKeyP *reserve_priv;
+  const struct TALER_ReservePublicKeyP *reserve_pub;
 
   ss->is = is;
   create_reserve
@@ -134,21 +137,31 @@ get_attestable_run (void *cls,
     TALER_TESTING_interpreter_fail (is);
     return;
   }
-  if (GNUNET_OK !=
+  if (GNUNET_OK ==
       TALER_TESTING_get_trait_reserve_priv (create_reserve,
-                                            &ss->reserve_priv))
+                                            &reserve_priv))
   {
-    GNUNET_break (0);
-    TALER_LOG_ERROR ("Failed to find reserve_priv for get_attestable query\n");
-    TALER_TESTING_interpreter_fail (is);
-    return;
+    GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
+                                        &ss->reserve_pub.eddsa_pub);
   }
-  GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
-                                      &ss->reserve_pub.eddsa_pub);
-  ss->rsh = TALER_EXCHANGE_reserves_get_attestable (is->exchange,
-                                                    ss->reserve_priv,
-                                                    &reserve_get_attestable_cb,
-                                                    ss);
+  else
+  {
+    if (GNUNET_OK !=
+        TALER_TESTING_get_trait_reserve_pub (create_reserve,
+                                             &reserve_pub))
+    {
+      GNUNET_break (0);
+      TALER_LOG_ERROR (
+        "Failed to find reserve_priv for get_attestable query\n");
+      TALER_TESTING_interpreter_fail (is);
+      return;
+    }
+    ss->reserve_pub = *reserve_pub;
+  }
+  ss->rgah = TALER_EXCHANGE_reserves_get_attestable (is->exchange,
+                                                     &ss->reserve_pub,
+                                                     
&reserve_get_attestable_cb,
+                                                     ss);
 }
 
 
@@ -165,15 +178,16 @@ get_attestable_cleanup (void *cls,
 {
   struct GetAttestableState *ss = cls;
 
-  if (NULL != ss->rsh)
+  if (NULL != ss->rgah)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Command %u (%s) did not complete\n",
                 ss->is->ip,
                 cmd->label);
-    TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rsh);
-    ss->rsh = NULL;
+    TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rgah);
+    ss->rgah = NULL;
   }
+  GNUNET_free (ss->expected_attestables);
   GNUNET_free (ss);
 }
 
@@ -185,12 +199,29 @@ TALER_TESTING_cmd_reserve_get_attestable (const char 
*label,
                                           ...)
 {
   struct GetAttestableState *ss;
+  va_list ap;
+  unsigned int num_expected;
+  const char *ea;
+
+  num_expected = 0;
+  va_start (ap, expected_response_code);
+  while (NULL != va_arg (ap, const char *))
+    num_expected++;
+  va_end (ap);
 
   GNUNET_assert (NULL != reserve_reference);
   ss = GNUNET_new (struct GetAttestableState);
   ss->reserve_reference = reserve_reference;
-  ss->expected_balance = expected_balance;
   ss->expected_response_code = expected_response_code;
+  ss->expected_attestables_length = num_expected;
+  ss->expected_attestables = GNUNET_new_array (num_expected,
+                                               const char *);
+  num_expected = 0;
+  va_start (ap, expected_response_code);
+  while (NULL != (ea = va_arg (ap, const char *)))
+    ss->expected_attestables[num_expected++] = ea;
+  va_end (ap);
+
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ss,

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