gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (58a5c085 -> 3f901571)


From: gnunet
Subject: [taler-exchange] branch master updated (58a5c085 -> 3f901571)
Date: Wed, 28 Sep 2022 12:19:19 +0200

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

grothoff pushed a change to branch master
in repository exchange.

    from 58a5c085 exclude mustach from indentation requirements
     new 58e7e986 -first sketch for reserve_open testing CMD
     new 3f901571 implemented reserve_open testing CMD

The 2 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:
 contrib/uncrustify.sh                      |   2 +-
 src/testing/Makefile.am                    |   1 +
 src/testing/testing_api_cmd_reserve_open.c | 154 +++++++++++++++++++++++++++--
 3 files changed, 149 insertions(+), 8 deletions(-)

diff --git a/contrib/uncrustify.sh b/contrib/uncrustify.sh
index e8e05d3e..09abaf54 100755
--- a/contrib/uncrustify.sh
+++ b/contrib/uncrustify.sh
@@ -9,6 +9,6 @@ if ! uncrustify --version >/dev/null; then
   exit 1
 fi
 
-find "$DIR/../src" \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) \
+find "$DIR/../src" \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) | grep -v 
mustach \
   -exec uncrustify -c "$DIR/uncrustify.cfg" --replace --no-backup {} + \
   || true
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 74facda0..78d4cdce 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -87,6 +87,7 @@ libtalertesting_la_SOURCES = \
   testing_api_cmd_refresh.c \
   testing_api_cmd_reserve_get.c \
   testing_api_cmd_reserve_history.c \
+  testing_api_cmd_reserve_open.c \
   testing_api_cmd_reserve_purse.c \
   testing_api_cmd_reserve_status.c \
   testing_api_cmd_revoke.c \
diff --git a/src/testing/testing_api_cmd_reserve_open.c 
b/src/testing/testing_api_cmd_reserve_open.c
index 366d6b92..67209d02 100644
--- a/src/testing/testing_api_cmd_reserve_open.c
+++ b/src/testing/testing_api_cmd_reserve_open.c
@@ -27,6 +27,24 @@
 #include "taler_testing_lib.h"
 
 
+/**
+ * Information we track per coin used to pay for opening the
+ * reserve.
+ */
+struct CoinDetail
+{
+  /**
+   * Name of the command and index of the coin to use.
+   */
+  const char *name;
+
+  /**
+   * Amount to charge to this coin.
+   */
+  struct TALER_Amount amount;
+};
+
+
 /**
  * State for a "open" CMD.
  */
@@ -38,6 +56,21 @@ struct OpenState
    */
   const char *reserve_reference;
 
+  /**
+   * Requested expiration time.
+   */
+  struct GNUNET_TIME_Relative req_expiration_time;
+
+  /**
+   * Requested minimum number of purses.
+   */
+  uint32_t min_purses;
+
+  /**
+   * Amount to pay for the opening from the reserve balance.
+   */
+  struct TALER_Amount reserve_pay;
+
   /**
    * Handle to the "reserve open" operation.
    */
@@ -48,6 +81,16 @@ struct OpenState
    */
   const char *expected_balance;
 
+  /**
+   * Length of the @e cd array.
+   */
+  unsigned int cpl;
+
+  /**
+   * Coin details, array of length @e cpl.
+   */
+  struct CoinDetail *cd;
+
   /**
    * Private key of the reserve being analyzed.
    */
@@ -79,11 +122,10 @@ struct OpenState
  */
 static void
 reserve_open_cb (void *cls,
-                 const struct TALER_EXCHANGE_ReserveOpen *rs)
+                 const struct TALER_EXCHANGE_ReserveOpenResult *rs)
 {
   struct OpenState *ss = cls;
   struct TALER_TESTING_Interpreter *is = ss->is;
-  struct TALER_Amount eb;
 
   ss->rsh = NULL;
   if (ss->expected_response_code != rs->hr.http_status)
@@ -122,6 +164,7 @@ open_run (void *cls,
 {
   struct OpenState *ss = cls;
   const struct TALER_TESTING_Command *create_reserve;
+  struct TALER_EXCHANGE_PurseDeposit cp[GNUNET_NZL (ss->cpl)];
 
   ss->is = is;
   create_reserve
@@ -145,10 +188,79 @@ open_run (void *cls,
   }
   GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
                                       &ss->reserve_pub.eddsa_pub);
-  ss->rsh = TALER_EXCHANGE_reserves_open (is->exchange,
-                                          ss->reserve_priv,
-                                          &reserve_open_cb,
-                                          ss);
+  for (unsigned int i = 0; i<ss->cpl; i++)
+  {
+    struct TALER_EXCHANGE_PurseDeposit *cpi = &cp[i];
+    const struct TALER_TESTING_Command *cmdi;
+    const struct TALER_AgeCommitmentProof *age_commitment_proof;
+    const struct TALER_CoinSpendPrivateKeyP *coin_priv;
+    const struct TALER_DenominationSignature *denom_sig;
+    const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
+    char *cref;
+    unsigned int cidx;
+
+    if (GNUNET_OK !=
+        TALER_TESTING_parse_coin_reference (ss->cd[i].name,
+                                            &cref,
+                                            &cidx))
+    {
+      GNUNET_break (0);
+      TALER_LOG_ERROR ("Failed to parse coin reference `%s'\n",
+                       ss->cd[i].name);
+      TALER_TESTING_interpreter_fail (is);
+      return;
+    }
+    cmdi = TALER_TESTING_interpreter_lookup_command (is,
+                                                     cref);
+    GNUNET_free (cref);
+    if (NULL == cmdi)
+    {
+      GNUNET_break (0);
+      TALER_LOG_ERROR ("Command `%s' not found\n",
+                       ss->cd[i].name);
+      TALER_TESTING_interpreter_fail (is);
+      return;
+    }
+    if ( (GNUNET_OK !=
+          TALER_TESTING_get_trait_age_commitment_proof (cmdi,
+                                                        cidx,
+                                                        &age_commitment_proof))
+         ||
+         (GNUNET_OK !=
+          TALER_TESTING_get_trait_coin_priv (cmdi,
+                                             cidx,
+                                             &coin_priv)) ||
+         (GNUNET_OK !=
+          TALER_TESTING_get_trait_denom_sig (cmdi,
+                                             cidx,
+                                             &denom_sig)) ||
+         (GNUNET_OK !=
+          TALER_TESTING_get_trait_denom_pub (cmdi,
+                                             cidx,
+                                             &denom_pub)) )
+    {
+      GNUNET_break (0);
+      TALER_LOG_ERROR ("Coin trait not found in `%s'\n",
+                       ss->cd[i].name);
+      TALER_TESTING_interpreter_fail (is);
+      return;
+    }
+    cpi->age_commitment_proof = age_commitment_proof;
+    cpi->coin_priv = *coin_priv;
+    cpi->denom_sig = *denom_sig;
+    cpi->amount = ss->cd[i].amount;
+    cpi->h_denom_pub = denom_pub->h_key;
+  }
+  ss->rsh = TALER_EXCHANGE_reserves_open (
+    is->exchange,
+    ss->reserve_priv,
+    &ss->reserve_pay,
+    ss->cpl,
+    cp,
+    GNUNET_TIME_relative_to_timestamp (ss->req_expiration_time),
+    ss->min_purses,
+    &reserve_open_cb,
+    ss);
 }
 
 
@@ -188,12 +300,40 @@ TALER_TESTING_cmd_reserve_open (const char *label,
                                 ...)
 {
   struct OpenState *ss;
+  va_list ap;
+  const char *name;
+  unsigned int i;
 
   GNUNET_assert (NULL != reserve_reference);
   ss = GNUNET_new (struct OpenState);
   ss->reserve_reference = reserve_reference;
-  ss->expected_balance = expected_balance;
+  ss->req_expiration_time = expiration_time;
+  ss->min_purses = min_purses;
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_string_to_amount (reserve_pay,
+                                         &ss->reserve_pay));
   ss->expected_response_code = expected_response_code;
+  va_start (ap,
+            expected_response_code);
+  while (NULL != (name = va_arg (ap, const char *)))
+    ss->cpl++;
+  va_end (ap);
+  GNUNET_assert (0 == (ss->cpl % 2));
+  ss->cd = GNUNET_new_array (ss->cpl,
+                             struct CoinDetail);
+  i = 0;
+  va_start (ap,
+            expected_response_code);
+  while (NULL != (name = va_arg (ap, const char *)))
+  {
+    ss->cd[i].name = name;
+    GNUNET_assert (GNUNET_OK ==
+                   TALER_string_to_amount (va_arg (ap,
+                                                   const char *),
+                                           &ss->cd[i].amount));
+    i++;
+  }
+  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]