gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (132359a4 -> cf358f95)


From: gnunet
Subject: [taler-exchange] branch master updated (132359a4 -> cf358f95)
Date: Sat, 23 Apr 2022 18:13:25 +0200

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

grothoff pushed a change to branch master
in repository exchange.

    from 132359a4 add purses-get to build
     new cf11b3f0 -create cmd for purse creation from reserve
     new e7317393 -create cmd for purse deposit
     new cf358f95 -uncrustify

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/include/taler_exchange_service.h               |   4 -
 src/include/taler_signatures.h                     |   2 +-
 src/include/taler_testing_lib.h                    |   4 -
 src/lib/exchange_api_purse_create_with_merge.c     |  15 +-
 src/testing/Makefile.am                            |   4 +-
 ...e_deposit.c => testing_api_cmd_purse_deposit.c} | 151 ++++------------
 ...tract_get.c => testing_api_cmd_reserve_purse.c} | 199 +++++++++++----------
 src/util/exchange_signatures.c                     |   1 +
 8 files changed, 148 insertions(+), 232 deletions(-)
 copy src/testing/{testing_api_cmd_purse_create_deposit.c => 
testing_api_cmd_purse_deposit.c} (65%)
 copy src/testing/{testing_api_cmd_contract_get.c => 
testing_api_cmd_reserve_purse.c} (51%)

diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 18bde0fe..6bb29807 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -4437,9 +4437,7 @@ struct TALER_EXCHANGE_PurseCreateMergeHandle;
  * @param contract_priv private key to get the contract
  * @param contract_terms contract the purse is about
  * @param upload_contract true to upload the contract
- * @param purse_expiration when will the unmerged purse expire
  * @paran merge_timestamp when should the merge happen (use current time)
- * @param purse_value_after_fees target amount in the purse
  * @param cb function to call with the exchange's result
  * @param cb_cls closure for @a cb
  * @return the request handle; NULL upon error
@@ -4453,9 +4451,7 @@ TALER_EXCHANGE_purse_create_with_merge (
   const struct TALER_ContractDiffiePrivateP *contract_priv,
   const json_t *contract_terms,
   bool upload_contract,
-  struct GNUNET_TIME_Timestamp purse_expiration,
   struct GNUNET_TIME_Timestamp merge_timestamp,
-  const struct TALER_Amount *purse_value_after_fees,
   TALER_EXCHANGE_PurseCreateMergeCallback cb,
   void *cb_cls);
 
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 81e74268..5eb680cd 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -386,6 +386,6 @@
 GNUNET_NETWORK_STRUCT_BEGIN
 
 
-GNUNET_NETWORK_STRUCT_END
+  GNUNET_NETWORK_STRUCT_END
 
 #endif
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 7c407152..30d0f098 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -2441,10 +2441,8 @@ TALER_TESTING_cmd_purse_get (
  *
  * @param label command label
  * @param expected_http_status what HTTP status do we expect to get returned 
from the exchange
- * @param target_amount amount for the purse to be full, without fees
  * @param contract_terms contract, JSON string
  * @param upload_contract should we upload the contract
- * @param purse_expiration how long until the purse expires
  * @param reserve_ref reference to reserve key, or NULL to create a new reserve
  * @return the command
  */
@@ -2452,10 +2450,8 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_purse_create_with_reserve (
   const char *label,
   unsigned int expected_http_status,
-  const char *target_amount,
   const char *contract_terms,
   bool upload_contract,
-  struct GNUNET_TIME_Relative purse_expiration,
   const char *reserve_ref);
 
 
diff --git a/src/lib/exchange_api_purse_create_with_merge.c 
b/src/lib/exchange_api_purse_create_with_merge.c
index dac0eaf5..61d4e545 100644
--- a/src/lib/exchange_api_purse_create_with_merge.c
+++ b/src/lib/exchange_api_purse_create_with_merge.c
@@ -250,9 +250,7 @@ TALER_EXCHANGE_purse_create_with_merge (
   const struct TALER_ContractDiffiePrivateP *contract_priv,
   const json_t *contract_terms,
   bool upload_contract,
-  struct GNUNET_TIME_Timestamp purse_expiration,
   struct GNUNET_TIME_Timestamp merge_timestamp,
-  const struct TALER_Amount *purse_value_after_fees,
   TALER_EXCHANGE_PurseCreateMergeCallback cb,
   void *cb_cls)
 {
@@ -270,6 +268,7 @@ TALER_EXCHANGE_purse_create_with_merge (
   struct TALER_PurseContractSignatureP purse_sig;
   void *econtract = NULL;
   size_t econtract_size = 0;
+  struct TALER_Amount purse_value_after_fees;
 
   pcm = GNUNET_new (struct TALER_EXCHANGE_PurseCreateMergeHandle);
   pcm->exchange = exchange;
@@ -284,9 +283,7 @@ TALER_EXCHANGE_purse_create_with_merge (
     return NULL;
   }
   pcm->h_contract_terms = pcm->h_contract_terms;
-  pcm->purse_expiration = purse_expiration;
   pcm->merge_timestamp = merge_timestamp;
-  pcm->purse_value_after_fees = *purse_value_after_fees;
   GNUNET_CRYPTO_eddsa_key_get_public (&purse_priv->eddsa_priv,
                                       &pcm->purse_pub.eddsa_pub);
   GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
@@ -296,11 +293,8 @@ TALER_EXCHANGE_purse_create_with_merge (
   GNUNET_CRYPTO_ecdhe_key_get_public (&contract_priv->ecdhe_priv,
                                       &contract_pub.ecdhe_pub);
 
-  // FIXME: extract min_age from contract_terms!
   {
-    // FIXME: extract amount from contract
-    // or pass explicitly? what about other
-    // args, like the purse expiration time?
+    // FIXME: get purse expiration time from contract?
     struct GNUNET_JSON_Specification spec[] = {
       TALER_JSON_spec_amount_any ("amount",
                                   &pcm->purse_value_after_fees),
@@ -308,6 +302,9 @@ TALER_EXCHANGE_purse_create_with_merge (
         GNUNET_JSON_spec_uint32 ("minimum_age",
                                  &min_age),
         NULL),
+      // FIXME: correct field name?
+      GNUNET_JSON_spec_timestamp ("payment_deadline",
+                                  &pcm->purse_expiration),
       GNUNET_JSON_spec_end ()
     };
 
@@ -385,7 +382,7 @@ TALER_EXCHANGE_purse_create_with_merge (
   }
   create_with_merge_obj = GNUNET_JSON_PACK (
     TALER_JSON_pack_amount ("purse_value",
-                            purse_value_after_fees),
+                            &purse_value_after_fees),
     GNUNET_JSON_pack_uint64 ("min_age",
                              min_age),
     GNUNET_JSON_pack_allow_null (
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 304a2440..f15577be 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -72,6 +72,7 @@ libtalertesting_la_SOURCES = \
   testing_api_cmd_offline_sign_keys.c \
   testing_api_cmd_offline_sign_extensions.c \
   testing_api_cmd_purse_create_deposit.c \
+  testing_api_cmd_purse_deposit.c \
   testing_api_cmd_purse_merge.c \
   testing_api_cmd_set_wire_fee.c \
   testing_api_cmd_recoup.c \
@@ -80,6 +81,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_purse.c \
   testing_api_cmd_reserve_status.c \
   testing_api_cmd_revoke.c \
   testing_api_cmd_revoke_denom_key.c \
@@ -122,7 +124,7 @@ AM_TESTS_ENVIRONMENT=export 
TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=
 
 noinst_PROGRAMS = \
   test_exchange_p2p_cs \
-  test_exchange_p2p_rsa 
+  test_exchange_p2p_rsa
 
 
 .NOTPARALLEL:
diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c 
b/src/testing/testing_api_cmd_purse_deposit.c
similarity index 65%
copy from src/testing/testing_api_cmd_purse_create_deposit.c
copy to src/testing/testing_api_cmd_purse_deposit.c
index af7ed3f5..0e97749c 100644
--- a/src/testing/testing_api_cmd_purse_create_deposit.c
+++ b/src/testing/testing_api_cmd_purse_deposit.c
@@ -17,7 +17,7 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file testing/testing_api_cmd_purse_create_deposit.c
+ * @file testing/testing_api_cmd_purse_deposit.c
  * @brief command for testing /purses/$PID/create
  * @author Christian Grothoff
  */
@@ -52,9 +52,9 @@ struct Coin
 
 
 /**
- * State for a "purse create deposit" CMD.
+ * State for a "purse deposit" CMD.
  */
-struct PurseCreateDepositState
+struct PurseDepositState
 {
 
   /**
@@ -68,66 +68,25 @@ struct PurseCreateDepositState
   struct Coin *coin_references;
 
   /**
-   * JSON string describing what a proposal is about.
-   */
-  json_t *contract_terms;
-
-  /**
-   * Purse expiration time.
-   */
-  struct GNUNET_TIME_Timestamp purse_expiration;
-
-  /**
-   * Relative purse expiration time.
-   */
-  struct GNUNET_TIME_Relative rel_expiration;
-
-  /**
-   * Set (by the interpreter) to a fresh private key.  This
-   * key will be used to create the purse.
-   */
-  struct TALER_PurseContractPrivateKeyP purse_priv;
-
-  /**
-   * Set (by the interpreter) to a fresh private key.  This
-   * key will be used to merge the purse.
-   */
-  struct TALER_PurseMergePrivateKeyP merge_priv;
-
-  /**
-   * Set (by the interpreter) to a fresh private key.  This
-   * key will be used to decrypt the contract.
-   */
-  struct TALER_ContractDiffiePrivateP contract_priv;
-
-  /**
-   * Signing key used by the exchange to sign the
-   * deposit confirmation.
-   */
-  struct TALER_ExchangePublicKeyP exchange_pub;
-
-  /**
-   * Signature from the exchange on the
-   * deposit confirmation.
-   */
-  struct TALER_ExchangeSignatureP exchange_sig;
-
-  /**
-   * Set (by the interpreter) to a public key corresponding
-   * to @e purse_priv.
+   * The purse's public key.
    */
   struct TALER_PurseContractPublicKeyP purse_pub;
 
   /**
-   * PurseCreateDeposit handle while operation is running.
+   * PurseDeposit handle while operation is running.
    */
-  struct TALER_EXCHANGE_PurseCreateDepositHandle *dh;
+  struct TALER_EXCHANGE_PurseDepositHandle *dh;
 
   /**
    * Interpreter state.
    */
   struct TALER_TESTING_Interpreter *is;
 
+  /**
+   * Reference to the command that established the purse.
+   */
+  const char *purse_ref;
+
   /**
    * Expected HTTP response code.
    */
@@ -139,15 +98,14 @@ struct PurseCreateDepositState
   unsigned int num_coin_references;
 
   /**
-   * Should we upload the contract?
+   * Minimum age to apply to all deposits.
    */
-  bool upload_contract;
-
+  uint8_t min_age;
 };
 
 
 /**
- * Callback to analyze the /purses/$PID/create response, just used to check if
+ * Callback to analyze the /purses/$PID/deposit response, just used to check if
  * the response code is acceptable.
  *
  * @param cls closure.
@@ -155,9 +113,9 @@ struct PurseCreateDepositState
  */
 static void
 deposit_cb (void *cls,
-            const struct TALER_EXCHANGE_PurseCreateDepositResponse *dr)
+            const struct TALER_EXCHANGE_PurseDepositResponse *dr)
 {
-  struct PurseCreateDepositState *ds = cls;
+  struct PurseDepositState *ds = cls;
 
   ds->dh = NULL;
   if (ds->expected_response_code != dr->hr.http_status)
@@ -176,8 +134,7 @@ deposit_cb (void *cls,
   }
   if (MHD_HTTP_OK == dr->hr.http_status)
   {
-    ds->exchange_pub = dr->details.success.exchange_pub;
-    ds->exchange_sig = dr->details.success.exchange_sig;
+    // FIXME: any data to keep from reply?
   }
   TALER_TESTING_interpreter_next (ds->is);
 }
@@ -195,7 +152,7 @@ deposit_run (void *cls,
              const struct TALER_TESTING_Command *cmd,
              struct TALER_TESTING_Interpreter *is)
 {
-  struct PurseCreateDepositState *ds = cls;
+  struct PurseDepositState *ds = cls;
   struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references];
 
   (void) cmd;
@@ -256,30 +213,20 @@ deposit_run (void *cls,
     pd->h_denom_pub = denom_pub->h_key;
   }
 
-  GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv);
-  GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv);
-  GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv);
-  ds->purse_expiration
-    = GNUNET_TIME_relative_to_timestamp (ds->rel_expiration);
-  GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv,
-                                      &ds->purse_pub.eddsa_pub);
-  ds->dh = TALER_EXCHANGE_purse_create_with_deposit (
+  ds->dh = TALER_EXCHANGE_purse_deposit (
     is->exchange,
-    &ds->purse_priv,
-    &ds->merge_priv,
-    &ds->contract_priv,
-    ds->contract_terms,
-    ds->purse_expiration,
+    NULL, /* FIXME: purse exchange URL */
+    &ds->purse_pub,
+    ds->min_age,
     ds->num_coin_references,
     deposits,
-    ds->upload_contract,
     &deposit_cb,
     ds);
   if (NULL == ds->dh)
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Could not create purse with deposit\n");
+                "Could not deposit into purse\n");
     TALER_TESTING_interpreter_fail (is);
     return;
   }
@@ -290,14 +237,14 @@ deposit_run (void *cls,
  * Free the state of a "deposit" CMD, and possibly cancel a
  * pending operation thereof.
  *
- * @param cls closure, must be a `struct PurseCreateDepositState`.
+ * @param cls closure, must be a `struct PurseDepositState`.
  * @param cmd the command which is being cleaned up.
  */
 static void
 deposit_cleanup (void *cls,
                  const struct TALER_TESTING_Command *cmd)
 {
-  struct PurseCreateDepositState *ds = cls;
+  struct PurseDepositState *ds = cls;
 
   if (NULL != ds->dh)
   {
@@ -305,12 +252,11 @@ deposit_cleanup (void *cls,
                 "Command %u (%s) did not complete\n",
                 ds->is->ip,
                 cmd->label);
-    TALER_EXCHANGE_purse_create_with_deposit_cancel (ds->dh);
+    TALER_EXCHANGE_purse_deposit_cancel (ds->dh);
     ds->dh = NULL;
   }
   for (unsigned int i = 0; i<ds->num_coin_references; i++)
     GNUNET_free (ds->coin_references[i].command_ref);
-  json_decref (ds->contract_terms);
   GNUNET_free (ds->coin_references);
   GNUNET_free (ds);
 }
@@ -331,16 +277,9 @@ deposit_traits (void *cls,
                 const char *trait,
                 unsigned int index)
 {
-  struct PurseCreateDepositState *ds = cls;
+  struct PurseDepositState *ds = cls;
   struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
-    TALER_TESTING_make_trait_contract_priv (&ds->contract_priv),
-    TALER_TESTING_make_trait_purse_priv (&ds->purse_priv),
     TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
-    TALER_TESTING_make_trait_contract_terms (ds->contract_terms),
-    TALER_TESTING_make_trait_deposit_amount (&ds->target_amount),
-    TALER_TESTING_make_trait_timestamp (index,
-                                        &ds->purse_expiration),
     TALER_TESTING_trait_end ()
   };
 
@@ -352,39 +291,26 @@ deposit_traits (void *cls,
 
 
 struct TALER_TESTING_Command
-TALER_TESTING_cmd_purse_create_with_deposit (
+TALER_TESTING_cmd_purse_deposit_coins (
   const char *label,
   unsigned int expected_http_status,
-  const char *target_amount,
-  const char *contract_terms,
-  bool upload_contract,
-  struct GNUNET_TIME_Relative purse_expiration,
+  uint8_t min_age,
+  const char *purse_ref,
   ...)
 {
-  struct PurseCreateDepositState *ds;
+  struct PurseDepositState *ds;
 
-  ds = GNUNET_new (struct PurseCreateDepositState);
-  ds->rel_expiration = purse_expiration;
-  ds->upload_contract = upload_contract;
+  ds = GNUNET_new (struct PurseDepositState);
   ds->expected_response_code = expected_http_status;
-  ds->contract_terms = json_loads (contract_terms,
-                                   JSON_REJECT_DUPLICATES,
-                                   NULL);
-  if (NULL == ds->contract_terms)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Failed to parse contract terms `%s' for CMD `%s'\n",
-                contract_terms,
-                label);
-    GNUNET_assert (0);
-  }
+  ds->min_age = min_age;
+  ds->purse_ref = purse_ref;
   {
     va_list ap;
     unsigned int i;
     const char *ref;
     const char *val;
 
-    va_start (ap, purse_expiration);
+    va_start (ap, purse_ref);
     while (NULL != (va_arg (ap, const char *)))
       ds->num_coin_references++;
     va_end (ap);
@@ -393,7 +319,7 @@ TALER_TESTING_cmd_purse_create_with_deposit (
     ds->coin_references = GNUNET_new_array (ds->num_coin_references,
                                             struct Coin);
     i = 0;
-    va_start (ap, purse_expiration);
+    va_start (ap, purse_ref);
     while (NULL != (ref = va_arg (ap, const char *)))
     {
       struct Coin *c = &ds->coin_references[i++];
@@ -410,9 +336,6 @@ TALER_TESTING_cmd_purse_create_with_deposit (
     }
     va_end (ap);
   }
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_string_to_amount (target_amount,
-                                         &ds->target_amount));
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ds,
@@ -427,4 +350,4 @@ TALER_TESTING_cmd_purse_create_with_deposit (
 }
 
 
-/* end of testing_api_cmd_purse_create_deposit.c */
+/* end of testing_api_cmd_purse_deposit.c */
diff --git a/src/testing/testing_api_cmd_contract_get.c 
b/src/testing/testing_api_cmd_reserve_purse.c
similarity index 51%
copy from src/testing/testing_api_cmd_contract_get.c
copy to src/testing/testing_api_cmd_reserve_purse.c
index 9432fdee..8f44692f 100644
--- a/src/testing/testing_api_cmd_contract_get.c
+++ b/src/testing/testing_api_cmd_reserve_purse.c
@@ -17,8 +17,8 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file testing/testing_api_cmd_contract_get.c
- * @brief command for testing GET /contracts/$CPUB
+ * @file testing/testing_api_cmd_reserve_purse.c
+ * @brief command for testing /reserves/$PID/purse
  * @author Christian Grothoff
  */
 #include "platform.h"
@@ -30,20 +30,26 @@
 
 
 /**
- * State for a "contract get" CMD.
+ * State for a "purse create with merge" CMD.
  */
-struct ContractGetState
+struct ReservePurseState
 {
 
   /**
-   * JSON string describing the resulting contract.
+   * Merge time (local time when the command was
+   * executed).
    */
-  json_t *contract_terms;
+  struct GNUNET_TIME_Timestamp merge_timestamp;
 
   /**
-   * Set to the returned merge key.
+   * Reserve private key.
    */
-  struct TALER_PurseMergePrivateKeyP merge_priv;
+  struct TALER_ReservePrivateKeyP reserve_priv;
+
+  /**
+   * Private key of the purse.
+   */
+  struct TALER_PurseContractPrivateKeyP purse_priv;
 
   /**
    * Public key of the purse.
@@ -51,14 +57,29 @@ struct ContractGetState
   struct TALER_PurseContractPublicKeyP purse_pub;
 
   /**
-   * Reference to the command that uploaded the contract.
+   * Private key with the merge capability.
+   */
+  struct TALER_PurseMergePrivateKeyP merge_priv;
+
+  /**
+   * Private key to decrypt the contract.
+   */
+  struct TALER_ContractDiffiePrivateP contract_priv;
+
+  /**
+   * Handle while operation is running.
+   */
+  struct TALER_EXCHANGE_PurseCreateMergeHandle *dh;
+
+  /**
+   * Contract terms for the purse.
    */
-  const char *contract_ref;
+  json_t *contract_terms;
 
   /**
-   * ContractGet handle while operation is running.
+   * Refernece to the reserve, or NULL (!).
    */
-  struct TALER_EXCHANGE_ContractsGetHandle *dh;
+  const char *reserve_ref;
 
   /**
    * Interpreter state.
@@ -74,18 +95,17 @@ struct ContractGetState
 
 
 /**
- * Callback to analyze the /contracts/$CPUB response, just used to check if
+ * Callback to analyze the /reserves/$PID/purse response, just used to check if
  * the response code is acceptable.
  *
  * @param cls closure.
- * @param dr get response details
+ * @param dr purse response details
  */
 static void
-get_cb (void *cls,
-        const struct TALER_EXCHANGE_ContractGetResponse *dr)
+purse_cb (void *cls,
+          const struct TALER_EXCHANGE_PurseCreateMergeResponse *dr)
 {
-  struct ContractGetState *ds = cls;
-  const struct TALER_TESTING_Command *ref;
+  struct ReservePurseState *ds = cls;
 
   ds->dh = NULL;
   if (ds->expected_response_code != dr->hr.http_status)
@@ -102,51 +122,6 @@ get_cb (void *cls,
     TALER_TESTING_interpreter_fail (ds->is);
     return;
   }
-  ref = TALER_TESTING_interpreter_lookup_command (ds->is,
-                                                  ds->contract_ref);
-  if (MHD_HTTP_OK == dr->hr.http_status)
-  {
-    const struct TALER_PurseMergePrivateKeyP *mp;
-    const json_t *ct;
-
-    /* check that we got what we expected to get! */
-    if (GNUNET_OK !=
-        TALER_TESTING_get_trait_merge_priv (ref,
-                                            &mp))
-    {
-      GNUNET_break (0);
-      TALER_TESTING_interpreter_fail (ds->is);
-      return;
-    }
-    if (GNUNET_OK !=
-        TALER_TESTING_get_trait_contract_terms (ref,
-                                                &ct))
-    {
-      GNUNET_break (0);
-      TALER_TESTING_interpreter_fail (ds->is);
-      return;
-    }
-    if (0 !=
-        GNUNET_memcmp (mp,
-                       &dr->details.success.merge_priv))
-    {
-      GNUNET_break (0);
-      TALER_TESTING_interpreter_fail (ds->is);
-      return;
-    }
-    if (1 != /* 1: equal, 0: not equal */
-        json_equal (ct,
-                    dr->details.success.contract_terms))
-    {
-      GNUNET_break (0);
-      TALER_TESTING_interpreter_fail (ds->is);
-      return;
-    }
-    ds->contract_terms = json_incref (
-      (json_t *) dr->details.success.contract_terms);
-    ds->merge_priv = dr->details.success.merge_priv;
-    ds->purse_pub = dr->details.success.purse_pub;
-  }
   TALER_TESTING_interpreter_next (ds->is);
 }
 
@@ -159,37 +134,50 @@ get_cb (void *cls,
  * @param is the interpreter state.
  */
 static void
-get_run (void *cls,
-         const struct TALER_TESTING_Command *cmd,
-         struct TALER_TESTING_Interpreter *is)
+purse_run (void *cls,
+           const struct TALER_TESTING_Command *cmd,
+           struct TALER_TESTING_Interpreter *is)
 {
-  struct ContractGetState *ds = cls;
-  const struct TALER_ContractDiffiePrivateP *contract_priv;
+  struct ReservePurseState *ds = cls;
+  const struct TALER_ReservePrivateKeyP *reserve_priv;
   const struct TALER_TESTING_Command *ref;
 
   (void) cmd;
   ds->is = is;
   ref = TALER_TESTING_interpreter_lookup_command (ds->is,
-                                                  ds->contract_ref);
+                                                  ds->reserve_ref);
   GNUNET_assert (NULL != ref);
   if (GNUNET_OK !=
-      TALER_TESTING_get_trait_contract_priv (ref,
-                                             &contract_priv))
+      TALER_TESTING_get_trait_reserve_priv (ref,
+                                            &reserve_priv))
   {
     GNUNET_break (0);
     TALER_TESTING_interpreter_fail (ds->is);
     return;
   }
-  ds->dh = TALER_EXCHANGE_contract_get (
+  ds->reserve_priv = *reserve_priv;
+  GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv);
+  GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv,
+                                      &ds->purse_pub.eddsa_pub);
+  GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv);
+  GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv);
+  ds->merge_timestamp = GNUNET_TIME_timestamp_get ();
+  ds->dh = TALER_EXCHANGE_purse_create_with_merge (
     is->exchange,
-    contract_priv,
-    &get_cb,
+    &ds->reserve_priv,
+    &ds->purse_priv,
+    &ds->merge_priv,
+    &ds->contract_priv,
+    ds->contract_terms,
+    true /* upload contract */,
+    ds->merge_timestamp,
+    &purse_cb,
     ds);
   if (NULL == ds->dh)
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Could not GET contract\n");
+                "Could not purse reserve\n");
     TALER_TESTING_interpreter_fail (is);
     return;
   }
@@ -197,17 +185,17 @@ get_run (void *cls,
 
 
 /**
- * Free the state of a "get" CMD, and possibly cancel a
+ * Free the state of a "purse" CMD, and possibly cancel a
  * pending operation thereof.
  *
- * @param cls closure, must be a `struct ContractGetState`.
+ * @param cls closure, must be a `struct ReservePurseState`.
  * @param cmd the command which is being cleaned up.
  */
 static void
-get_cleanup (void *cls,
-             const struct TALER_TESTING_Command *cmd)
+purse_cleanup (void *cls,
+               const struct TALER_TESTING_Command *cmd)
 {
-  struct ContractGetState *ds = cls;
+  struct ReservePurseState *ds = cls;
 
   if (NULL != ds->dh)
   {
@@ -215,7 +203,7 @@ get_cleanup (void *cls,
                 "Command %u (%s) did not complete\n",
                 ds->is->ip,
                 cmd->label);
-    TALER_EXCHANGE_contract_get_cancel (ds->dh);
+    TALER_EXCHANGE_purse_create_with_merge_cancel (ds->dh);
     ds->dh = NULL;
   }
   json_decref (ds->contract_terms);
@@ -224,7 +212,7 @@ get_cleanup (void *cls,
 
 
 /**
- * Offer internal data from a "get" CMD, to other commands.
+ * Offer internal data from a "purse" CMD, to other commands.
  *
  * @param cls closure.
  * @param[out] ret result.
@@ -233,16 +221,21 @@ get_cleanup (void *cls,
  * @return #GNUNET_OK on success.
  */
 static enum GNUNET_GenericReturnValue
-get_traits (void *cls,
-            const void **ret,
-            const char *trait,
-            unsigned int index)
+purse_traits (void *cls,
+              const void **ret,
+              const char *trait,
+              unsigned int index)
 {
-  struct ContractGetState *ds = cls;
+  struct ReservePurseState *ds = cls;
   struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
-    TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
+    TALER_TESTING_make_trait_timestamp (0,
+                                        &ds->merge_timestamp),
     TALER_TESTING_make_trait_contract_terms (ds->contract_terms),
+    TALER_TESTING_make_trait_purse_priv (&ds->purse_priv),
+    TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
+    TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
+    TALER_TESTING_make_trait_contract_priv (&ds->contract_priv),
+    TALER_TESTING_make_trait_reserve_priv (&ds->reserve_priv),
     TALER_TESTING_trait_end ()
   };
 
@@ -254,23 +247,31 @@ get_traits (void *cls,
 
 
 struct TALER_TESTING_Command
-TALER_TESTING_cmd_contract_get (
+TALER_TESTING_cmd_purse_create_with_reserve (
   const char *label,
   unsigned int expected_http_status,
-  const char *contract_ref)
+  const char *contract_terms,
+  bool upload_contract,
+  const char *reserve_ref)
 {
-  struct ContractGetState *ds;
-
-  ds = GNUNET_new (struct ContractGetState);
+  struct ReservePurseState *ds;
+  json_error_t err;
+
+  ds = GNUNET_new (struct ReservePurseState);
+  ds->contract_terms = json_loads (contract_terms,
+                                   0 /* flags */,
+                                   &err);
+  GNUNET_assert (NULL != ds->contract_terms);
+  ds->reserve_ref = reserve_ref;
   ds->expected_response_code = expected_http_status;
-  ds->contract_ref = contract_ref;
+
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ds,
       .label = label,
-      .run = &get_run,
-      .cleanup = &get_cleanup,
-      .traits = &get_traits
+      .run = &purse_run,
+      .cleanup = &purse_cleanup,
+      .traits = &purse_traits
     };
 
     return cmd;
@@ -278,4 +279,4 @@ TALER_TESTING_cmd_contract_get (
 }
 
 
-/* end of testing_api_cmd_contract_get.c */
+/* end of testing_api_cmd_reserve_purse.c */
diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c
index deacf32e..e211e16e 100644
--- a/src/util/exchange_signatures.c
+++ b/src/util/exchange_signatures.c
@@ -85,6 +85,7 @@ TALER_exchange_deposit_sign (
                             &merchant_sig->eddsa_sig);
 }
 
+
 enum GNUNET_GenericReturnValue
 TALER_exchange_deposit_verify (
   const struct TALER_MerchantPublicKeyP *merchant,

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