gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: fixing #5767


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: fixing #5767
Date: Sun, 28 Jul 2019 15:41:08 +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 5b2efa2b fixing #5767
5b2efa2b is described below

commit 5b2efa2b0694f2e1d16af15c7c47cbd26f7c64c1
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Jul 28 15:39:28 2019 +0200

    fixing #5767
---
 .../taler-auditor-httpd_deposit-confirmation.c     | 16 ++--
 src/auditor/taler-auditor-httpd_parsing.c          |  2 +-
 src/exchange/taler-exchange-httpd_deposit.c        |  4 +-
 src/lib/auditor_api_deposit_confirmation.c         | 55 +++++++------
 src/lib/auditor_api_handle.c                       | 24 +++---
 src/lib/exchange_api_common.c                      | 10 +--
 src/lib/exchange_api_deposit.c                     |  8 +-
 src/lib/teah_common.c                              |  7 +-
 src/lib/test_auditor_api.c                         | 20 ++---
 src/lib/testing_api_cmd_deposit.c                  | 51 ++++++++-----
 .../testing_auditor_api_cmd_deposit_confirmation.c | 89 +++++++++++++---------
 11 files changed, 156 insertions(+), 130 deletions(-)

diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c 
b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
index a3d03baf..af86378c 100644
--- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c
+++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
@@ -153,7 +153,7 @@ verify_and_execute_deposit_confirmation (struct 
MHD_Connection *connection,
   {
     TALER_LOG_WARNING ("Invalid signature on exchange signing key\n");
     return TAH_RESPONSE_reply_signature_invalid (connection,
-                                                
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
+                                                 
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
                                                  "master_sig");
   }
 
@@ -161,9 +161,9 @@ verify_and_execute_deposit_confirmation (struct 
MHD_Connection *connection,
   if (GNUNET_OK !=
       TAH_DB_run_transaction (connection,
                               "persist exchange signing key",
-                             &mhd_ret,
-                             &store_exchange_signing_key_transaction,
-                             (void *) es))
+                              &mhd_ret,
+                              &store_exchange_signing_key_transaction,
+                              (void *) es))
     return mhd_ret;
 
   /* check deposit confirmation signature */
@@ -185,7 +185,7 @@ verify_and_execute_deposit_confirmation (struct 
MHD_Connection *connection,
   {
     TALER_LOG_WARNING ("Invalid signature on /deposit-confirmation request\n");
     return TAH_RESPONSE_reply_signature_invalid (connection,
-                                                
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
+                                                 
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
                                                  "exchange_sig");
   }
 
@@ -193,9 +193,9 @@ verify_and_execute_deposit_confirmation (struct 
MHD_Connection *connection,
   if (GNUNET_OK !=
       TAH_DB_run_transaction (connection,
                               "store deposit confirmation",
-                             &mhd_ret,
-                             &deposit_confirmation_transaction,
-                             (void *) dc))
+                              &mhd_ret,
+                              &deposit_confirmation_transaction,
+                              (void *) dc))
     return mhd_ret;
   return reply_deposit_confirmation_success (connection);
 }
diff --git a/src/auditor/taler-auditor-httpd_parsing.c 
b/src/auditor/taler-auditor-httpd_parsing.c
index 6c4bece9..36ae4a16 100644
--- a/src/auditor/taler-auditor-httpd_parsing.c
+++ b/src/auditor/taler-auditor-httpd_parsing.c
@@ -80,7 +80,7 @@ TAH_PARSE_post_json (struct MHD_Connection *connection,
   case GNUNET_JSON_PR_OUT_OF_MEMORY:
     return (MHD_NO ==
             TAH_RESPONSE_reply_internal_error (connection,
-                                              TALER_EC_PARSER_OUT_OF_MEMORY,
+                                               TALER_EC_PARSER_OUT_OF_MEMORY,
                                                "out of memory"))
       ? GNUNET_SYSERR : GNUNET_NO;
   case GNUNET_JSON_PR_CONTINUE:
diff --git a/src/exchange/taler-exchange-httpd_deposit.c 
b/src/exchange/taler-exchange-httpd_deposit.c
index 51adacb7..c19ad4b1 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -80,8 +80,8 @@ reply_deposit_success (struct MHD_Connection *connection,
   dc.merchant = *merchant;
   if (GNUNET_OK !=
       TEH_KS_sign (&dc.purpose,
-                  &pub,
-                  &sig))
+                   &pub,
+                   &sig))
   {
     return TEH_RESPONSE_reply_internal_error (connection,
                                               
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
diff --git a/src/lib/auditor_api_deposit_confirmation.c 
b/src/lib/auditor_api_deposit_confirmation.c
index f26339a6..2001a2c5 100644
--- a/src/lib/auditor_api_deposit_confirmation.c
+++ b/src/lib/auditor_api_deposit_confirmation.c
@@ -189,7 +189,6 @@ verify_signatures (const struct GNUNET_HashCode *h_wire,
       TALER_LOG_DEBUG ("... amount_without_fee was %s\n",
                        TALER_amount2s (amount_without_fee));
     }
-
     return GNUNET_SYSERR;
   }
   sv.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
@@ -268,8 +267,8 @@ TALER_AUDITOR_deposit_confirmation (struct 
TALER_AUDITOR_Handle *auditor,
                                     struct GNUNET_TIME_Absolute ep_expire,
                                     struct GNUNET_TIME_Absolute ep_end,
                                     const struct TALER_MasterSignatureP 
*master_sig,
-                                   
TALER_AUDITOR_DepositConfirmationResultCallback cb,
-                                   void *cb_cls)
+                                    
TALER_AUDITOR_DepositConfirmationResultCallback cb,
+                                    void *cb_cls)
 {
   struct TALER_AUDITOR_DepositConfirmationHandle *dh;
   struct GNUNET_CURL_Context *ctx;
@@ -282,7 +281,7 @@ TALER_AUDITOR_deposit_confirmation (struct 
TALER_AUDITOR_Handle *auditor,
   (void) GNUNET_TIME_round_abs (&ep_expire);
   (void) GNUNET_TIME_round_abs (&ep_end);
   GNUNET_assert (GNUNET_YES ==
-                MAH_handle_is_ready (auditor));
+                 MAH_handle_is_ready (auditor));
   if (GNUNET_OK !=
       verify_signatures (h_wire,
                          h_contract_terms,
@@ -305,26 +304,26 @@ TALER_AUDITOR_deposit_confirmation (struct 
TALER_AUDITOR_Handle *auditor,
 
   deposit_confirmation_obj
     = json_pack ("{s:o, s:o," /* H_wire, h_contract_terms */
-                " s:o, s:o," /* timestamp, refund_deadline */
-                " s:o, s:o," /* amount_without_fees, coin_pub */
-                " s:o, s:o," /* merchant_pub, exchange_sig */
-                " s:o, s:o," /* master_pub, ep_start */
-                " s:o, s:o," /* ep_expire, ep_end */
+                 " s:o, s:o," /* timestamp, refund_deadline */
+                 " s:o, s:o," /* amount_without_fees, coin_pub */
+                 " s:o, s:o," /* merchant_pub, exchange_sig */
+                 " s:o, s:o," /* master_pub, ep_start */
+                 " s:o, s:o," /* ep_expire, ep_end */
                  " s:o, s:o}", /* master_sig, exchange_pub */
-                "h_wire", GNUNET_JSON_from_data_auto (h_wire),
-                "h_contract_terms", GNUNET_JSON_from_data_auto 
(h_contract_terms),
-                "timestamp", GNUNET_JSON_from_time_abs (timestamp),
-                "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline),
-                "amount_without_fee", TALER_JSON_from_amount 
(amount_without_fee),
-                "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
-                "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub),
-                "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig),
-                "master_pub", GNUNET_JSON_from_data_auto (master_pub),
-                "ep_start", GNUNET_JSON_from_time_abs (ep_start),
-                "ep_expire", GNUNET_JSON_from_time_abs (ep_expire),
-                "ep_end", GNUNET_JSON_from_time_abs (ep_end),
-                "master_sig", GNUNET_JSON_from_data_auto (master_sig),
-                "exchange_pub", GNUNET_JSON_from_data_auto (exchange_pub));
+                 "h_wire", GNUNET_JSON_from_data_auto (h_wire),
+                 "h_contract_terms", GNUNET_JSON_from_data_auto 
(h_contract_terms),
+                 "timestamp", GNUNET_JSON_from_time_abs (timestamp),
+                 "refund_deadline", GNUNET_JSON_from_time_abs 
(refund_deadline),
+                 "amount_without_fee", TALER_JSON_from_amount 
(amount_without_fee),
+                 "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
+                 "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub),
+                 "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig),
+                 "master_pub", GNUNET_JSON_from_data_auto (master_pub),
+                 "ep_start", GNUNET_JSON_from_time_abs (ep_start),
+                 "ep_expire", GNUNET_JSON_from_time_abs (ep_expire),
+                 "ep_end", GNUNET_JSON_from_time_abs (ep_end),
+                 "master_sig", GNUNET_JSON_from_data_auto (master_sig),
+                 "exchange_pub", GNUNET_JSON_from_data_auto (exchange_pub));
 
   if (NULL == deposit_confirmation_obj)
   {
@@ -360,11 +359,11 @@ TALER_AUDITOR_deposit_confirmation (struct 
TALER_AUDITOR_Handle *auditor,
               "URL for deposit-confirmation: `%s'\n",
               dh->url);
   ctx = MAH_handle_to_context (auditor);
-  dh->job = GNUNET_CURL_job_add (ctx,
-                                eh,
-                                GNUNET_YES,
-                                &handle_deposit_confirmation_finished,
-                                dh);
+  dh->job = GNUNET_CURL_job_add2 (ctx,
+                                  eh,
+                                  dh->ctx.headers,
+                                  &handle_deposit_confirmation_finished,
+                                  dh);
   return dh;
 }
 
diff --git a/src/lib/auditor_api_handle.c b/src/lib/auditor_api_handle.c
index 8077b80c..bf8c31ab 100644
--- a/src/lib/auditor_api_handle.c
+++ b/src/lib/auditor_api_handle.c
@@ -385,9 +385,10 @@ int
 MAH_handle_is_ready (struct TALER_AUDITOR_Handle *h)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Checking if auditor %p is now ready: %s\n",
+              "Checking if auditor %p (%s) is now ready: %s\n",
               h,
-             (MHD_VERSION == h->state) ? "yes" : "no");
+              h->url,
+              (MHD_VERSION == h->state) ? "yes" : "no");
   return (MHS_VERSION == h->state) ? GNUNET_YES : GNUNET_NO;
 }
 
@@ -453,15 +454,12 @@ MAH_path_to_url2 (const char *base_url,
  */
 struct TALER_AUDITOR_Handle *
 TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
-                      const char *url,
-                      TALER_AUDITOR_VersionCallback version_cb,
-                      void *version_cb_cls)
+                       const char *url,
+                       TALER_AUDITOR_VersionCallback version_cb,
+                       void *version_cb_cls)
 {
   struct TALER_AUDITOR_Handle *auditor;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Connecting to auditor at URL `%s'.\n",
-              url);
   /* Disable 100 continue processing */
   GNUNET_break (GNUNET_OK ==
                 GNUNET_CURL_append_header (ctx,
@@ -472,7 +470,11 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
   auditor->version_cb = version_cb;
   auditor->version_cb_cls = version_cb_cls;
   auditor->retry_task = GNUNET_SCHEDULER_add_now (&request_version,
-                                                 auditor);
+                                                  auditor);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Connecting to auditor at URL `%s' (%p).\n",
+              url,
+              auditor);
   return auditor;
 }
 
@@ -520,6 +522,10 @@ request_version (void *cls)
 void
 TALER_AUDITOR_disconnect (struct TALER_AUDITOR_Handle *auditor)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Disconnecting from auditor at URL `%s' (%p).\n",
+              auditor->url,
+              auditor);
   if (NULL != auditor->vr)
   {
     GNUNET_CURL_job_cancel (auditor->vr->job);
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 72eb9ace..7c70567d 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -37,8 +37,8 @@
  */
 int
 TALER_EXCHANGE_verify_coin_history (const char *currency,
-                                   const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
-                                   json_t *history,
+                                    const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
+                                    json_t *history,
                                     struct TALER_Amount *total)
 {
   size_t len;
@@ -241,8 +241,8 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
                                      &exchange_pub),
         GNUNET_JSON_spec_fixed_auto ("reserve_pub",
                                      &pc.reserve_pub),
-       GNUNET_JSON_spec_absolute_time_nbo ("timestamp",
-                                           &pc.timestamp),
+        GNUNET_JSON_spec_absolute_time_nbo ("timestamp",
+                                            &pc.timestamp),
         GNUNET_JSON_spec_end()
       };
 
@@ -335,7 +335,7 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
  */
 const struct TALER_EXCHANGE_SigningPublicKey *
 TALER_EXCHANGE_get_exchange_signing_key_info (const struct TALER_EXCHANGE_Keys 
*keys,
-                                             const struct 
TALER_ExchangePublicKeyP *exchange_pub)
+                                              const struct 
TALER_ExchangePublicKeyP *exchange_pub)
 {
   for (unsigned int i=0;i<keys->num_sign_keys;i++)
   {
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c
index 72aefca1..6570a17f 100644
--- a/src/lib/exchange_api_deposit.c
+++ b/src/lib/exchange_api_deposit.c
@@ -600,10 +600,10 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle 
*exchange,
               dh->url);
   ctx = TEAH_handle_to_context (exchange);
   dh->job = GNUNET_CURL_job_add2 (ctx,
-                                 eh,
-                                 dh->ctx.headers,
-                                 &handle_deposit_finished,
-                                 dh);
+                                  eh,
+                                  dh->ctx.headers,
+                                  &handle_deposit_finished,
+                                  dh);
   return dh;
 }
 
diff --git a/src/lib/teah_common.c b/src/lib/teah_common.c
index b8bea187..cc8a2375 100644
--- a/src/lib/teah_common.c
+++ b/src/lib/teah_common.c
@@ -31,8 +31,7 @@
 
 
 /**
- * Add the @a body as POST data to the easy handle in
- * @a ctx.
+ * Add the @a body as POST data to the easy handle in @a ctx.
  *
  * @param ctx[in,out] a request context (updated)
  * @param eh easy handle to use
@@ -41,8 +40,8 @@
  */
 int
 TALER_curl_easy_post (struct TEAH_PostContext *ctx,
-                     CURL *eh,
-                     const json_t *body)
+                      CURL *eh,
+                      const json_t *body)
 {
   char *str;
   size_t slen;
diff --git a/src/lib/test_auditor_api.c b/src/lib/test_auditor_api.c
index df69eac9..f8861bc4 100644
--- a/src/lib/test_auditor_api.c
+++ b/src/lib/test_auditor_api.c
@@ -555,47 +555,38 @@ run (void *cls,
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-2",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-3",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-4",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-5",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-6",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-7",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-8",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-9",
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-
     TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-10",
                                        "massive-reserve",
                                        "EUR:1",
@@ -710,6 +701,12 @@ run (void *cls,
        GNUNET_TIME_UNIT_ZERO,
        "EUR:1",
        MHD_HTTP_OK),
+    TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation",
+                                            is->auditor,
+                                            "massive-deposit-10",
+                                            0,
+                                            "EUR:0.99",
+                                            MHD_HTTP_OK),
     CMD_RUN_AUDITOR("massive-auditor"),
 
     TALER_TESTING_cmd_end ()
@@ -752,7 +749,6 @@ int
 main (int argc,
       char * const *argv)
 {
-
   /* These environment variables get in the way... */
   unsetenv ("XDG_DATA_HOME");
   unsetenv ("XDG_CONFIG_HOME");
@@ -770,8 +766,8 @@ main (int argc,
    * fetches the port number from config in order to see
    * if it's available. */
   switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
-                                         &auditor_url,
-                                         &exchange_url))
+                                          &auditor_url,
+                                          &exchange_url))
   {
   case GNUNET_SYSERR:
     GNUNET_break (0);
diff --git a/src/lib/testing_api_cmd_deposit.c 
b/src/lib/testing_api_cmd_deposit.c
index 1868e8bd..d6e3ef54 100644
--- a/src/lib/testing_api_cmd_deposit.c
+++ b/src/lib/testing_api_cmd_deposit.c
@@ -66,10 +66,9 @@ struct DepositState
   json_t *contract_terms;
 
   /**
-   * Relative time (to add to 'now') to compute the refund
-   * deadline.  Zero for no refunds.
+   * Refund deadline. Zero for no refunds.
    */
-  struct GNUNET_TIME_Relative refund_deadline;
+  struct GNUNET_TIME_Absolute refund_deadline;
 
   /**
    * Set (by the interpreter) to a fresh private key.  This
@@ -83,6 +82,11 @@ struct DepositState
   struct TALER_EXCHANGE_DepositHandle *dh;
 
   /**
+   * Timestamp of the /deposit operation.
+   */
+  struct GNUNET_TIME_Absolute timestamp;
+
+  /**
    * Interpreter state.
    */
   struct TALER_TESTING_Interpreter *is;
@@ -245,9 +249,7 @@ deposit_run (void *cls,
   const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
   const struct TALER_DenominationSignature *denom_pub_sig;
   struct TALER_CoinSpendSignatureP coin_sig;
-  struct GNUNET_TIME_Absolute refund_deadline;
   struct GNUNET_TIME_Absolute wire_deadline;
-  struct GNUNET_TIME_Absolute timestamp;
   struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
   struct TALER_MerchantPublicKeyP merchant_pub;
   struct GNUNET_HashCode h_contract_terms;
@@ -307,17 +309,17 @@ deposit_run (void *cls,
   ds->merchant_priv.eddsa_priv = *merchant_priv;
   GNUNET_free (merchant_priv);
 
-  if (0 != ds->refund_deadline.rel_value_us)
+  if (0 != ds->refund_deadline.abs_value_us)
   {
-    refund_deadline = GNUNET_TIME_relative_to_absolute
-      (ds->refund_deadline);
+    struct GNUNET_TIME_Relative refund_deadline;
+
+    refund_deadline = GNUNET_TIME_absolute_get_remaining (ds->refund_deadline);
     wire_deadline = GNUNET_TIME_relative_to_absolute
-    (GNUNET_TIME_relative_multiply
-      (ds->refund_deadline, 2));
+    (GNUNET_TIME_relative_multiply (refund_deadline, 2));
   }
   else
   {
-    refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS;
+    ds->refund_deadline = ds->timestamp;
     wire_deadline = GNUNET_TIME_relative_to_absolute
       (GNUNET_TIME_UNIT_ZERO);
   }
@@ -325,10 +327,7 @@ deposit_run (void *cls,
     (&ds->merchant_priv.eddsa_priv,
      &merchant_pub.eddsa_pub);
 
-  timestamp = GNUNET_TIME_absolute_get ();
-  GNUNET_TIME_round_abs (&timestamp);
-  GNUNET_TIME_round_abs (&refund_deadline);
-  GNUNET_TIME_round_abs (&wire_deadline);
+  (void) GNUNET_TIME_round_abs (&wire_deadline);
 
   {
     struct TALER_DepositRequestPS dr;
@@ -343,9 +342,9 @@ deposit_run (void *cls,
       (GNUNET_OK ==
        TALER_JSON_merchant_wire_signature_hash (ds->wire_details,
                                                 &dr.h_wire));
-    dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);
+    dr.timestamp = GNUNET_TIME_absolute_hton (ds->timestamp);
     dr.refund_deadline = GNUNET_TIME_absolute_hton
-      (refund_deadline);
+      (ds->refund_deadline);
     TALER_amount_hton (&dr.amount_with_fee, &amount);
     TALER_amount_hton
       (&dr.deposit_fee, &denom_pub->fee_deposit);
@@ -365,9 +364,9 @@ deposit_run (void *cls,
      &coin_pub,
      denom_pub_sig,
      &denom_pub->key,
-     timestamp,
+     ds->timestamp,
      &merchant_pub,
-     refund_deadline,
+     ds->refund_deadline,
      &coin_sig,
      &deposit_cb,
      ds);
@@ -537,8 +536,20 @@ TALER_TESTING_cmd_deposit
        label);
     GNUNET_assert (0);
   }
+  ds->timestamp = GNUNET_TIME_absolute_get ();
+  (void) GNUNET_TIME_round_abs (&ds->timestamp);
 
-  ds->refund_deadline = refund_deadline;
+  json_object_set (ds->contract_terms,
+                   "timestamp",
+                   GNUNET_JSON_from_time_abs (ds->timestamp));
+  if (0 != refund_deadline.rel_value_us)
+  {
+    ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline);
+    (void) GNUNET_TIME_round_abs (&ds->refund_deadline);
+    json_object_set (ds->contract_terms,
+                     "refund_deadline",
+                     GNUNET_JSON_from_time_abs (ds->refund_deadline));
+  }
   ds->amount = amount;
   ds->expected_response_code = expected_response_code;
 
diff --git a/src/lib/testing_auditor_api_cmd_deposit_confirmation.c 
b/src/lib/testing_auditor_api_cmd_deposit_confirmation.c
index 95871ef1..f5235266 100644
--- a/src/lib/testing_auditor_api_cmd_deposit_confirmation.c
+++ b/src/lib/testing_auditor_api_cmd_deposit_confirmation.c
@@ -101,8 +101,8 @@ struct DepositConfirmationState
  */
 static void
 deposit_confirmation_run (void *cls,
-                         const struct TALER_TESTING_Command *cmd,
-                         struct TALER_TESTING_Interpreter *is);
+                          const struct TALER_TESTING_Command *cmd,
+                          struct TALER_TESTING_Interpreter *is);
 
 
 /**
@@ -133,9 +133,9 @@ do_retry (void *cls)
  */
 static void
 deposit_confirmation_cb (void *cls,
-                        unsigned int http_status,
-                        enum TALER_ErrorCode ec,
-                        const json_t *obj)
+                         unsigned int http_status,
+                         enum TALER_ErrorCode ec,
+                         const json_t *obj)
 {
   struct DepositConfirmationState *dcs = cls;
 
@@ -152,14 +152,14 @@ deposit_confirmation_cb (void *cls,
                     "Retrying deposit confirmation failed with %u/%d\n",
                     http_status,
                     (int) ec);
-       /* on DB conflicts, do not use backoff */
-       if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
-         dcs->backoff = GNUNET_TIME_UNIT_ZERO;
-       else
-         dcs->backoff = EXCHANGE_LIB_BACKOFF (dcs->backoff);
-       dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
-                                                       &do_retry,
-                                                       dcs);
+        /* on DB conflicts, do not use backoff */
+        if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+          dcs->backoff = GNUNET_TIME_UNIT_ZERO;
+        else
+          dcs->backoff = EXCHANGE_LIB_BACKOFF (dcs->backoff);
+        dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
+                                                        &do_retry,
+                                                        dcs);
         return;
       }
     }
@@ -186,8 +186,8 @@ deposit_confirmation_cb (void *cls,
  */
 static void
 deposit_confirmation_run (void *cls,
-                         const struct TALER_TESTING_Command *cmd,
-                         struct TALER_TESTING_Interpreter *is)
+                          const struct TALER_TESTING_Command *cmd,
+                          struct TALER_TESTING_Interpreter *is)
 {
   struct DepositConfirmationState *dcs = cls;
   const struct TALER_TESTING_Command *deposit_cmd;
@@ -211,7 +211,7 @@ deposit_confirmation_run (void *cls,
   GNUNET_assert (NULL != dcs->deposit_reference);
   deposit_cmd
     = TALER_TESTING_interpreter_lookup_command (is,
-                                               dcs->deposit_reference);
+                                                dcs->deposit_reference);
   if (NULL == deposit_cmd)
   {
     GNUNET_break (0);
@@ -221,41 +221,41 @@ deposit_confirmation_run (void *cls,
 
   GNUNET_assert (GNUNET_OK ==
                 TALER_TESTING_get_trait_exchange_pub (deposit_cmd,
-                                                      dcs->coin_index,
-                                                      &exchange_pub));
+                                               dcs->coin_index,
+                                               &exchange_pub));
   GNUNET_assert (GNUNET_OK ==
                 TALER_TESTING_get_trait_exchange_sig (deposit_cmd,
-                                                      dcs->coin_index,
-                                                      &exchange_sig));
+                                               dcs->coin_index,
+                                               &exchange_sig));
   keys = TALER_EXCHANGE_get_keys (dcs->is->exchange);
   GNUNET_assert (NULL != keys);
   spk = TALER_EXCHANGE_get_exchange_signing_key_info (keys,
-                                                     exchange_pub);
+                                                      exchange_pub);
 
   GNUNET_assert (GNUNET_OK ==
                 TALER_TESTING_get_trait_contract_terms (deposit_cmd,
-                                                        dcs->coin_index,
-                                                        &contract_terms));
+                                                 dcs->coin_index,
+                                                 &contract_terms));
   /* Very unlikely to fail */
   GNUNET_assert (NULL != contract_terms);
   GNUNET_assert (GNUNET_OK ==
                  TALER_JSON_hash (contract_terms,
                                   &h_contract_terms));
   GNUNET_assert (GNUNET_OK ==
-                TALER_TESTING_get_trait_wire_details (deposit_cmd,
-                                                      dcs->coin_index,
-                                                      &wire_details));
+                 TALER_TESTING_get_trait_wire_details (deposit_cmd,
+                                                       dcs->coin_index,
+                                                       &wire_details));
   GNUNET_assert (GNUNET_OK ==
-                 TALER_JSON_hash (wire_details,
-                                  &h_wire));
+                 TALER_JSON_merchant_wire_signature_hash (wire_details,
+                                                          &h_wire));
   GNUNET_assert (GNUNET_OK ==
-                TALER_TESTING_get_trait_coin_priv (deposit_cmd,
-                                                   dcs->coin_index,
-                                                   &coin_priv));
+                 TALER_TESTING_get_trait_coin_priv (deposit_cmd,
+                                                    dcs->coin_index,
+                                                    &coin_priv));
   GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
                                       &coin_pub.eddsa_pub);
   GNUNET_assert (GNUNET_OK ==
-                TALER_TESTING_get_trait_peer_key (deposit_cmd,
+                 TALER_TESTING_get_trait_peer_key (deposit_cmd,
                                                    dcs->coin_index,
                                                    &merchant_priv));
   GNUNET_CRYPTO_eddsa_key_get_public (merchant_priv,
@@ -263,10 +263,10 @@ deposit_confirmation_run (void *cls,
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount (dcs->amount_without_fee,
                                          &amount_without_fee));
+  /* timestamp is mandatory */
   {
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_absolute_time ("timestamp", &timestamp),
-      GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
       GNUNET_JSON_spec_end()
     };
 
@@ -280,6 +280,21 @@ deposit_confirmation_run (void *cls,
       return;
     }
   }
+  /* refund deadline is optional, defaults to zero */
+  {
+    struct GNUNET_JSON_Specification spec[] = {
+      GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
+      GNUNET_JSON_spec_end()
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_JSON_parse (contract_terms,
+                           spec,
+                           NULL, NULL))
+    {
+      refund_deadline = timestamp;
+    }
+  }
   dcs->dc = TALER_AUDITOR_deposit_confirmation
     (dcs->auditor,
      &h_wire,
@@ -318,7 +333,7 @@ deposit_confirmation_run (void *cls,
  */
 static void
 deposit_confirmation_cleanup (void *cls,
-                             const struct TALER_TESTING_Command *cmd)
+                              const struct TALER_TESTING_Command *cmd)
 {
   struct DepositConfirmationState *dcs = cls;
 
@@ -352,9 +367,9 @@ deposit_confirmation_cleanup (void *cls,
  */
 static int
 deposit_confirmation_traits (void *cls,
-                            const void **ret,
-                            const char *trait,
-                            unsigned int index)
+                             const void **ret,
+                             const char *trait,
+                             unsigned int index)
 {
   /* Must define this function because some callbacks
    * look for certain traits on _all_ the commands. */

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



reply via email to

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