gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated (f3918c1 -> ca73be0)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (f3918c1 -> ca73be0)
Date: Fri, 21 Jul 2017 23:19:58 +0200

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

grothoff pushed a change to branch master
in repository merchant.

    from f3918c1  fix timestamp issue in lib testcase
     new a755271  work for #4943 (incomplete)
     new c6cebe5  style fixes
     new 817d3ff  indentation and style fixes
     new b2b7d8b  indentation fixes
     new c2f95bf  indentation fixes, style fix on how to generate timestamp
     new 49885a0  removing bogus #include
     new 12b0ea3  implement mandatory rounding of timestamp
     new faaf295  init timestamp
     new c3b2fba  fix configuration to ensure exchange wires immediately
     new 759f073  fix merchant_api_track_transfer to actually pass wire method 
to service
     new ca73be0  more logging

The 11 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:
 .../taler-merchant-httpd_track-transaction.c       |   1 -
 src/backend/taler-merchant-httpd_track-transfer.c  | 124 ++-
 src/backenddb/plugin_merchantdb_postgres.c         |   5 +
 src/include/taler_merchant_service.h               | 107 +--
 src/lib/merchant_api_track_transfer.c              |  12 +-
 src/lib/test_merchant_api.c                        | 900 +++++++++++----------
 src/lib/test_merchant_api.conf                     |   3 +-
 7 files changed, 656 insertions(+), 496 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_track-transaction.c 
b/src/backend/taler-merchant-httpd_track-transaction.c
index d0dbe83..5101f3f 100644
--- a/src/backend/taler-merchant-httpd_track-transaction.c
+++ b/src/backend/taler-merchant-httpd_track-transaction.c
@@ -95,7 +95,6 @@ make_track_transaction_ok (unsigned int num_transfers,
 }
 
 
-
 /**
  * Context for a /track/transaction operation.
  */
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c 
b/src/backend/taler-merchant-httpd_track-transfer.c
index d38cb66..4d55b7a 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -96,6 +96,11 @@ struct TrackTransferContext
   char *uri;
 
   /**
+   * Wire method used for the transfer.
+   */
+  char *wire_method;
+
+  /**
    * Pointer to the detail that we are currently
    * checking in #check_transfer().
    */
@@ -183,6 +188,11 @@ free_transfer_track_context (struct TrackTransferContext 
*rctx)
     GNUNET_free (rctx->uri);
     rctx->uri = NULL;
   }
+  if (NULL != rctx->wire_method)
+  {
+    GNUNET_free (rctx->wire_method);
+    rctx->wire_method = NULL;
+  }
   GNUNET_free (rctx);
 }
 
@@ -459,7 +469,7 @@ check_transfer (void *cls,
                                      "exchange_deposit_proof", exchange_proof,
                                      "conflict_offset", (json_int_t) 
rctx->current_offset,
                                      "exchange_transfer_proof", 
rctx->original_response,
-                                     "coin_pub", GNUNET_JSON_from_data_auto 
(coin_pub),
+                                     "coin_pub", GNUNET_JSON_from_data_auto 
(coin_pub), 
                                      "h_contract_terms", 
GNUNET_JSON_from_data_auto (&ttd->h_contract_terms),
                                      "amount_with_fee", TALER_JSON_from_amount 
(amount_with_fee),
                                      "deposit_fee", TALER_JSON_from_amount 
(deposit_fee));
@@ -470,6 +480,89 @@ check_transfer (void *cls,
 
 
 /**
+ * Check that the given @a wire_fee is what the 
+ * @a exchange_pub should charge at the @a execution_time.
+ * If the fee is correct (according to our database),
+ * return #GNUNET_OK.  If we do not have the fee structure
+ * in our DB, we just accept it and return #GNUNET_NO;
+ * if we have proof that the fee is bogus, we respond with
+ * the proof to the client and return #GNUNET_SYSERR.
+ *
+ * @param rctx context of the transfer to respond to
+ * @param json response from the exchange
+ * @param execution_time time of the wire transfer
+ * @param wire_fee fee claimed by the exchange
+ * @return #GNUNET_SYSERR if we returned hard proof of
+ *   missbehavior from the exchange to the client
+ */
+static int
+check_wire_fee (struct TrackTransferContext *rctx,
+               const json_t *json,
+               struct GNUNET_TIME_Absolute execution_time,
+               const struct TALER_Amount *wire_fee)
+{
+  const struct TALER_MasterPublicKeyP *master_pub;
+  struct GNUNET_HashCode h_wire_method;
+  struct TALER_Amount expected_fee;
+  struct TALER_Amount closing_fee;
+  struct TALER_MasterSignatureP master_sig;
+  struct GNUNET_TIME_Absolute start_date;
+  struct GNUNET_TIME_Absolute end_date;
+  enum GNUNET_DB_QueryStatus qs;
+  const struct TALER_EXCHANGE_Keys *keys;
+
+  keys = TALER_EXCHANGE_get_keys (rctx->eh);
+  if (NULL == keys)
+  {
+    GNUNET_break (0);
+    return GNUNET_NO;
+  }
+  master_pub = &keys->master_pub;
+  GNUNET_CRYPTO_hash (rctx->wire_method,
+                     strlen (rctx->wire_method) + 1,
+                     &h_wire_method);
+  qs = db->lookup_wire_fee (db->cls,
+                           master_pub,
+                           &h_wire_method,
+                           execution_time,
+                           &expected_fee,
+                           &closing_fee,
+                           &start_date,
+                           &end_date,
+                           &master_sig);
+  if (0 >= qs)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               "Failed to find wire fee for `%s' at %s in DB, accepting 
blindly that the fee is %s\n",
+               TALER_B2S (master_pub),
+               GNUNET_STRINGS_absolute_time_to_string (execution_time),
+               TALER_amount2s (wire_fee));
+    return GNUNET_NO;
+  }
+  if (0 <= TALER_amount_cmp (&expected_fee,
+                            wire_fee))
+    return GNUNET_OK; /* expected_fee >= wire_fee */
+  
+  /* Wire fee check failed, export proof to client */
+  resume_track_transfer_with_response
+    (rctx,
+     MHD_HTTP_INTERNAL_SERVER_ERROR,
+     TMH_RESPONSE_make_json_pack ("{s:I, s:o, s:o, s:o, s:o, s:o, s:o, s:o, 
s:o, s:O}",
+                                 "code", (json_int_t) 
TALER_EC_TRACK_TRANSFER_JSON_BAD_WIRE_FEE,
+                                 "wire_fee", TALER_JSON_from_amount (wire_fee),
+                                 "execution_time", GNUNET_JSON_from_time_abs 
(execution_time),
+                                 "expected_wire_fee", TALER_JSON_from_amount 
(&expected_fee),
+                                 "expected_closing_fee", 
TALER_JSON_from_amount (&closing_fee),
+                                 "start_date", GNUNET_JSON_from_time_abs 
(start_date),
+                                 "end_date", GNUNET_JSON_from_time_abs 
(end_date),
+                                 "master_sig", GNUNET_JSON_from_data_auto 
(&master_sig),
+                                 "master_pub", GNUNET_JSON_from_data_auto 
(master_pub),
+                                 "json", json));
+  return GNUNET_SYSERR;
+}
+
+
+/**
  * Function called with detailed wire transfer data, including all
  * of the coin transactions that were combined into the wire transfer.
  *
@@ -546,6 +639,14 @@ wire_transfer_cb (void *cls,
     return;
   }
   rctx->original_response = json;
+
+  if (GNUNET_SYSERR ==
+      check_wire_fee (rctx,
+                     json,
+                     execution_time,
+                     wire_fee))
+    return;
+
   for (unsigned int i=0;i<details_length;i++)
   {
     rctx->current_offset = i;
@@ -775,6 +876,7 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh,
   const char *str;
   const char *uri;
   const char *instance_str;
+  const char *wire_method;
   int ret;
   enum GNUNET_DB_QueryStatus qs;
 
@@ -831,6 +933,26 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh,
                                            "exchange");
   rctx->uri = GNUNET_strdup (uri);
 
+  wire_method = MHD_lookup_connection_value (connection,
+                                            MHD_GET_ARGUMENT_KIND,
+                                            "wire_method");
+  if (NULL == wire_method)
+  {
+    if (1)
+    {
+      /* temporary work-around until demo is adjusted... */
+      GNUNET_break (0);
+      wire_method = "test";
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 "Client needs fixing, see API change for #4943!\n");
+    }
+    else
+      return TMH_RESPONSE_reply_arg_missing (connection,
+                                            TALER_EC_PARAMETER_MISSING,
+                                            "wire_method");
+  }
+  rctx->wire_method = GNUNET_strdup (wire_method);
+
   instance_str = MHD_lookup_connection_value (connection,
                                               MHD_GET_ARGUMENT_KIND,
                                               "instance");
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 17e4d0a..6c4dbcb 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1917,6 +1917,11 @@ postgres_store_wire_fee_by_exchange (void *cls,
   };
 
   check_connection (pg);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             "Storing wire fee for %s starting at %s of %s\n",
+             TALER_B2S (exchange_pub),
+             GNUNET_STRINGS_absolute_time_to_string (start_date),
+             TALER_amount2s (wire_fee));
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
                                              "insert_wire_fee",
                                              params);  
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index fa73977..ab31701 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014, 2015, 2016 INRIA
+  Copyright (C) 2014-2017 INRIA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
@@ -30,23 +30,11 @@
 
 /* ********************* /refund ************************** */
 
-struct TALER_MERCHANT_RefundIncreaseOperation;
-
-struct TALER_MERCHANT_RefundLookupOperation;
-
 /**
- * Callback to process a POST /refund request
- *
- * @param cls closure
- * @param http_status HTTP status code for this request
- * @param ec taler-specific error code
- * @param obj the response body
+ * Handle for a GET /refund operation.
  */
-typedef void
-(*TALER_MERCHANT_RefundIncreaseCallback) (void *cls,
-                                          unsigned int http_status,
-                                          enum TALER_ErrorCode ec,
-                                          const json_t *obj);
+struct TALER_MERCHANT_RefundLookupOperation;
+
 
 /**
  * Callback to process a GET /refund request
@@ -58,9 +46,9 @@ typedef void
  */
 typedef void
 (*TALER_MERCHANT_RefundLookupCallback) (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);
 
 /**
  * Does a GET /refund.
@@ -81,6 +69,36 @@ TALER_MERCHANT_refund_lookup (struct GNUNET_CURL_Context 
*ctx,
                               void *cb_cls);
 
 /**
+ * Cancel a GET /refund request.
+ *
+ * @param rlo the refund increasing operation to cancel
+ */
+void
+TALER_MERCHANT_refund_lookup_cancel (struct 
TALER_MERCHANT_RefundLookupOperation *rlo);
+
+
+/**
+ * Handle for a POST /refund operation.
+ */
+struct TALER_MERCHANT_RefundIncreaseOperation;
+
+
+/**
+ * Callback to process a POST /refund request
+ *
+ * @param cls closure
+ * @param http_status HTTP status code for this request
+ * @param ec taler-specific error code
+ * @param obj the response body
+ */
+typedef void
+(*TALER_MERCHANT_RefundIncreaseCallback) (void *cls,
+                                          unsigned int http_status,
+                                          enum TALER_ErrorCode ec,
+                                          const json_t *obj);
+
+
+/**
  * Increase the refund associated to a order
  *
  * @param ctx the CURL context used to connect to the backend
@@ -110,13 +128,6 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context 
*ctx,
 void
 TALER_MERCHANT_refund_increase_cancel (struct 
TALER_MERCHANT_RefundIncreaseOperation *rio);
 
-/**
- * Cancel a GET /refund request.
- *
- * @param rlo the refund increasing operation to cancel
- */
-void
-TALER_MERCHANT_refund_lookup_cancel (struct 
TALER_MERCHANT_RefundLookupOperation *rlo);
 
 /* *********************  /proposal *********************** */
 
@@ -127,11 +138,6 @@ TALER_MERCHANT_refund_lookup_cancel (struct 
TALER_MERCHANT_RefundLookupOperation
 struct TALER_MERCHANT_ProposalOperation;
 
 /**
- * Handle to a GET /proposal operation
- */
-struct TALER_MERCHANT_ProposalLookupOperation;
-
-/**
  * Callbacks of this type are used to serve the result of submitting a
  * /contract request to a merchant.
  *
@@ -155,19 +161,6 @@ typedef void
 
 
 /**
- * Callback called to work a GET /proposal response.
- *
- * @param cls closure
- * @param http_status HTTP status code of the request
- * @param body JSON containing the response's payload.
- * In case of errors, it contains the appropriate error encoding.
- */
-typedef void
-(*TALER_MERCHANT_ProposalLookupOperationCallback) (void *cls,
-                                                   unsigned int http_status,
-                                                   const json_t *body);
-
-/**
  * PUT an order to the backend and receives the related proposal.
  *
  * @param ctx execution context
@@ -197,6 +190,26 @@ TALER_MERCHANT_proposal_cancel (struct 
TALER_MERCHANT_ProposalOperation *po);
 
 
 /**
+ * Handle to a GET /proposal operation
+ */
+struct TALER_MERCHANT_ProposalLookupOperation;
+
+
+/**
+ * Callback called to work a GET /proposal response.
+ *
+ * @param cls closure
+ * @param http_status HTTP status code of the request
+ * @param body JSON containing the response's payload.
+ * In case of errors, it contains the appropriate error encoding.
+ */
+typedef void
+(*TALER_MERCHANT_ProposalLookupOperationCallback) (void *cls,
+                                                   unsigned int http_status,
+                                                   const json_t *body);
+
+
+/**
  * Calls the GET /proposal API at the backend.  That is,
  * retrieve a proposal data by providing its transaction id.
  *
@@ -456,7 +469,8 @@ struct TALER_MERCHANT_TrackTransferHandle;
  * by the exchange for a given h_contract_terms, by _one_ wire
  * transfer.
  */
-struct TALER_MERCHANT_TrackTransferDetails {
+struct TALER_MERCHANT_TrackTransferDetails
+{
 
   /**
    * Total amount paid back by the exchange.
@@ -501,12 +515,14 @@ typedef void
                                          unsigned int details_length,
                                          const struct 
TALER_MERCHANT_TrackTransferDetails *details);
 
+
 /**
  * Request backend to return deposits associated with a given wtid.
  *
  * @param ctx execution context
  * @param backend_uri base URI of the backend
  * @param instance which merchant instance is going to be tracked
+ * @param wire_method wire method used for the wire transfer
  * @param wtid base32 string indicating a wtid
  * @param exchange base URL of the exchange in charge of returning the wanted 
information
  * @param track_transfer_cb the callback to call when a reply for this request 
is available
@@ -517,6 +533,7 @@ struct TALER_MERCHANT_TrackTransferHandle *
 TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
                                const char *backend_uri,
                                const char *instance,
+                              const char *wire_method,
                                const struct TALER_WireTransferIdentifierRawP 
*wtid,
                                const char *exchange_uri,
                                TALER_MERCHANT_TrackTransferCallback 
track_transfer_cb,
diff --git a/src/lib/merchant_api_track_transfer.c 
b/src/lib/merchant_api_track_transfer.c
index f0b6590..660d4e1 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
+  Copyright (C) 2014-2017 GNUnet e.V. and INRIA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Lesser General Public License as published by the Free 
Software
@@ -112,9 +112,8 @@ check_track_transfer_response_ok (struct 
TALER_MERCHANT_TrackTransferHandle *wdh
   num_details = json_array_size (deposits);
   {
     struct TALER_MERCHANT_TrackTransferDetails details[num_details];
-    unsigned int i;
 
-    for (i=0;i<num_details;i++)
+    for (unsigned int i=0;i<num_details;i++)
     {
       struct TALER_MERCHANT_TrackTransferDetails *detail = &details[i];
       json_t *deposit = json_array_get (deposits, i);
@@ -217,6 +216,7 @@ handle_track_transfer_finished (void *cls,
  * @param ctx execution context
  * @param backend_uri base URI of the backend
  * @param instance which merchant instance is going to be tracked
+ * @param wire_method wire method used for the wire transfer
  * @param wtid base32 string indicating a wtid
  * @param exchange_uri base URL of the exchange in charge of returning the 
wanted information
  * @param track_transfer_cb the callback to call when a reply for this request 
is available
@@ -227,6 +227,7 @@ struct TALER_MERCHANT_TrackTransferHandle *
 TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
                                const char *backend_uri,
                                const char *instance,
+                              const char *wire_method,
                                const struct TALER_WireTransferIdentifierRawP 
*wtid,
                                const char *exchange_uri,
                                TALER_MERCHANT_TrackTransferCallback 
track_transfer_cb,
@@ -247,11 +248,12 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context 
*ctx,
   base = MAH_path_to_url_ (backend_uri,
                           "/track/transfer");
   GNUNET_asprintf (&tdo->url,
-                   "%s?wtid=%s&exchange=%s&instance=%s",
+                   "%s?wtid=%s&exchange=%s&instance=%s&wire_method=%s",
                    base,
                    wtid_str,
                    exchange_uri,
-                  instance);
+                  instance,
+                  wire_method);
   GNUNET_free (base);
   GNUNET_free (wtid_str);
   eh = curl_easy_init ();
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 69bc4c3..6f23209 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
+  Copyright (C) 2014-2017 GNUnet e.V. and INRIA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Lesser General Public License as published by the Free 
Software
@@ -26,7 +26,6 @@
 #include <taler/taler_util.h>
 #include <taler/taler_signatures.h>
 #include "taler_merchant_service.h"
-#include "taler-merchant-httpd_refund.h"
 #include "taler_merchantdb_lib.h"
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet/gnunet_curl_lib.h>
@@ -64,7 +63,7 @@
 /**
  * Handle to database.
  */
-struct TALER_MERCHANTDB_Plugin *db;
+static struct TALER_MERCHANTDB_Plugin *db;
 
 /**
  * Configuration handle.
@@ -89,7 +88,7 @@ static char **instances;
 /**
  * How many merchant instances this test runs
  */
-unsigned int ninstances = 0;
+static unsigned int ninstances = 0;
 
 /**
  * Current instance
@@ -99,12 +98,12 @@ static char *instance;
 /**
  * Current instance key
  */
-struct GNUNET_CRYPTO_EddsaPrivateKey *instance_priv;
+static struct GNUNET_CRYPTO_EddsaPrivateKey *instance_priv;
 
 /**
  * Current instance being tested
  */
-unsigned int instance_idx = 0;
+static unsigned int instance_idx = 0;
 
 /**
  * Task run on timeout.
@@ -286,398 +285,395 @@ struct Command
   union
   {
 
-/**
- * Information for a #OC_ADMIN_ADD_INCOMING command.
- */
-struct
-{
-
-  /**
-   * Label to another admin_add_incoming command if we
-   * should deposit into an existing reserve, NULL if
-   * a fresh reserve should be created.
-   */
-  const char *reserve_reference;
-
-  /**
-   * String describing the amount to add to the reserve.
-   */
-  const char *amount;
-
-  /**
-   * Sender's bank account details (JSON).
-   */
-  const char *sender_details;
-
-  /**
-   * Transfer details (JSON)
-   */
-   const char *transfer_details;
-
-  /**
-   * Set (by the interpreter) to the reserve's private key
-   * we used to fill the reserve.
-   */
-  struct TALER_ReservePrivateKeyP reserve_priv;
-
-  /**
-   * Set to the API's handle during the operation.
-   */
-  struct TALER_EXCHANGE_AdminAddIncomingHandle *aih;
-
-} admin_add_incoming;
-
-/**
- * Information for OC_PROPOSAL_LOOKUP command.
- */
-struct
-{
-
-  /**
-   * Reference to the proposal we want to lookup.
-   */
-  const char *proposal_reference;
-
-  struct TALER_MERCHANT_ProposalLookupOperation *plo;
-
-} proposal_lookup;
-
-/**
- * Information for a #OC_WITHDRAW_STATUS command.
- */
-struct
-{
-
-  /**
-   * Label to the #OC_ADMIN_ADD_INCOMING command which
-   * created the reserve.
-   */
-  const char *reserve_reference;
-
-  /**
-   * Set to the API's handle during the operation.
-   */
-  struct TALER_EXCHANGE_ReserveStatusHandle *wsh;
-
-  /**
-   * Expected reserve balance.
-   */
-  const char *expected_balance;
-
-} reserve_status;
-
-/**
- * Information for a #OC_WITHDRAW_SIGN command.
- */
-struct
-{
-
-  /**
-   * Which reserve should we withdraw from?
-   */
-  const char *reserve_reference;
-
-  /**
-   * String describing the denomination value we should withdraw.
-   * A corresponding denomination key must exist in the exchange's
-   * offerings.  Can be NULL if @e pk is set instead.
-   */
-  const char *amount;
-
-  /**
-   * If @e amount is NULL, this specifies the denomination key to
-   * use.  Otherwise, this will be set (by the interpreter) to the
-   * denomination PK matching @e amount.
-   */
-  const struct TALER_EXCHANGE_DenomPublicKey *pk;
-
-  /**
-   * Set (by the interpreter) to the exchange's signature over the
-   * coin's public key.
-   */
-  struct TALER_DenominationSignature sig;
-
-  /**
-   * Set (by the interpreter) to the coin's private key.
-   */
-  struct TALER_CoinSpendPrivateKeyP coin_priv;
-
-  /**
-   * Blinding key used for the operation.
-   */
-  struct TALER_DenominationBlindingKeyP blinding_key;
-
-  /**
-   * Withdraw handle (while operation is running).
-   */
-  struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh;
-
-} reserve_withdraw;
-
-/**
- * Information for an #OC_PROPOSAL command.
- */
-struct
-{
-
-  /**
-   * The order.
-   * It's dynamically generated because we need different transaction_id
-   * for different merchant instances.
-   */
-  char order[ORDER_MAX_SIZE];
-
-  /**
-   * Handle to the active PUT /proposal operation, or NULL.
-   */
-  struct TALER_MERCHANT_ProposalOperation *po;
-
-  /**
-   * Full contract in JSON, set by the /contract operation.
-   * FIXME: verify in the code that this bit is actually proposal
-   * data and not the whole proposal.
-   */
-  json_t *contract_terms;
-
-  /**
-   * Proposal's signature.
-   */
-  struct TALER_MerchantSignatureP merchant_sig;
-
-  /**
-   * Proposal data's hashcode.
-   */
-  struct GNUNET_HashCode hash;
-
-} proposal;
-
-/**
- * Information for a #OC_PAY command.
- * FIXME: support tests where we pay with multiple coins at once.
- */
-struct
-{
-
-  /**
-   * Reference to the contract.
-   */
-  const char *contract_ref;
-
-  /**
-   * ";"-separated list of references to withdrawn coins to be used
-   * in the payment.
-   */
-  char *coin_ref;
-
-  /**
-   * Amount to pay (from the coin, including fee).
-   */
-  const char *amount_with_fee;
-
-  /**
-   * Amount to pay (from the coin, excluding fee).  The sum of the
-   * deltas between all @e amount_with_fee and the @e
-   * amount_without_fee must be less than max_fee, and the sum of
-   * the @e amount_with_fee must be larger than the @e
-   * total_amount.
-   */
-  const char *amount_without_fee;
-
-  /**
-   * Deposit handle while operation is running.
-   */
-  struct TALER_MERCHANT_Pay *ph;
-
-  /**
-   * Hashcode of the proposal data associated to this payment.
-   */
-  struct GNUNET_HashCode h_contract_terms;
-
-  /**
-   * Merchant's public key
-   */
-  struct TALER_MerchantPublicKeyP merchant_pub;
-
-} pay;
-
-struct {
-
-  /**
-   * Process for the aggregator.
-   */
-  struct GNUNET_OS_Process *aggregator_proc;
-
-  /**
-   * ID of task called whenever we get a SIGCHILD.
-   */
-  struct GNUNET_SCHEDULER_Task *child_death_task;
-
-} run_aggregator;
-
-struct {
-
-  /**
-   * Which amount do we expect to see transferred?
-   */
-  const char *amount;
-
-  /**
-   * Which account do we expect to be debited?
-   */
-  uint64_t account_debit;
-
-  /**
-   * Which account do we expect to be credited?
-   */
-  uint64_t account_credit;
-
-  /**
-   * Set (!) to the wire transfer subject observed.
-   */
-  char *subject;
-
-} check_bank_transfer;
-
-struct {
-
-  /**
-   * #OC_CHECK_BANK_TRANSFER command from which we should grab
-   * the WTID.
-   */
-  char *check_bank_ref;
-
-  /**
-   * #OC_PAY command which we expect in the result.
-   * Since we are tracking a bank transaction, we want to know
-   * which (Taler) deposit is associated with the bank
-   * transaction being tracked now.
-   */
-  char *expected_pay_ref;
-
-  /**
-   * Handle to a /track/transfer operation
-   */
-  struct TALER_MERCHANT_TrackTransferHandle *tdo;
-
-} track_transfer;
-
-struct {
-
-  /**
-   * #OC_PAY command from which we should grab
-   * the WTID.
-   */
-  char *pay_ref;
-
-  /**
-   * #OC_CHECK_BANK_TRANSFER command which we expect in the result.
-   */
-  char *expected_transfer_ref;
-
-  /**
-   * Wire fee we expect to pay for this transaction.
-   */
-  const char *wire_fee;
-
-  /**
-   * Handle to a /track/transaction operation
-   */
-  struct TALER_MERCHANT_TrackTransactionHandle *tth;
-
-} track_transaction;
-
-struct {
-  /**
-   * Date we want retrieved transactions younger than
-   */
-  struct GNUNET_TIME_Absolute date;
-
-  /**
-   * How many "rows" we expect in the result
-   */
-  unsigned int nresult;
-
-  /**
-   * Handle to the merchant
-   */
-
-  /**
-   * Handle to /history request
-   */
-  struct TALER_MERCHANT_HistoryOperation *ho;
-
-  /**
-   * The backend will return records with row_id
-   * less than this value.
-   */
-  unsigned int start;
-
-  /**
-   * The backend will return at most `nrows` records.
-   */
-  unsigned int nrows;
-
-} history;
-
-struct {
-  /**
-   * Reference to the order we want reimbursed
-   */
-  char *order_id;
-
-  /**
-   * Handle to a refund increase operation
-   */
-  struct TALER_MERCHANT_RefundIncreaseOperation *rio;
-
-  /**
-   * Amount to refund
-   */
-  const char *refund_amount;
-  
-  /**
-   * Reason for refunding
-   */
-  const char *reason;
+    /**
+     * Information for a #OC_ADMIN_ADD_INCOMING command.
+     */
+    struct
+    {
 
-  /**
-   * Refund fee (MUST match the value given in config)
-   */
-  const char *refund_fee;
+      /**
+       * Label to another admin_add_incoming command if we
+       * should deposit into an existing reserve, NULL if
+       * a fresh reserve should be created.
+       */
+      const char *reserve_reference;
 
-} refund_increase;
+      /**
+       * String describing the amount to add to the reserve.
+       */
+      const char *amount;
 
-struct {
+      /**
+       * Sender's bank account details (JSON).
+       */
+      const char *sender_details;
 
-  /**
-   * Reference to the order whose refund was increased
-   */
-  char *order_id;
+      /**
+       * Transfer details (JSON)
+       */
+      const char *transfer_details;
 
-  /**
-   * Handle to the operation
-   */
-  struct TALER_MERCHANT_RefundLookupOperation *rlo;
+      /**
+       * Set (by the interpreter) to the reserve's private key
+       * we used to fill the reserve.
+       */
+      struct TALER_ReservePrivateKeyP reserve_priv;
+      
+      /**
+       * Set to the API's handle during the operation.
+       */
+      struct TALER_EXCHANGE_AdminAddIncomingHandle *aih;
+      
+    } admin_add_incoming;
 
-  /**
-   * Used to retrieve the asked refund amount.
-   * This information helps the callback to mock a GET /refund
-   * response and match it against what the backend actually
-   * responded.
-   */
-  char *increase_ref;
+    /**
+     * Information for OC_PROPOSAL_LOOKUP command.
+     */
+    struct
+    {
+      
+      /**
+       * Reference to the proposal we want to lookup.
+       */
+      const char *proposal_reference;
+      
+      struct TALER_MERCHANT_ProposalLookupOperation *plo;
+      
+    } proposal_lookup;
+    
+    /**
+     * Information for a #OC_WITHDRAW_STATUS command.
+     */
+    struct
+    {
+      
+      /**
+       * Label to the #OC_ADMIN_ADD_INCOMING command which
+       * created the reserve.
+       */
+      const char *reserve_reference;
+      
+      /**
+       * Set to the API's handle during the operation.
+       */
+      struct TALER_EXCHANGE_ReserveStatusHandle *wsh;
+      
+      /**
+       * Expected reserve balance.
+       */
+      const char *expected_balance;
+      
+    } reserve_status;
+    
+    /**
+     * Information for a #OC_WITHDRAW_SIGN command.
+     */
+    struct
+    {
+      
+      /**
+       * Which reserve should we withdraw from?
+       */
+      const char *reserve_reference;
+      
+      /**
+       * String describing the denomination value we should withdraw.
+       * A corresponding denomination key must exist in the exchange's
+       * offerings.  Can be NULL if @e pk is set instead.
+       */
+      const char *amount;
+      
+      /**
+       * If @e amount is NULL, this specifies the denomination key to
+       * use.  Otherwise, this will be set (by the interpreter) to the
+       * denomination PK matching @e amount.
+       */
+      const struct TALER_EXCHANGE_DenomPublicKey *pk;
+      
+      /**
+       * Set (by the interpreter) to the exchange's signature over the
+       * coin's public key.
+       */
+      struct TALER_DenominationSignature sig;
+      
+      /**
+       * Set (by the interpreter) to the coin's private key.
+       */
+      struct TALER_CoinSpendPrivateKeyP coin_priv;
+      
+      /**
+       * Blinding key used for the operation.
+       */
+      struct TALER_DenominationBlindingKeyP blinding_key;
+      
+      /**
+       * Withdraw handle (while operation is running).
+       */
+      struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh;
+      
+    } reserve_withdraw;
+    
+    /**
+     * Information for an #OC_PROPOSAL command.
+     */
+    struct
+    {
+      
+      /**
+       * The order.
+       * It's dynamically generated because we need different transaction_id
+       * for different merchant instances.
+       */
+      char order[ORDER_MAX_SIZE];
+      
+      /**
+       * Handle to the active PUT /proposal operation, or NULL.
+       */
+      struct TALER_MERCHANT_ProposalOperation *po;
+      
+      /**
+       * Full contract in JSON, set by the /contract operation.
+       * FIXME: verify in the code that this bit is actually proposal
+       * data and not the whole proposal.
+       */
+      json_t *contract_terms;
+      
+      /**
+       * Proposal's signature.
+       */
+      struct TALER_MerchantSignatureP merchant_sig;
+      
+      /**
+       * Proposal data's hashcode.
+       */
+      struct GNUNET_HashCode hash;
+      
+    } proposal;
+    
+    /**
+     * Information for a #OC_PAY command.
+     * FIXME: support tests where we pay with multiple coins at once.
+     */
+    struct
+    {
+      
+      /**
+       * Reference to the contract.
+       */
+      const char *contract_ref;
+      
+      /**
+       * ";"-separated list of references to withdrawn coins to be used
+       * in the payment.
+       */
+      char *coin_ref;
+      
+      /**
+       * Amount to pay (from the coin, including fee).
+       */
+      const char *amount_with_fee;
+      
+      /**
+       * Amount to pay (from the coin, excluding fee).  The sum of the
+       * deltas between all @e amount_with_fee and the @e
+       * amount_without_fee must be less than max_fee, and the sum of
+       * the @e amount_with_fee must be larger than the @e
+       * total_amount.
+       */
+      const char *amount_without_fee;
+      
+      /**
+       * Deposit handle while operation is running.
+       */
+      struct TALER_MERCHANT_Pay *ph;
+      
+      /**
+       * Hashcode of the proposal data associated to this payment.
+       */
+      struct GNUNET_HashCode h_contract_terms;
 
-  /**
-   * Used to retrieve the number and denomination of coins
-   * used to pay for the related contract.
-   * This information helps the callback to mock a GET /refund
-   * response and match it against what the backend actually
-   * responded.
-   */
-  char *pay_ref;
+      /**
+       * Merchant's public key
+       */
+      struct TALER_MerchantPublicKeyP merchant_pub;
+      
+    } pay;
+    
+    struct {
+      
+      /**
+       * Process for the aggregator.
+       */
+      struct GNUNET_OS_Process *aggregator_proc;
+      
+      /**
+       * ID of task called whenever we get a SIGCHILD.
+       */
+      struct GNUNET_SCHEDULER_Task *child_death_task;
+      
+    } run_aggregator;
+    
+    struct {
+      
+      /**
+       * Which amount do we expect to see transferred?
+       */
+      const char *amount;
+      
+      /**
+       * Which account do we expect to be debited?
+       */
+      uint64_t account_debit;
+      
+      /**
+       * Which account do we expect to be credited?
+       */
+      uint64_t account_credit;
+      
+      /**
+       * Set (!) to the wire transfer subject observed.
+       */
+      char *subject;
+      
+    } check_bank_transfer;
+    
+    struct {
+      
+      /**
+       * #OC_CHECK_BANK_TRANSFER command from which we should grab
+       * the WTID.
+       */
+      char *check_bank_ref;
+      
+      /**
+       * #OC_PAY command which we expect in the result.
+       * Since we are tracking a bank transaction, we want to know
+       * which (Taler) deposit is associated with the bank
+       * transaction being tracked now.
+       */
+      char *expected_pay_ref;
+      
+      /**
+       * Handle to a /track/transfer operation
+       */
+      struct TALER_MERCHANT_TrackTransferHandle *tdo;
+      
+    } track_transfer;
+    
+    struct {
+      
+      /**
+       * #OC_PAY command from which we should grab
+       * the WTID.
+       */
+      char *pay_ref;
+      
+      /**
+       * #OC_CHECK_BANK_TRANSFER command which we expect in the result.
+       */
+      char *expected_transfer_ref;
+      
+      /**
+       * Wire fee we expect to pay for this transaction.
+       */
+      const char *wire_fee;
+      
+      /**
+       * Handle to a /track/transaction operation
+       */
+      struct TALER_MERCHANT_TrackTransactionHandle *tth;
+      
+    } track_transaction;
+    
+    struct {
+      
+      /**
+       * Date we want retrieved transactions younger than
+       */
+      struct GNUNET_TIME_Absolute date;
+      
+      /**
+       * How many "rows" we expect in the result
+       */
+      unsigned int nresult;
+      
+      /**
+       * Handle to /history request
+       */
+      struct TALER_MERCHANT_HistoryOperation *ho;
+      
+      /**
+       * The backend will return records with row_id
+       * less than this value.
+       */
+      unsigned int start;
+      
+      /**
+       * The backend will return at most `nrows` records.
+       */
+      unsigned int nrows;
+      
+    } history;
 
-} refund_lookup;
+    struct {
+      /**
+       * Reference to the order we want reimbursed
+       */
+      char *order_id;
+      
+      /**
+       * Handle to a refund increase operation
+       */
+      struct TALER_MERCHANT_RefundIncreaseOperation *rio;
+      
+      /**
+       * Amount to refund
+       */
+      const char *refund_amount;
+      
+      /**
+       * Reason for refunding
+       */
+      const char *reason;
+      
+      /**
+       * Refund fee (MUST match the value given in config)
+       */
+      const char *refund_fee;
+      
+    } refund_increase;
 
+    struct {
+      
+      /**
+       * Reference to the order whose refund was increased
+       */
+      char *order_id;
+      
+      /**
+       * Handle to the operation
+       */
+      struct TALER_MERCHANT_RefundLookupOperation *rlo;
+      
+      /**
+       * Used to retrieve the asked refund amount.
+       * This information helps the callback to mock a GET /refund
+       * response and match it against what the backend actually
+       * responded.
+       */
+      char *increase_ref;
+      
+      /**
+       * Used to retrieve the number and denomination of coins
+       * used to pay for the related contract.
+       * This information helps the callback to mock a GET /refund
+       * response and match it against what the backend actually
+       * responded.
+       */
+      char *pay_ref;
+      
+    } refund_lookup;
+    
   } details;
 
 };
@@ -780,7 +776,6 @@ static const struct Command *
 find_command (const struct InterpreterState *is,
               const char *label)
 {
-  unsigned int i;
   const struct Command *cmd;
 
   if (NULL == label)
@@ -789,7 +784,9 @@ find_command (const struct InterpreterState *is,
                 "Attempt to lookup command for empty label\n");
     return NULL;
   }
-  for (i=0;OC_END != (cmd = &is->commands[i])->oc;i++)
+  for (unsigned int i=0;
+       OC_END != (cmd = &is->commands[i])->oc;
+       i++)
     if ( (NULL != cmd->label) &&
        (0 == strcmp (cmd->label,
                      label)) )
@@ -985,7 +982,6 @@ reserve_status_cb (void *cls,
   struct InterpreterState *is = cls;
   struct Command *cmd = &is->commands[is->ip];
   struct Command *rel;
-  unsigned int i;
   unsigned int j;
   struct TALER_Amount amount;
 
@@ -1005,7 +1001,7 @@ reserve_status_cb (void *cls,
   {
   case MHD_HTTP_OK:
     j = 0;
-    for (i=0;i<is->ip;i++)
+    for (unsigned int i=0;i<is->ip;i++)
     {
       switch ((rel = &is->commands[i])->oc)
       {
@@ -1085,9 +1081,9 @@ reserve_status_cb (void *cls,
     }
     break;
   default:
-  /* Unsupported status code (by test harness) */
-  GNUNET_break (0);
-  break;
+    /* Unsupported status code (by test harness) */
+    GNUNET_break (0);
+    break;
   }
   next_command (is);
 }
@@ -1141,7 +1137,7 @@ reserve_withdraw_cb (void *cls,
       = GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
     break;
   case MHD_HTTP_PAYMENT_REQUIRED:
-  /* nothing to check */
+    /* nothing to check */
     break;
   default:
     /* Unsupported status code (by test harness) */
@@ -1248,6 +1244,7 @@ hashmap_free (void *cls,
   return GNUNET_YES;
 }
 
+
 /**
  * Process GET /refund (increase) response. 
  *
@@ -1281,7 +1278,6 @@ refund_lookup_cb (void *cls,
   const struct Command *increase;
   struct TALER_Amount refund_amount;
  
-
   if (MHD_HTTP_OK != http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1295,47 +1291,57 @@ refund_lookup_cb (void *cls,
   json_array_foreach (obj, index, elem)
   {
     struct TALER_CoinSpendPublicKeyP coin_pub;
-    struct TALER_Amount *irefund_amount = GNUNET_new (struct TALER_Amount);
+    struct TALER_Amount *irefund_amount
+      = GNUNET_new (struct TALER_Amount);
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub),
       TALER_JSON_spec_amount ("refund_amount", irefund_amount),
       GNUNET_JSON_spec_end ()
-  };
+    };
      
-  GNUNET_assert (GNUNET_OK == GNUNET_JSON_parse (elem,
-                                                 spec,
-                                                 &error_name,
-                                                 &error_line));
-  GNUNET_CRYPTO_hash (&coin_pub,
-                      sizeof (struct TALER_CoinSpendPublicKeyP),
-                      &h_coin_pub);
-  
-  GNUNET_assert (GNUNET_OK ==
-    GNUNET_CONTAINER_multihashmap_put (map,
-                                       &h_coin_pub,
-                                       irefund_amount,
-                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 
+    GNUNET_assert (GNUNET_OK ==
+                  GNUNET_JSON_parse (elem,
+                                     spec,
+                                     &error_name,
+                                     &error_line));
+    GNUNET_CRYPTO_hash (&coin_pub,
+                       sizeof (struct TALER_CoinSpendPublicKeyP),
+                       &h_coin_pub);
+    
+    GNUNET_assert (GNUNET_OK ==
+                  GNUNET_CONTAINER_multihashmap_put (map,
+                                                     &h_coin_pub,
+                                                     irefund_amount,
+                                                     
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 
   };
   
   /* Retrieve coins used to pay, from OC_PAY command */
-  GNUNET_assert (NULL != (pay = find_command (is, 
cmd->details.refund_lookup.pay_ref)));
+  GNUNET_assert (NULL != (pay =
+                         find_command (is,
+                                       cmd->details.refund_lookup.pay_ref)));
   icoin_refs = GNUNET_strdup (pay->details.pay.coin_ref);
-  GNUNET_assert (NULL != (icoin_ref = strtok (icoin_refs, ";")));
-  TALER_amount_get_zero ("EUR", &acc);
+  GNUNET_assert (NULL != (icoin_ref =
+                         strtok (icoin_refs, ";")));
+  TALER_amount_get_zero ("EUR",
+                        &acc);
   do
   {
-    GNUNET_assert (NULL != (icoin = find_command (is, icoin_ref)));
+    GNUNET_assert (NULL != (icoin =
+                           find_command (is,
+                                         icoin_ref)));
     GNUNET_CRYPTO_eddsa_key_get_public 
(&icoin->details.reserve_withdraw.coin_priv.eddsa_priv,
                                         &icoin_pub.eddsa_pub);
     GNUNET_CRYPTO_hash (&icoin_pub,
                         sizeof (struct TALER_CoinSpendPublicKeyP),
                         &h_icoin_pub);
-    /*Can be NULL: not all coins are involved in refund*/
-    iamount = GNUNET_CONTAINER_multihashmap_get (map, &h_icoin_pub);
+    /* Can be NULL: not all coins are involved in refund */
+    iamount = GNUNET_CONTAINER_multihashmap_get (map,
+                                                &h_icoin_pub);
     if (NULL != iamount)
-      GNUNET_assert (GNUNET_OK == TALER_amount_add (&acc,
-                                                    &acc,
-                                                    iamount)); 
+      GNUNET_assert (GNUNET_OK ==
+                    TALER_amount_add (&acc,
+                                      &acc,
+                                      iamount)); 
     
     icoin_ref = strtok (NULL, ";");
     if (NULL == icoin_ref)
@@ -1449,8 +1455,11 @@ maint_child_death (void *cls)
   char c[16];
 
   cmd->details.run_aggregator.child_death_task = NULL;
-  pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
-  GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c)));
+  pr = GNUNET_DISK_pipe_handle (sigpipe,
+                               GNUNET_DISK_PIPE_END_READ);
+  GNUNET_break (0 < GNUNET_DISK_file_read (pr,
+                                          &c,
+                                          sizeof (c)));
   GNUNET_OS_process_wait (cmd->details.run_aggregator.aggregator_proc);
   GNUNET_OS_process_destroy (cmd->details.run_aggregator.aggregator_proc);
   cmd->details.run_aggregator.aggregator_proc = NULL;
@@ -1577,14 +1586,14 @@ static const struct TALER_EXCHANGE_DenomPublicKey *
 find_pk (const struct TALER_EXCHANGE_Keys *keys,
          const struct TALER_Amount *amount)
 {
-  unsigned int i;
   struct GNUNET_TIME_Absolute now;
-  struct TALER_EXCHANGE_DenomPublicKey *pk;
   char *str;
 
   now = GNUNET_TIME_absolute_get ();
-  for (i=0;i<keys->num_denom_keys;i++)
+  for (unsigned int i=0;i<keys->num_denom_keys;i++)
   {
+    const struct TALER_EXCHANGE_DenomPublicKey *pk;
+    
     pk = &keys->denom_keys[i];
     if ( (0 == TALER_amount_cmp (amount,
                                  &pk->value)) &&
@@ -1594,8 +1603,10 @@ find_pk (const struct TALER_EXCHANGE_Keys *keys,
   }
   /* do 2nd pass to check if expiration times are to blame for failure */
   str = TALER_amount_to_string (amount);
-  for (i=0;i<keys->num_denom_keys;i++)
+  for (unsigned int i=0;i<keys->num_denom_keys;i++)
   {
+    const struct TALER_EXCHANGE_DenomPublicKey *pk;
+
     pk = &keys->denom_keys[i];
     if ( (0 == TALER_amount_cmp (amount,
                                  &pk->value)) &&
@@ -1841,7 +1852,9 @@ interpreter_run (void *cls)
       const char *order_id;
 
       GNUNET_assert (NULL != cmd->details.proposal_lookup.proposal_reference);
-      GNUNET_assert (NULL != (ref = find_command (is, 
cmd->details.proposal_lookup.proposal_reference)));
+      GNUNET_assert (NULL != (ref =
+                             find_command (is,
+                                           
cmd->details.proposal_lookup.proposal_reference)));
 
       order_id = json_string_value (json_object_get 
(ref->details.proposal.contract_terms,
                                     "order_id"));
@@ -1864,7 +1877,8 @@ interpreter_run (void *cls)
         cmd->details.admin_add_incoming.reserve_reference)
     {
       GNUNET_assert (NULL != (ref
-        = find_command (is, 
cmd->details.admin_add_incoming.reserve_reference)));
+        = find_command (is,
+                       cmd->details.admin_add_incoming.reserve_reference)));
       GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
       cmd->details.admin_add_incoming.reserve_priv
         = ref->details.admin_add_incoming.reserve_priv;
@@ -1977,19 +1991,15 @@ interpreter_run (void *cls)
     json_t *order;
     json_error_t error;
     struct GNUNET_TIME_Absolute timestamp;
-    char *date;
   
     GNUNET_assert (NULL != (order = json_loads (cmd->details.proposal.order,
                                                 JSON_REJECT_DUPLICATES,
                                                 &error)));
-
     timestamp = GNUNET_TIME_absolute_get ();
-    GNUNET_asprintf (&date,
-                     "/Date(%llu)/",
-                     timestamp.abs_value_us / 1000LL / 1000LL);
+    (void) GNUNET_TIME_round_abs (&timestamp);
     json_object_set_new (order,
                          "timestamp",
-                         json_string (date));
+                         GNUNET_JSON_from_time_abs (timestamp));
     if (NULL != instance)
     {
       json_t *merchant;
@@ -2041,7 +2051,7 @@ interpreter_run (void *cls)
     merchant_sig = ref->details.proposal.merchant_sig;
     GNUNET_assert (NULL != ref->details.proposal.contract_terms);
     {
-      /* Get information that need to be replied in the deposit permission */
+      /* Get information that needs to be replied in the deposit permission */
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_string ("order_id", &order_id),
         GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
@@ -2207,6 +2217,7 @@ interpreter_run (void *cls)
           = TALER_MERCHANT_track_transfer (ctx,
                                            MERCHANT_URI,
                                            instance,
+                                          "test",
                                            &wtid,
                                            EXCHANGE_URI,
                                            &track_transfer_cb,
@@ -2479,6 +2490,7 @@ run (void *cls)
       .details.reserve_status.reserve_reference
         = "create-reserve-1",
       .details.reserve_status.expected_balance = "EUR:0" },
+    
     /* Create proposal */
     { .oc = OC_PROPOSAL,
       .label = "create-proposal-1",
@@ -2490,7 +2502,7 @@ run (void *cls)
            \"fraction\":50000000},\
         \"order_id\":\"1\",\
         \"refund_deadline\":\"\\/Date(0)\\/\",\
-        \"pay_deadline\":\"\\/Date(9999999999)\\/\",\
+        \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
         \"amount\":\
           {\"currency\":\"EUR\",\
            \"value\":5,\
@@ -2499,6 +2511,8 @@ run (void *cls)
         \"products\":\
           [ {\"description\":\"ice cream\",\
              \"value\":\"{EUR:5}\"} ] }"},
+
+    /* execute simple payment */
     { .oc = OC_PAY,
       .label = "deposit-simple",
       .expected_response_code = MHD_HTTP_OK,
@@ -2506,6 +2520,7 @@ run (void *cls)
       .details.pay.coin_ref = "withdraw-coin-1;withdraw-coin-2",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
+
     /* Try to replay payment reusing coin */
     { .oc = OC_PAY,
       .label = "replay-simple",
@@ -2514,6 +2529,7 @@ run (void *cls)
       .details.pay.coin_ref = "withdraw-coin-1",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
+
     /* Create another contract */
     { .oc = OC_PROPOSAL,
       .label = "create-proposal-2",
@@ -2545,6 +2561,7 @@ run (void *cls)
       .details.pay.coin_ref = "withdraw-coin-1",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
+    
     /* Fill second reserve with EUR:1 */
     { .oc = OC_ADMIN_ADD_INCOMING,
       .label = "create-reserve-2",
@@ -2592,13 +2609,12 @@ run (void *cls)
     /* Check nothing happened on the bank side so far */
     { .oc = OC_CHECK_BANK_TRANSFERS_EMPTY,
       .label = "check_bank_empty" },
-    
-    
+        
     /* Run transfers. */
     { .oc = OC_RUN_AGGREGATOR,
       .label = "run-aggregator" },
     
-    /* Obtain WTID of the transfer */
+    /* Obtain WTID of the transfer generated by "deposit-simple" */
     { .oc = OC_CHECK_BANK_TRANSFER,
       .label = "check_bank_transfer-498c",
       .details.check_bank_transfer.amount = "EUR:4.98",
@@ -2618,7 +2634,7 @@ run (void *cls)
       .details.track_transaction.expected_transfer_ref
         = "check_bank_transfer-498c",
       .details.track_transaction.pay_ref = "deposit-simple",
-      .details.track_transaction.wire_fee = "EUR:0.01",
+      .details.track_transaction.wire_fee = "EUR:0.01"
     },
     
     /* Trace the WTID back to the original transaction */
diff --git a/src/lib/test_merchant_api.conf b/src/lib/test_merchant_api.conf
index 5e72ed0..a01c4e0 100644
--- a/src/lib/test_merchant_api.conf
+++ b/src/lib/test_merchant_api.conf
@@ -21,8 +21,7 @@ PORT = 8082
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
-# FIXME: EDATE is a bit short, 'execution_delay'?
-EDATE = 3 week
+WIRE_TRANSFER_DELAY = 0 s
 
 # Which plugin (backend) do we use for the DB.
 DB = postgres

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



reply via email to

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