gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (e62708f -> f6633b5)


From: gnunet
Subject: [taler-merchant] branch master updated (e62708f -> f6633b5)
Date: Sat, 02 Nov 2019 23:09:55 +0100

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

grothoff pushed a change to branch master
in repository merchant.

    from e62708f  also propage timeout into curl
     new 5acd586  simplify structure
     new f6633b5  simplify structure

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/taler_merchant_testing_lib.h           |  40 +-
 src/lib/Makefile.am                                |  14 +-
 src/lib/merchant_api_poll_payment.c                |   2 +-
 src/lib/testing_api_cmd_refund.c                   | 636 ---------------------
 src/lib/testing_api_cmd_refund_increase.c          | 234 ++++++++
 src/lib/testing_api_cmd_tip_authorize.c            | 375 ++++++++++++
 ..._api_cmd_tip.c => testing_api_cmd_tip_pickup.c} | 611 +-------------------
 src/lib/testing_api_cmd_tip_query.c                | 297 ++++++++++
 src/lib/testing_api_cmd_track_transaction.c        | 298 ++++++++++
 ...md_track.c => testing_api_cmd_track_transfer.c} | 272 +--------
 10 files changed, 1256 insertions(+), 1523 deletions(-)
 delete mode 100644 src/lib/testing_api_cmd_refund.c
 create mode 100644 src/lib/testing_api_cmd_refund_increase.c
 create mode 100644 src/lib/testing_api_cmd_tip_authorize.c
 rename src/lib/{testing_api_cmd_tip.c => testing_api_cmd_tip_pickup.c} (51%)
 create mode 100644 src/lib/testing_api_cmd_tip_query.c
 create mode 100644 src/lib/testing_api_cmd_track_transaction.c
 rename src/lib/{testing_api_cmd_track.c => testing_api_cmd_track_transfer.c} 
(58%)

diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index ac9ae6f..5583062 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -109,9 +109,43 @@ TALER_TESTING_cmd_proposal_lookup (const char *label,
  * @param http_status expected HTTP response code.
  * @param proposal_reference the proposal whose payment status
  *        is going to be checked.
- * @param expect_paid GNUNET_YES if we expect the proposal to be
- *        paid, GNUNET_NO otherwise.
+ * @param expect_paid #GNUNET_YES if we expect the proposal to be
+ *        paid, #GNUNET_NO otherwise.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_check_payment (const char *label,
+                                 const char *merchant_url,
+                                 unsigned int http_status,
+                                 const char *proposal_reference,
+                                 unsigned int expect_paid);
+
+/**
+ * Start a long-polled "poll-payment" test command.
+ *
+ * @param label command label.
+ * @param merchant_url merchant base url
+ * @param proposal_reference the proposal whose payment status
+ *        is going to be checked.
+ * @param timeout which timeout to use
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_poll_payment_start (const char *label,
+                                      const char *merchant_url,
+                                      const char *proposal_reference,
+                                      struct GNUNET_TIME_Relative timeout);
+
+
+/**
+ * Expect completion of a long-polled "poll payment" test command.
  *
+ * @param label command label.
+ * @param poll_start_reference payment start operation that should have
+ *                   completed
+ * @param http_status expected HTTP response code.
+ * @param expect_paid #GNUNET_YES if we expect the proposal to be
+ *        paid, #GNUNET_NO otherwise.
  * @return the command
  */
 struct TALER_TESTING_Command
@@ -121,6 +155,7 @@ TALER_TESTING_cmd_check_payment (const char *label,
                                  const char *proposal_reference,
                                  unsigned int expect_paid);
 
+
 /**
  * Make a "pay" test command.
  *
@@ -135,7 +170,6 @@ TALER_TESTING_cmd_check_payment (const char *label,
  *        fee
  * @param amount_without_fee amount to pay, no fees included.
  * @param refund_fee fee for refunding this payment.
- *
  * @return the command
  */
 struct TALER_TESTING_Command
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 3d54d68..439a48a 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -42,13 +42,17 @@ libtalermerchant_la_LIBADD = \
   $(XLIB)
 
 libtalermerchanttesting_la_SOURCES = \
-  testing_api_cmd_proposal.c \
-  testing_api_cmd_pay.c \
-  testing_api_cmd_refund.c \
-  testing_api_cmd_tip.c \
-  testing_api_cmd_track.c \
   testing_api_cmd_history.c \
+  testing_api_cmd_pay.c \
+  testing_api_cmd_proposal.c \
+  testing_api_cmd_refund_increase.c \
+  testing_api_cmd_refund_lookup.c \
   testing_api_cmd_rewind.c \
+  testing_api_cmd_tip_authorize.c \
+  testing_api_cmd_tip_pickup.c \
+  testing_api_cmd_tip_query.c \
+  testing_api_cmd_track_transaction.c \
+  testing_api_cmd_track_transfer.c \
   testing_api_helpers.c \
   testing_api_trait_merchant_sig.c \
   testing_api_trait_string.c \
diff --git a/src/lib/merchant_api_poll_payment.c 
b/src/lib/merchant_api_poll_payment.c
index 069c5b7..e89948e 100644
--- a/src/lib/merchant_api_poll_payment.c
+++ b/src/lib/merchant_api_poll_payment.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2018 GNUnet e.V. and INRIA
+  Copyright (C) 2018, 2019 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
diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c
deleted file mode 100644
index f592f6a..0000000
--- a/src/lib/testing_api_cmd_refund.c
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
-  This file is part of TALER
-  Copyright (C) 2014-2018 Taler Systems SA
-
-  TALER is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as
-  published by the Free Software Foundation; either version 3, or
-  (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public
-  License along with TALER; see the file COPYING.  If not, see
-  <http://www.gnu.org/licenses/>
-*/
-
-/**
- * @file lib/testing_api_cmd_refund.c
- * @brief command to test refunds.
- * @author Marcello Stanisci
- */
-
-#include "platform.h"
-#include <taler/taler_exchange_service.h>
-#include <taler/taler_testing_lib.h>
-#include "taler_merchant_service.h"
-#include "taler_merchant_testing_lib.h"
-
-
-/**
- * State for a "refund increase" CMD.
- */
-struct RefundIncreaseState
-{
-  /**
-   * Operation handle for a POST /refund request.
-   */
-  struct TALER_MERCHANT_RefundIncreaseOperation *rio;
-
-  /**
-   * Base URL of the merchant serving the request.
-   */
-  const char *merchant_url;
-
-  /**
-   * Order id of the contract to refund.
-   */
-  const char *order_id;
-
-  /**
-   * The amount to refund.
-   */
-  const char *refund_amount;
-
-  /**
-   * Refund fee.
-   */
-  const char *refund_fee;
-
-  /**
-   * Human-readable justification for the refund.
-   */
-  const char *reason;
-
-  /**
-   * Interpreter state.
-   */
-  struct TALER_TESTING_Interpreter *is;
-
-  /**
-   * Expected HTTP response code.
-   */
-  unsigned int http_code;
-};
-
-
-/**
- * State for a "refund lookup" CMD.
- */
-struct RefundLookupState
-{
-  /**
-   * Operation handle for a GET /public/refund request.
-   */
-  struct TALER_MERCHANT_RefundLookupOperation *rlo;
-
-  /**
-   * Base URL of the merchant serving the request.
-   */
-  const char *merchant_url;
-
-  /**
-   * Order id to look up.
-   */
-  const char *order_id;
-
-  /**
-   * Reference to a "pay" CMD, used to double-check if
-   * refunded coins were actually spent:
-   */
-  const char *pay_reference;
-
-  /**
-   * Reference to a "refund increase" CMD that offer
-   * the expected amount to be refunded; can be NULL.
-   */
-  const char *increase_reference;
-
-  /**
-   * Expected HTTP response code.
-   */
-  unsigned int http_code;
-
-  /**
-   * Interpreter state.
-   */
-  struct TALER_TESTING_Interpreter *is;
-
-  /**
-   * Explicit amount to be refunded, must be defined if @a
-   * increase_reference is NULL.
-   */
-  const char *refund_amount;
-};
-
-
-/**
- * Free the state of a "refund increase" CMD, and
- * possibly cancel a pending "refund increase" operation.
- *
- * @param cls closure
- * @param cmd command currently being freed.
- */
-static void
-refund_increase_cleanup (void *cls,
-                         const struct TALER_TESTING_Command *cmd)
-{
-  struct RefundIncreaseState *ris = cls;
-
-  if (NULL != ris->rio)
-  {
-    TALER_LOG_WARNING ("Refund-increase operation"
-                       " did not complete\n");
-    TALER_MERCHANT_refund_increase_cancel (ris->rio);
-  }
-  GNUNET_free (ris);
-}
-
-
-/**
- * Free the state of a "refund lookup" CMD, and
- * possibly cancel a pending "refund lookup" operation.
- *
- * @param cls closure
- * @param cmd command currently being freed.
- */
-static void
-refund_lookup_cleanup (void *cls,
-                       const struct TALER_TESTING_Command *cmd)
-{
-  struct RefundLookupState *rls = cls;
-
-  if (NULL != rls->rlo)
-  {
-    TALER_LOG_WARNING ("Refund-lookup operation"
-                       " did not complete\n");
-    TALER_MERCHANT_refund_lookup_cancel (rls->rlo);
-  }
-  GNUNET_free (rls);
-}
-
-
-/**
- * Process POST /refund (increase) response; just checking
- * if the HTTP response code is the one expected.
- *
- * @param cls closure
- * @param http_status HTTP status code
- * @param ec taler-specific error object
- * @param obj response body; is NULL on success.
- */
-static void
-refund_increase_cb (void *cls,
-                    unsigned int http_status,
-                    enum TALER_ErrorCode ec,
-                    const json_t *obj)
-{
-  struct RefundIncreaseState *ris = cls;
-
-  ris->rio = NULL;
-  if (ris->http_code != http_status)
-    TALER_TESTING_FAIL (ris->is);
-
-  TALER_TESTING_interpreter_next (ris->is);
-}
-
-
-/**
- * Run the "refund increase" CMD.
- *
- * @param cls closure.
- * @param cmd command currently being run.
- * @param is the interpreter state.
- */
-static void
-refund_increase_run (void *cls,
-                     const struct TALER_TESTING_Command *cmd,
-                     struct TALER_TESTING_Interpreter *is)
-{
-  struct RefundIncreaseState *ris = cls;
-  struct TALER_Amount refund_amount;
-
-  ris->is = is;
-  if (GNUNET_OK != TALER_string_to_amount (ris->refund_amount,
-                                           &refund_amount))
-    TALER_TESTING_FAIL (is);
-  ris->rio = TALER_MERCHANT_refund_increase (is->ctx,
-                                             ris->merchant_url,
-                                             ris->order_id,
-                                             &refund_amount,
-                                             ris->reason,
-                                             &refund_increase_cb,
-                                             ris);
-  GNUNET_assert (NULL != ris->rio);
-}
-
-
-/**
- * Callback that frees all the elements in the hashmap
- *
- * @param cls closure, NULL
- * @param key current key
- * @param value a `struct TALER_Amount`
- *
- * @return always #GNUNET_YES (continue to iterate)
- */
-static int
-hashmap_free (void *cls,
-              const struct GNUNET_HashCode *key,
-              void *value)
-{
-  struct TALER_Amount *refund_amount = value;
-
-  GNUNET_free (refund_amount);
-  return GNUNET_YES;
-}
-
-
-/**
- * Process "GET /public/refund" (lookup) response;
- * mainly checking if the refunded amount matches the
- * expectation.
- *
- * @param cls closure
- * @param http_status HTTP status code
- * @param ec taler-specific error object
- * @param obj response body; is NULL on error.
- */
-static void
-refund_lookup_cb (void *cls,
-                  unsigned int http_status,
-                  enum TALER_ErrorCode ec,
-                  const json_t *obj)
-{
-  struct RefundLookupState *rls = cls;
-  struct GNUNET_CONTAINER_MultiHashMap *map;
-  size_t index;
-  json_t *elem;
-  const char *error_name;
-  unsigned int error_line;
-  struct GNUNET_HashCode h_coin_pub;
-  const char *coin_reference;
-  char *coin_reference_dup;
-  const char *icoin_reference;
-  const struct TALER_TESTING_Command *pay_cmd;
-  const struct TALER_TESTING_Command *increase_cmd;
-  const char *refund_amount;
-  struct TALER_Amount acc;
-  struct TALER_Amount ra;
-  const json_t *arr;
-
-  rls->rlo = NULL;
-  if (rls->http_code != http_status)
-    TALER_TESTING_FAIL (rls->is);
-
-  arr = json_object_get (obj, "refund_permissions");
-  if (NULL == arr)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Tolerating a refund permission not found\n");
-    TALER_TESTING_interpreter_next (rls->is);
-    return;
-  }
-  map = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
-
-  /* Put in array every refunded coin.  */
-  json_array_foreach (arr, index, elem)
-  {
-    struct TALER_CoinSpendPublicKeyP coin_pub;
-    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, // which
-                     irefund_amount, // how much
-                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-  };
-
-  /* Compare spent coins with refunded, and if they match,
-   * increase an accumulator.  */
-  if (NULL ==
-      (pay_cmd = TALER_TESTING_interpreter_lookup_command
-                   (rls->is, rls->pay_reference)))
-    TALER_TESTING_FAIL (rls->is);
-
-  if (GNUNET_OK != TALER_TESTING_get_trait_coin_reference
-        (pay_cmd, 0, &coin_reference))
-    TALER_TESTING_FAIL (rls->is);
-
-  GNUNET_assert (GNUNET_OK == TALER_amount_get_zero ("EUR",
-                                                     &acc));
-  coin_reference_dup = GNUNET_strdup (coin_reference);
-  for (icoin_reference = strtok (coin_reference_dup, ";");
-       NULL != icoin_reference;
-       icoin_reference = strtok (NULL, ";"))
-  {
-    const struct TALER_CoinSpendPrivateKeyP *icoin_priv;
-    struct TALER_CoinSpendPublicKeyP icoin_pub;
-    struct GNUNET_HashCode h_icoin_pub;
-    struct TALER_Amount *iamount;
-    const struct TALER_TESTING_Command *icoin_cmd;
-
-    if (NULL ==
-        (icoin_cmd = TALER_TESTING_interpreter_lookup_command
-                       (rls->is, icoin_reference)) )
-    {
-      GNUNET_break (0);
-      TALER_LOG_ERROR ("Bad reference `%s'\n",
-                       icoin_reference);
-      TALER_TESTING_interpreter_fail (rls->is);
-      GNUNET_CONTAINER_multihashmap_destroy (map);
-      return;
-    }
-
-    if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
-          (icoin_cmd, 0, &icoin_priv))
-    {
-      GNUNET_break (0);
-      TALER_LOG_ERROR ("Command `%s' failed to give coin"
-                       " priv trait\n",
-                       icoin_reference);
-      TALER_TESTING_interpreter_fail (rls->is);
-      GNUNET_CONTAINER_multihashmap_destroy (map);
-      return;
-    }
-
-    GNUNET_CRYPTO_eddsa_key_get_public (&icoin_priv->eddsa_priv,
-                                        &icoin_pub.eddsa_pub);
-    GNUNET_CRYPTO_hash (&icoin_pub,
-                        sizeof (struct TALER_CoinSpendPublicKeyP),
-                        &h_icoin_pub);
-
-    iamount = GNUNET_CONTAINER_multihashmap_get
-                (map, &h_icoin_pub);
-
-    /* Can be NULL: not all coins are involved in refund */
-    if (NULL == iamount)
-      continue;
-
-    GNUNET_assert (GNUNET_OK == TALER_amount_add (&acc,
-                                                  &acc,
-                                                  iamount));
-  }
-
-  GNUNET_free (coin_reference_dup);
-
-  if (NULL !=
-      (increase_cmd = TALER_TESTING_interpreter_lookup_command
-                        (rls->is, rls->increase_reference)))
-  {
-    if (GNUNET_OK != TALER_TESTING_get_trait_amount
-          (increase_cmd, 0, &refund_amount))
-      TALER_TESTING_FAIL (rls->is);
-
-    if (GNUNET_OK != TALER_string_to_amount
-          (refund_amount, &ra))
-      TALER_TESTING_FAIL (rls->is);
-  }
-  else
-  {
-    GNUNET_assert (NULL != rls->refund_amount);
-
-    if (GNUNET_OK != TALER_string_to_amount
-          (rls->refund_amount, &ra))
-      TALER_TESTING_FAIL (rls->is);
-  }
-
-  GNUNET_CONTAINER_multihashmap_iterate (map,
-                                         &hashmap_free,
-                                         NULL);
-  GNUNET_CONTAINER_multihashmap_destroy (map);
-
-  /* Check that what the backend claims to have been refunded
-   * actually matches _our_ refund expectation.  */
-  if (0 != TALER_amount_cmp (&acc,
-                             &ra))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Incomplete refund: expected '%s', got '%s'\n",
-                TALER_amount_to_string (&ra),
-                TALER_amount_to_string (&acc));
-    TALER_TESTING_interpreter_fail (rls->is);
-    return;
-  }
-
-  TALER_TESTING_interpreter_next (rls->is);
-}
-
-
-/**
- * Run the "refund lookup" CMD.
- *
- * @param cls closure.
- * @param cmd command being currently run.
- * @param is interpreter state.
- */
-static void
-refund_lookup_run (void *cls,
-                   const struct TALER_TESTING_Command *cmd,
-                   struct TALER_TESTING_Interpreter *is)
-{
-  struct RefundLookupState *rls = cls;
-
-  rls->is = is;
-  rls->rlo = TALER_MERCHANT_refund_lookup (is->ctx,
-                                           rls->merchant_url,
-                                           rls->order_id,
-                                           &refund_lookup_cb,
-                                           rls);
-  GNUNET_assert (NULL != rls->rlo);
-}
-
-
-/**
- * Offer internal data from the "refund increase" CMD
- * state to other commands.
- *
- * @param cls closure
- * @param ret[out] result (could be anything)
- * @param trait name of the trait
- * @param index index number of the object to extract.
- * @return #GNUNET_OK on success
- */
-static int
-refund_increase_traits (void *cls,
-                        const void **ret,
-                        const char *trait,
-                        unsigned int index)
-{
-  struct RefundIncreaseState *ris = cls;
-
-  struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_amount (0, ris->refund_amount),
-    TALER_TESTING_trait_end ()
-  };
-
-  return TALER_TESTING_get_trait (traits,
-                                  ret,
-                                  trait,
-                                  index);
-
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Define a "refund increase" CMD.
- *
- * @param label command label.
- * @param merchant_url base URL of the backend serving the
- *        "refund increase" request.
- * @param reason refund justification, human-readable.
- * @param order_id order id of the contract to refund.
- * @param refund_amount amount to be refund-increased.
- * @param refund_fee refund fee.
- * @param http_code expected HTTP response code.
- *
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_refund_increase
-  (const char *label,
-  const char *merchant_url,
-  const char *reason,
-  const char *order_id,
-  const char *refund_amount,
-  const char *refund_fee,
-  unsigned int http_code)
-{
-  struct RefundIncreaseState *ris;
-
-  ris = GNUNET_new (struct RefundIncreaseState);
-  ris->merchant_url = merchant_url;
-  ris->order_id = order_id;
-  ris->refund_amount = refund_amount;
-  ris->refund_fee = refund_fee;
-  ris->reason = reason;
-  ris->http_code = http_code;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = ris,
-    .label = label,
-    .run = &refund_increase_run,
-    .cleanup = &refund_increase_cleanup,
-    .traits = &refund_increase_traits
-  };
-
-  return cmd;
-}
-
-
-/**
- * Define a "refund lookup" CMD.
- *
- * @param label command label.
- * @param merchant_url base URL of the merchant serving the
- *        "refund lookup" request.
- * @param increase_reference reference to a "refund increase" CMD
- *        that will offer the amount to check the looked up refund
- *        against.  Must NOT be NULL.
- * @param pay_reference reference to the "pay" CMD whose coins got
- *        refunded.  It is used to double-check if the refunded
- *        coins were actually spent in the first place.
- * @param order_id order id whose refund status is to be looked up.
- * @param http_code expected HTTP response code.
- *
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_refund_lookup
-  (const char *label,
-  const char *merchant_url,
-  const char *increase_reference,
-  const char *pay_reference,
-  const char *order_id,
-  unsigned int http_code)
-{
-  struct RefundLookupState *rls;
-
-  rls = GNUNET_new (struct RefundLookupState);
-  rls->merchant_url = merchant_url;
-  rls->order_id = order_id;
-  rls->pay_reference = pay_reference;
-  rls->increase_reference = increase_reference;
-  rls->http_code = http_code;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = rls,
-    .label = label,
-    .run = &refund_lookup_run,
-    .cleanup = &refund_lookup_cleanup
-  };
-
-  return cmd;
-}
-
-
-/**
- * Define a "refund lookup" CMD, equipped with a expected refund
- * amount.
- *
- * @param label command label.
- * @param merchant_url base URL of the merchant serving the
- *        "refund lookup" request.
- * @param increase_reference reference to a "refund increase" CMD
- *        that will offer the amount to check the looked up refund
- *        against.  Can be NULL, takes precedence over @a
- *        refund_amount.
- * @param pay_reference reference to the "pay" CMD whose coins got
- *        refunded.  It is used to double-check if the refunded
- *        coins were actually spent in the first place.
- * @param order_id order id whose refund status is to be looked up.
- * @param http_code expected HTTP response code.
- * @param refund_amount expected refund amount.  Must be defined
- *        if @a increase_reference is NULL.
- *
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_refund_lookup_with_amount
-  (const char *label,
-  const char *merchant_url,
-  const char *increase_reference,
-  const char *pay_reference,
-  const char *order_id,
-  unsigned int http_code,
-  const char *refund_amount)
-{
-  struct RefundLookupState *rls;
-
-  rls = GNUNET_new (struct RefundLookupState);
-  rls->merchant_url = merchant_url;
-  rls->order_id = order_id;
-  rls->pay_reference = pay_reference;
-  rls->increase_reference = increase_reference;
-  rls->http_code = http_code;
-  rls->refund_amount = refund_amount;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = rls,
-    .label = label,
-    .run = &refund_lookup_run,
-    .cleanup = &refund_lookup_cleanup
-  };
-
-  return cmd;
-}
-
-
-/* end of testing_api_cmd_refund.c */
diff --git a/src/lib/testing_api_cmd_refund_increase.c 
b/src/lib/testing_api_cmd_refund_increase.c
new file mode 100644
index 0000000..1852745
--- /dev/null
+++ b/src/lib/testing_api_cmd_refund_increase.c
@@ -0,0 +1,234 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014-2018 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 3, or
+  (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public
+  License along with TALER; see the file COPYING.  If not, see
+  <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file lib/testing_api_cmd_refund_increase.c
+ * @brief command to test refunds.
+ * @author Marcello Stanisci
+ */
+
+#include "platform.h"
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_testing_lib.h>
+#include "taler_merchant_service.h"
+#include "taler_merchant_testing_lib.h"
+
+
+/**
+ * State for a "refund increase" CMD.
+ */
+struct RefundIncreaseState
+{
+  /**
+   * Operation handle for a POST /refund request.
+   */
+  struct TALER_MERCHANT_RefundIncreaseOperation *rio;
+
+  /**
+   * Base URL of the merchant serving the request.
+   */
+  const char *merchant_url;
+
+  /**
+   * Order id of the contract to refund.
+   */
+  const char *order_id;
+
+  /**
+   * The amount to refund.
+   */
+  const char *refund_amount;
+
+  /**
+   * Refund fee.
+   */
+  const char *refund_fee;
+
+  /**
+   * Human-readable justification for the refund.
+   */
+  const char *reason;
+
+  /**
+   * Interpreter state.
+   */
+  struct TALER_TESTING_Interpreter *is;
+
+  /**
+   * Expected HTTP response code.
+   */
+  unsigned int http_code;
+};
+
+
+/**
+ * Free the state of a "refund increase" CMD, and
+ * possibly cancel a pending "refund increase" operation.
+ *
+ * @param cls closure
+ * @param cmd command currently being freed.
+ */
+static void
+refund_increase_cleanup (void *cls,
+                         const struct TALER_TESTING_Command *cmd)
+{
+  struct RefundIncreaseState *ris = cls;
+
+  if (NULL != ris->rio)
+  {
+    TALER_LOG_WARNING ("Refund-increase operation"
+                       " did not complete\n");
+    TALER_MERCHANT_refund_increase_cancel (ris->rio);
+  }
+  GNUNET_free (ris);
+}
+
+
+/**
+ * Process POST /refund (increase) response; just checking
+ * if the HTTP response code is the one expected.
+ *
+ * @param cls closure
+ * @param http_status HTTP status code
+ * @param ec taler-specific error object
+ * @param obj response body; is NULL on success.
+ */
+static void
+refund_increase_cb (void *cls,
+                    unsigned int http_status,
+                    enum TALER_ErrorCode ec,
+                    const json_t *obj)
+{
+  struct RefundIncreaseState *ris = cls;
+
+  ris->rio = NULL;
+  if (ris->http_code != http_status)
+    TALER_TESTING_FAIL (ris->is);
+
+  TALER_TESTING_interpreter_next (ris->is);
+}
+
+
+/**
+ * Run the "refund increase" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command currently being run.
+ * @param is the interpreter state.
+ */
+static void
+refund_increase_run (void *cls,
+                     const struct TALER_TESTING_Command *cmd,
+                     struct TALER_TESTING_Interpreter *is)
+{
+  struct RefundIncreaseState *ris = cls;
+  struct TALER_Amount refund_amount;
+
+  ris->is = is;
+  if (GNUNET_OK != TALER_string_to_amount (ris->refund_amount,
+                                           &refund_amount))
+    TALER_TESTING_FAIL (is);
+  ris->rio = TALER_MERCHANT_refund_increase (is->ctx,
+                                             ris->merchant_url,
+                                             ris->order_id,
+                                             &refund_amount,
+                                             ris->reason,
+                                             &refund_increase_cb,
+                                             ris);
+  GNUNET_assert (NULL != ris->rio);
+}
+
+
+/**
+ * Offer internal data from the "refund increase" CMD
+ * state to other commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param index index number of the object to extract.
+ * @return #GNUNET_OK on success
+ */
+static int
+refund_increase_traits (void *cls,
+                        const void **ret,
+                        const char *trait,
+                        unsigned int index)
+{
+  struct RefundIncreaseState *ris = cls;
+  struct TALER_TESTING_Trait traits[] = {
+    TALER_TESTING_make_trait_amount (0, ris->refund_amount),
+    TALER_TESTING_trait_end ()
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
+
+/**
+ * Define a "refund increase" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend serving the
+ *        "refund increase" request.
+ * @param reason refund justification, human-readable.
+ * @param order_id order id of the contract to refund.
+ * @param refund_amount amount to be refund-increased.
+ * @param refund_fee refund fee.
+ * @param http_code expected HTTP response code.
+ *
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_refund_increase
+  (const char *label,
+  const char *merchant_url,
+  const char *reason,
+  const char *order_id,
+  const char *refund_amount,
+  const char *refund_fee,
+  unsigned int http_code)
+{
+  struct RefundIncreaseState *ris;
+
+  ris = GNUNET_new (struct RefundIncreaseState);
+  ris->merchant_url = merchant_url;
+  ris->order_id = order_id;
+  ris->refund_amount = refund_amount;
+  ris->refund_fee = refund_fee;
+  ris->reason = reason;
+  ris->http_code = http_code;
+  {
+    struct TALER_TESTING_Command cmd = {
+      .cls = ris,
+      .label = label,
+      .run = &refund_increase_run,
+      .cleanup = &refund_increase_cleanup,
+      .traits = &refund_increase_traits
+    };
+
+    return cmd;
+  }
+}
+
+
+/* end of testing_api_cmd_refund_increase.c */
diff --git a/src/lib/testing_api_cmd_tip_authorize.c 
b/src/lib/testing_api_cmd_tip_authorize.c
new file mode 100644
index 0000000..e10ecac
--- /dev/null
+++ b/src/lib/testing_api_cmd_tip_authorize.c
@@ -0,0 +1,375 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014-2018 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 3, or
+  (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public
+  License along with TALER; see the file COPYING.  If not, see
+  <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file lib/testing_api_cmd_tip_authorize.c
+ * @brief command to test the tipping.
+ * @author Marcello Stanisci
+ */
+
+#include "platform.h"
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_testing_lib.h>
+#include "taler_merchant_service.h"
+#include "taler_merchant_testing_lib.h"
+
+
+/**
+ * State for a /tip-authorize CMD.
+ */
+struct TipAuthorizeState
+{
+
+  /**
+   * Merchant base URL.
+   */
+  const char *merchant_url;
+
+  /**
+   * Expected HTTP response code.
+   */
+  unsigned int http_status;
+
+  /**
+   * Human-readable justification for the
+   * tip authorization carried on by this CMD.
+   */
+  const char *justification;
+
+  /**
+   * Amount that should be authorized for tipping.
+   */
+  const char *amount;
+
+  /**
+   * Expected Taler error code for this CMD.
+   */
+  enum TALER_ErrorCode expected_ec;
+
+  /**
+   * Tip taler:// URI.
+   */
+  const char *tip_uri;
+
+  /**
+   * The tip id; set when the CMD succeeds.
+   */
+  struct GNUNET_HashCode tip_id;
+
+  /**
+   * Expiration date for this tip.
+   */
+  struct GNUNET_TIME_Absolute tip_expiration;
+
+  /**
+   * Handle to the on-going /tip-authorize request.
+   */
+  struct TALER_MERCHANT_TipAuthorizeOperation *tao;
+
+  /**
+   * The interpreter state.
+   */
+  struct TALER_TESTING_Interpreter *is;
+};
+
+
+/**
+ * Callback for a /tip-authorize request.  Set into the state
+ * what was returned from the backend (@a tip_id and @a
+ * tip_expiration).
+ *
+ * @param cls closure
+ * @param http_status HTTP status returned by the merchant backend
+ * @param ec taler-specific error code
+ * @param taler_tip_uri URI to let the wallet know about the tip
+ * @param tip_id unique identifier for the tip
+ */
+static void
+tip_authorize_cb (void *cls,
+                  unsigned int http_status,
+                  enum TALER_ErrorCode ec,
+                  const char *taler_tip_uri,
+                  struct GNUNET_HashCode *tip_id)
+{
+  struct TipAuthorizeState *tas = cls;
+
+  tas->tao = NULL;
+  if (tas->http_status != http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u (%d)"
+                " to command %s\n",
+                http_status,
+                ec,
+                TALER_TESTING_interpreter_get_current_label
+                  (tas->is));
+
+    TALER_TESTING_interpreter_fail (tas->is);
+    return;
+  }
+
+  if (tas->expected_ec != ec)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected error code %d (%u) to command %s\n",
+                ec,
+                http_status,
+                TALER_TESTING_interpreter_get_current_label
+                  (tas->is));
+    TALER_TESTING_interpreter_fail (tas->is);
+    return;
+  }
+  if ( (MHD_HTTP_OK == http_status) &&
+       (TALER_EC_NONE == ec) )
+  {
+    tas->tip_uri = strdup (taler_tip_uri);
+    tas->tip_id = *tip_id;
+  }
+
+  TALER_TESTING_interpreter_next (tas->is);
+}
+
+
+/**
+ * Offers information from the /tip-authorize CMD state to other
+ * commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param index index number of the object to extract.
+ * @return #GNUNET_OK on success
+ */
+static int
+tip_authorize_traits (void *cls,
+                      const void **ret,
+                      const char *trait,
+                      unsigned int index)
+{
+  struct TipAuthorizeState *tas = cls;
+  struct TALER_TESTING_Trait traits[] = {
+    TALER_TESTING_make_trait_tip_id (0, &tas->tip_id),
+    TALER_TESTING_trait_end (),
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
+
+/**
+ * Runs the /tip-authorize CMD
+ *
+ * @param cls closure
+ * @param cmd the CMD representing _this_ command
+ * @param is interpreter state
+ */
+static void
+tip_authorize_run (void *cls,
+                   const struct TALER_TESTING_Command *cmd,
+                   struct TALER_TESTING_Interpreter *is)
+{
+  struct TipAuthorizeState *tas = cls;
+  struct TALER_Amount amount;
+
+  tas->is = is;
+  if (GNUNET_OK != TALER_string_to_amount (tas->amount,
+                                           &amount))
+    TALER_TESTING_FAIL (is);
+
+  tas->tao = TALER_MERCHANT_tip_authorize
+               (is->ctx,
+               tas->merchant_url,
+               "http://merchant.com/pickup";,
+               "http://merchant.com/continue";,
+               &amount,
+               tas->justification,
+               tip_authorize_cb,
+               tas);
+
+  GNUNET_assert (NULL != tas->tao);
+}
+
+
+/**
+ * Run the /tip-authorize CMD, the "fake" version of it.
+ *
+ * @param cls closure
+ * @param cmd the CMD representing _this_ command
+ * @param is interpreter state *
+ */
+static void
+tip_authorize_fake_run (void *cls,
+                        const struct TALER_TESTING_Command *cmd,
+                        struct TALER_TESTING_Interpreter *is)
+{
+  struct TipAuthorizeState *tas = cls;
+
+  /* Make up a tip id.  */
+  GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+                              &tas->tip_id,
+                              sizeof (struct GNUNET_HashCode));
+
+  TALER_TESTING_interpreter_next (is);
+}
+
+
+/**
+ * Free the state from a /tip-authorize CMD, and possibly
+ * cancel any pending operation.
+ *
+ * @param cls closure
+ * @param cmd the /tip-authorize CMD that is about to be freed.
+ */
+static void
+tip_authorize_cleanup (void *cls,
+                       const struct TALER_TESTING_Command *cmd)
+{
+  struct TipAuthorizeState *tas = cls;
+
+  if (NULL != tas->tao)
+  {
+    TALER_LOG_WARNING ("Tip-autorize operation"
+                       " did not complete\n");
+    TALER_MERCHANT_tip_authorize_cancel (tas->tao);
+  }
+  GNUNET_free (tas);
+}
+
+
+/**
+ * Create a /tip-authorize CMD, specifying the Taler error code
+ * that is expected to be returned by the backend.
+ *
+ * @param label this command label
+ * @param merchant_url the base URL of the merchant that will
+ *        serve the /tip-authorize request.
+ * @param exchange_url the base URL of the exchange that owns
+ *        the reserve from which the tip is going to be gotten.
+ * @param http_status the HTTP response code which is expected
+ *        for this operation.
+ * @param justification human-readable justification for this
+ *        tip authorization.
+ * @param amount the amount to authorize for tipping.
+ * @param ec expected Taler-defined error code.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize_with_ec
+  (const char *label,
+  const char *merchant_url,
+  const char *exchange_url,
+  unsigned int http_status,
+  const char *justification,
+  const char *amount,
+  enum TALER_ErrorCode ec)
+{
+  struct TipAuthorizeState *tas;
+
+  tas = GNUNET_new (struct TipAuthorizeState);
+  tas->merchant_url = merchant_url;
+  tas->justification = justification;
+  tas->amount = amount;
+  tas->http_status = http_status;
+  tas->expected_ec = ec;
+
+  struct TALER_TESTING_Command cmd = {
+    .label = label,
+    .cls = tas,
+    .run = &tip_authorize_run,
+    .cleanup = &tip_authorize_cleanup,
+    .traits = &tip_authorize_traits
+  };
+
+  return cmd;
+}
+
+
+/**
+ * Create a /tip-authorize CMD.
+ *
+ * @param label this command label
+ * @param merchant_url the base URL of the merchant that will
+ *        serve the /tip-authorize request.
+ * @param exchange_url the base URL of the exchange that owns
+ *        the reserve from which the tip is going to be gotten.
+ * @param http_status the HTTP response code which is expected
+ *        for this operation.
+ * @param justification human-readable justification for this
+ *        tip authorization.
+ * @param amount the amount to authorize for tipping.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize (const char *label,
+                                 const char *merchant_url,
+                                 const char *exchange_url,
+                                 unsigned int http_status,
+                                 const char *justification,
+                                 const char *amount)
+{
+  struct TipAuthorizeState *tas;
+
+  tas = GNUNET_new (struct TipAuthorizeState);
+  tas->merchant_url = merchant_url;
+  tas->justification = justification;
+  tas->amount = amount;
+  tas->http_status = http_status;
+
+  struct TALER_TESTING_Command cmd = {
+    .label = label,
+    .cls = tas,
+    .run = &tip_authorize_run,
+    .cleanup = &tip_authorize_cleanup,
+    .traits = &tip_authorize_traits
+  };
+
+  return cmd;
+}
+
+
+/**
+ * This commands does not query the backend at all,
+ * but just makes up a fake authorization id that will
+ * be subsequently used by the "pick up" CMD in order
+ * to test against such a case.
+ *
+ * @param label command label.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize_fake (const char *label)
+{
+  struct TipAuthorizeState *tas;
+
+  tas = GNUNET_new (struct TipAuthorizeState);
+
+  struct TALER_TESTING_Command cmd = {
+    .label = label,
+    .cls = tas,
+    .run = &tip_authorize_fake_run,
+    .cleanup = &tip_authorize_cleanup,
+    .traits = &tip_authorize_traits
+  };
+
+  return cmd;
+}
+
+
+/* end of testing_api_cmd_tip_authorize.c */
diff --git a/src/lib/testing_api_cmd_tip.c 
b/src/lib/testing_api_cmd_tip_pickup.c
similarity index 51%
rename from src/lib/testing_api_cmd_tip.c
rename to src/lib/testing_api_cmd_tip_pickup.c
index 41757b6..4a537f9 100644
--- a/src/lib/testing_api_cmd_tip.c
+++ b/src/lib/testing_api_cmd_tip_pickup.c
@@ -95,7 +95,6 @@ struct TipPickupState
    */
   const struct TALER_EXCHANGE_DenomPublicKey **dks;
 
-
   /**
    * The array of planchet secrets, in the same order of @a
    * amounts.
@@ -122,583 +121,6 @@ struct TipPickupState
 };
 
 
-/**
- * State for a /tip-query CMD.
- */
-struct TipQueryState
-{
-
-  /**
-   * The merchant base URL.
-   */
-  const char *merchant_url;
-
-  /**
-   * Expected HTTP response code for this CMD.
-   */
-  unsigned int http_status;
-
-  /**
-   * The handle to the current /tip-query request.
-   */
-  struct TALER_MERCHANT_TipQueryOperation *tqo;
-
-  /**
-   * The interpreter state.
-   */
-  struct TALER_TESTING_Interpreter *is;
-
-  /**
-   * Expected amount to be picked up.
-   */
-  const char *expected_amount_picked_up;
-
-  /**
-   * Expected amount to be tip-authorized.
-   */
-  const char *expected_amount_authorized;
-
-  /**
-   * Amount that is expected to be still available
-   * from the tip reserve.
-   */
-  const char *expected_amount_available;
-};
-
-
-/**
- * State for a /tip-authorize CMD.
- */
-struct TipAuthorizeState
-{
-
-  /**
-   * Merchant base URL.
-   */
-  const char *merchant_url;
-
-  /**
-   * Expected HTTP response code.
-   */
-  unsigned int http_status;
-
-  /**
-   * Human-readable justification for the
-   * tip authorization carried on by this CMD.
-   */
-  const char *justification;
-
-  /**
-   * Amount that should be authorized for tipping.
-   */
-  const char *amount;
-
-  /**
-   * Expected Taler error code for this CMD.
-   */
-  enum TALER_ErrorCode expected_ec;
-
-  /**
-   * Tip taler:// URI.
-   */
-  const char *tip_uri;
-
-  /**
-   * The tip id; set when the CMD succeeds.
-   */
-  struct GNUNET_HashCode tip_id;
-
-  /**
-   * Expiration date for this tip.
-   */
-  struct GNUNET_TIME_Absolute tip_expiration;
-
-  /**
-   * Handle to the on-going /tip-authorize request.
-   */
-  struct TALER_MERCHANT_TipAuthorizeOperation *tao;
-
-  /**
-   * The interpreter state.
-   */
-  struct TALER_TESTING_Interpreter *is;
-};
-
-/**
- * Callback for a /tip-authorize request.  Set into the state
- * what was returned from the backend (@a tip_id and @a
- * tip_expiration).
- *
- * @param cls closure
- * @param http_status HTTP status returned by the merchant backend
- * @param ec taler-specific error code
- * @param taler_tip_uri URI to let the wallet know about the tip
- * @param tip_id unique identifier for the tip
- */
-static void
-tip_authorize_cb (void *cls,
-                  unsigned int http_status,
-                  enum TALER_ErrorCode ec,
-                  const char *taler_tip_uri,
-                  struct GNUNET_HashCode *tip_id)
-{
-  struct TipAuthorizeState *tas = cls;
-
-  tas->tao = NULL;
-  if (tas->http_status != http_status)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected response code %u (%d)"
-                " to command %s\n",
-                http_status,
-                ec,
-                TALER_TESTING_interpreter_get_current_label
-                  (tas->is));
-
-    TALER_TESTING_interpreter_fail (tas->is);
-    return;
-  }
-
-  if (tas->expected_ec != ec)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected error code %d (%u) to command %s\n",
-                ec,
-                http_status,
-                TALER_TESTING_interpreter_get_current_label
-                  (tas->is));
-    TALER_TESTING_interpreter_fail (tas->is);
-    return;
-  }
-  if ( (MHD_HTTP_OK == http_status) &&
-       (TALER_EC_NONE == ec) )
-  {
-    tas->tip_uri = strdup (taler_tip_uri);
-    tas->tip_id = *tip_id;
-  }
-
-  TALER_TESTING_interpreter_next (tas->is);
-}
-
-
-/**
- * Offers information from the /tip-authorize CMD state to other
- * commands.
- *
- * @param cls closure
- * @param ret[out] result (could be anything)
- * @param trait name of the trait
- * @param index index number of the object to extract.
- * @return #GNUNET_OK on success
- */
-static int
-tip_authorize_traits (void *cls,
-                      const void **ret,
-                      const char *trait,
-                      unsigned int index)
-{
-  struct TipAuthorizeState *tas = cls;
-  struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_tip_id (0, &tas->tip_id),
-    TALER_TESTING_trait_end (),
-  };
-
-  return TALER_TESTING_get_trait (traits,
-                                  ret,
-                                  trait,
-                                  index);
-}
-
-
-/**
- * Runs the /tip-authorize CMD
- *
- * @param cls closure
- * @param cmd the CMD representing _this_ command
- * @param is interpreter state
- */
-static void
-tip_authorize_run (void *cls,
-                   const struct TALER_TESTING_Command *cmd,
-                   struct TALER_TESTING_Interpreter *is)
-{
-  struct TipAuthorizeState *tas = cls;
-  struct TALER_Amount amount;
-
-  tas->is = is;
-  if (GNUNET_OK != TALER_string_to_amount (tas->amount,
-                                           &amount))
-    TALER_TESTING_FAIL (is);
-
-  tas->tao = TALER_MERCHANT_tip_authorize
-               (is->ctx,
-               tas->merchant_url,
-               "http://merchant.com/pickup";,
-               "http://merchant.com/continue";,
-               &amount,
-               tas->justification,
-               tip_authorize_cb,
-               tas);
-
-  GNUNET_assert (NULL != tas->tao);
-}
-
-
-/**
- * Run the /tip-authorize CMD, the "fake" version of it.
- *
- * @param cls closure
- * @param cmd the CMD representing _this_ command
- * @param is interpreter state *
- */
-static void
-tip_authorize_fake_run (void *cls,
-                        const struct TALER_TESTING_Command *cmd,
-                        struct TALER_TESTING_Interpreter *is)
-{
-  struct TipAuthorizeState *tas = cls;
-
-  /* Make up a tip id.  */
-  GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
-                              &tas->tip_id,
-                              sizeof (struct GNUNET_HashCode));
-
-  TALER_TESTING_interpreter_next (is);
-}
-
-
-/**
- * Free the state from a /tip-authorize CMD, and possibly
- * cancel any pending operation.
- *
- * @param cls closure
- * @param cmd the /tip-authorize CMD that is about to be freed.
- */
-static void
-tip_authorize_cleanup (void *cls,
-                       const struct TALER_TESTING_Command *cmd)
-{
-  struct TipAuthorizeState *tas = cls;
-
-  if (NULL != tas->tao)
-  {
-    TALER_LOG_WARNING ("Tip-autorize operation"
-                       " did not complete\n");
-    TALER_MERCHANT_tip_authorize_cancel (tas->tao);
-  }
-  GNUNET_free (tas);
-}
-
-
-/**
- * Create a /tip-authorize CMD, specifying the Taler error code
- * that is expected to be returned by the backend.
- *
- * @param label this command label
- * @param merchant_url the base URL of the merchant that will
- *        serve the /tip-authorize request.
- * @param exchange_url the base URL of the exchange that owns
- *        the reserve from which the tip is going to be gotten.
- * @param http_status the HTTP response code which is expected
- *        for this operation.
- * @param justification human-readable justification for this
- *        tip authorization.
- * @param amount the amount to authorize for tipping.
- * @param ec expected Taler-defined error code.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize_with_ec
-  (const char *label,
-  const char *merchant_url,
-  const char *exchange_url,
-  unsigned int http_status,
-  const char *justification,
-  const char *amount,
-  enum TALER_ErrorCode ec)
-{
-  struct TipAuthorizeState *tas;
-
-  tas = GNUNET_new (struct TipAuthorizeState);
-  tas->merchant_url = merchant_url;
-  tas->justification = justification;
-  tas->amount = amount;
-  tas->http_status = http_status;
-  tas->expected_ec = ec;
-
-  struct TALER_TESTING_Command cmd = {
-    .label = label,
-    .cls = tas,
-    .run = &tip_authorize_run,
-    .cleanup = &tip_authorize_cleanup,
-    .traits = &tip_authorize_traits
-  };
-
-  return cmd;
-}
-
-
-/**
- * Create a /tip-authorize CMD.
- *
- * @param label this command label
- * @param merchant_url the base URL of the merchant that will
- *        serve the /tip-authorize request.
- * @param exchange_url the base URL of the exchange that owns
- *        the reserve from which the tip is going to be gotten.
- * @param http_status the HTTP response code which is expected
- *        for this operation.
- * @param justification human-readable justification for this
- *        tip authorization.
- * @param amount the amount to authorize for tipping.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize (const char *label,
-                                 const char *merchant_url,
-                                 const char *exchange_url,
-                                 unsigned int http_status,
-                                 const char *justification,
-                                 const char *amount)
-{
-  struct TipAuthorizeState *tas;
-
-  tas = GNUNET_new (struct TipAuthorizeState);
-  tas->merchant_url = merchant_url;
-  tas->justification = justification;
-  tas->amount = amount;
-  tas->http_status = http_status;
-
-  struct TALER_TESTING_Command cmd = {
-    .label = label,
-    .cls = tas,
-    .run = &tip_authorize_run,
-    .cleanup = &tip_authorize_cleanup,
-    .traits = &tip_authorize_traits
-  };
-
-  return cmd;
-}
-
-
-/**
- * Callback to process a GET /tip-query request, it mainly
- * checks that what the backend returned matches the command's
- * expectations.
- *
- * @param cls closure
- * @param http_status HTTP status code for this request
- * @param ec Taler-specific error code
- * @param raw raw response body
- * @param reserve_expiration when the tip reserve will expire
- * @param reserve_pub tip reserve public key
- * @param amount_authorized total amount authorized on tip reserve
- * @param amount_available total amount still available on
- *        tip reserve
- * @param amount_picked_up total amount picked up from tip reserve
- */
-static void
-tip_query_cb (void *cls,
-              unsigned int http_status,
-              enum TALER_ErrorCode ec,
-              const json_t *raw,
-              struct GNUNET_TIME_Absolute reserve_expiration,
-              struct TALER_ReservePublicKeyP *reserve_pub,
-              struct TALER_Amount *amount_authorized,
-              struct TALER_Amount *amount_available,
-              struct TALER_Amount *amount_picked_up)
-{
-  struct TipQueryState *tqs = cls;
-  struct TALER_Amount a;
-
-  tqs->tqo = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Tip query callback at command `%s'\n",
-              TALER_TESTING_interpreter_get_current_label
-                (tqs->is));
-
-  GNUNET_assert (NULL != reserve_pub);
-  GNUNET_assert (NULL != amount_authorized);
-  GNUNET_assert (NULL != amount_available);
-  GNUNET_assert (NULL != amount_picked_up);
-
-  if (tqs->expected_amount_available)
-  {
-    GNUNET_assert (GNUNET_OK == TALER_string_to_amount
-                     (tqs->expected_amount_available, &a));
-    {
-      char *str;
-
-      str = TALER_amount_to_string (amount_available);
-      TALER_LOG_INFO ("expected available %s, actual %s\n",
-                      TALER_amount2s (&a),
-                      str);
-      GNUNET_free (str);
-    }
-    if (0 != TALER_amount_cmp (amount_available, &a))
-      TALER_TESTING_FAIL (tqs->is);
-  }
-
-  if (tqs->expected_amount_authorized)
-  {
-    GNUNET_assert (GNUNET_OK == TALER_string_to_amount
-                     (tqs->expected_amount_authorized, &a));
-    {
-      char *str;
-
-      str = TALER_amount_to_string (amount_authorized);
-      TALER_LOG_INFO ("expected authorized %s, actual %s\n",
-                      TALER_amount2s (&a),
-                      str);
-      GNUNET_free (str);
-    }
-    if (0 != TALER_amount_cmp (amount_authorized, &a))
-      TALER_TESTING_FAIL (tqs->is);
-  }
-
-  if (tqs->expected_amount_picked_up)
-  {
-    GNUNET_assert (GNUNET_OK == TALER_string_to_amount
-                     (tqs->expected_amount_picked_up, &a));
-    {
-      char *str;
-      str = TALER_amount_to_string (amount_picked_up);
-      TALER_LOG_INFO ("expected picked_up %s, actual %s\n",
-                      TALER_amount2s (&a),
-                      str);
-      GNUNET_free (str);
-    }
-    if (0 != TALER_amount_cmp (amount_picked_up, &a))
-      TALER_TESTING_FAIL (tqs->is);
-  }
-
-  if (tqs->http_status != http_status)
-    TALER_TESTING_FAIL (tqs->is);
-
-  TALER_TESTING_interpreter_next (tqs->is);
-}
-
-
-/**
- * Free the state from a /tip-query CMD, and possibly cancel
- * a pending /tip-query request.
- *
- * @param cls closure.
- * @param cmd the /tip-query CMD to free.
- */
-static void
-tip_query_cleanup (void *cls,
-                   const struct TALER_TESTING_Command *cmd)
-{
-  struct TipQueryState *tqs = cls;
-
-  if (NULL != tqs->tqo)
-  {
-    TALER_LOG_WARNING ("Tip-query operation"
-                       " did not complete\n");
-    TALER_MERCHANT_tip_query_cancel (tqs->tqo);
-  }
-  GNUNET_free (tqs);
-}
-
-
-/**
- * Run a /tip-query CMD.
- *
- * @param cls closure.
- * @param cmd the current /tip-query CMD.
- * @param is the interpreter state.
- */
-static void
-tip_query_run (void *cls,
-               const struct TALER_TESTING_Command *cmd,
-               struct TALER_TESTING_Interpreter *is)
-{
-  struct TipQueryState *tqs = cls;
-
-  tqs->is = is;
-  tqs->tqo = TALER_MERCHANT_tip_query (is->ctx,
-                                       tqs->merchant_url,
-                                       &tip_query_cb,
-                                       tqs);
-  GNUNET_assert (NULL != tqs->tqo);
-}
-
-
-/**
- * Define a /tip-query CMD equipped with a expected amount.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- *        server the /tip-query request.
- * @param http_status expected HTTP response code for the
- *        /tip-query request.
- * @param expected_amount_picked_up expected amount already
- *        picked up.
- * @param expected_amount_authorized expected amount that was
- *        authorized in the first place.
- * @param expected_amount_available expected amount which is
- *        still available from the tip reserve
- * @return the command
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_query_with_amounts
-  (const char *label,
-  const char *merchant_url,
-  unsigned int http_status,
-  const char *expected_amount_picked_up,
-  const char *expected_amount_authorized,
-  const char *expected_amount_available)
-{
-  struct TipQueryState *tqs;
-
-  tqs = GNUNET_new (struct TipQueryState);
-  tqs->merchant_url = merchant_url;
-  tqs->http_status = http_status;
-  tqs->expected_amount_picked_up = expected_amount_picked_up;
-  tqs->expected_amount_authorized = expected_amount_authorized;
-  tqs->expected_amount_available = expected_amount_available;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = tqs,
-    .label = label,
-    .run = &tip_query_run,
-    .cleanup = &tip_query_cleanup
-  };
-
-  return cmd;
-}
-
-
-/**
- * Define a /tip-query CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- *        server the /tip-query request.
- * @param http_status expected HTTP response code for the
- *        /tip-query request.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_query (const char *label,
-                             const char *merchant_url,
-                             unsigned int http_status)
-{
-  struct TipQueryState *tqs;
-
-  tqs = GNUNET_new (struct TipQueryState);
-  tqs->merchant_url = merchant_url;
-  tqs->http_status = http_status;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = tqs,
-    .label = label,
-    .run = &tip_query_run,
-    .cleanup = &tip_query_cleanup
-  };
-
-  return cmd;
-}
-
-
 /**
  * Internal withdraw handle used when withdrawing tips.
  */
@@ -720,13 +142,13 @@ struct WithdrawHandle
    */
   unsigned int off;
 
-
   /**
    * Internal state of the "pickup" CMD.
    */
   struct TipPickupState *tps;
 };
 
+
 /**
  * This callback handles the response of a withdraw operation
  * from the exchange, that is the final step in getting the tip.
@@ -1173,33 +595,4 @@ TALER_TESTING_cmd_tip_pickup
 }
 
 
-/**
- * This commands does not query the backend at all,
- * but just makes up a fake authorization id that will
- * be subsequently used by the "pick up" CMD in order
- * to test against such a case.
- *
- * @param label command label.
- *
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize_fake (const char *label)
-{
-  struct TipAuthorizeState *tas;
-
-  tas = GNUNET_new (struct TipAuthorizeState);
-
-  struct TALER_TESTING_Command cmd = {
-    .label = label,
-    .cls = tas,
-    .run = &tip_authorize_fake_run,
-    .cleanup = &tip_authorize_cleanup,
-    .traits = &tip_authorize_traits
-  };
-
-  return cmd;
-}
-
-
-/* end of testing_api_cmd_tip.c */
+/* end of testing_api_cmd_tip_pickup.c */
diff --git a/src/lib/testing_api_cmd_tip_query.c 
b/src/lib/testing_api_cmd_tip_query.c
new file mode 100644
index 0000000..114bde7
--- /dev/null
+++ b/src/lib/testing_api_cmd_tip_query.c
@@ -0,0 +1,297 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014-2018 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 3, or
+  (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public
+  License along with TALER; see the file COPYING.  If not, see
+  <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file lib/testing_api_cmd_tip_query.c
+ * @brief command to test the tipping.
+ * @author Marcello Stanisci
+ */
+
+#include "platform.h"
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_testing_lib.h>
+#include "taler_merchant_service.h"
+#include "taler_merchant_testing_lib.h"
+
+
+/**
+ * State for a /tip-query CMD.
+ */
+struct TipQueryState
+{
+
+  /**
+   * The merchant base URL.
+   */
+  const char *merchant_url;
+
+  /**
+   * Expected HTTP response code for this CMD.
+   */
+  unsigned int http_status;
+
+  /**
+   * The handle to the current /tip-query request.
+   */
+  struct TALER_MERCHANT_TipQueryOperation *tqo;
+
+  /**
+   * The interpreter state.
+   */
+  struct TALER_TESTING_Interpreter *is;
+
+  /**
+   * Expected amount to be picked up.
+   */
+  const char *expected_amount_picked_up;
+
+  /**
+   * Expected amount to be tip-authorized.
+   */
+  const char *expected_amount_authorized;
+
+  /**
+   * Amount that is expected to be still available
+   * from the tip reserve.
+   */
+  const char *expected_amount_available;
+};
+
+
+/**
+ * Callback to process a GET /tip-query request, it mainly
+ * checks that what the backend returned matches the command's
+ * expectations.
+ *
+ * @param cls closure
+ * @param http_status HTTP status code for this request
+ * @param ec Taler-specific error code
+ * @param raw raw response body
+ * @param reserve_expiration when the tip reserve will expire
+ * @param reserve_pub tip reserve public key
+ * @param amount_authorized total amount authorized on tip reserve
+ * @param amount_available total amount still available on
+ *        tip reserve
+ * @param amount_picked_up total amount picked up from tip reserve
+ */
+static void
+tip_query_cb (void *cls,
+              unsigned int http_status,
+              enum TALER_ErrorCode ec,
+              const json_t *raw,
+              struct GNUNET_TIME_Absolute reserve_expiration,
+              struct TALER_ReservePublicKeyP *reserve_pub,
+              struct TALER_Amount *amount_authorized,
+              struct TALER_Amount *amount_available,
+              struct TALER_Amount *amount_picked_up)
+{
+  struct TipQueryState *tqs = cls;
+  struct TALER_Amount a;
+
+  tqs->tqo = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Tip query callback at command `%s'\n",
+              TALER_TESTING_interpreter_get_current_label
+                (tqs->is));
+
+  GNUNET_assert (NULL != reserve_pub);
+  GNUNET_assert (NULL != amount_authorized);
+  GNUNET_assert (NULL != amount_available);
+  GNUNET_assert (NULL != amount_picked_up);
+
+  if (tqs->expected_amount_available)
+  {
+    GNUNET_assert (GNUNET_OK == TALER_string_to_amount
+                     (tqs->expected_amount_available, &a));
+    {
+      char *str;
+
+      str = TALER_amount_to_string (amount_available);
+      TALER_LOG_INFO ("expected available %s, actual %s\n",
+                      TALER_amount2s (&a),
+                      str);
+      GNUNET_free (str);
+    }
+    if (0 != TALER_amount_cmp (amount_available, &a))
+      TALER_TESTING_FAIL (tqs->is);
+  }
+
+  if (tqs->expected_amount_authorized)
+  {
+    GNUNET_assert (GNUNET_OK == TALER_string_to_amount
+                     (tqs->expected_amount_authorized, &a));
+    {
+      char *str;
+
+      str = TALER_amount_to_string (amount_authorized);
+      TALER_LOG_INFO ("expected authorized %s, actual %s\n",
+                      TALER_amount2s (&a),
+                      str);
+      GNUNET_free (str);
+    }
+    if (0 != TALER_amount_cmp (amount_authorized, &a))
+      TALER_TESTING_FAIL (tqs->is);
+  }
+
+  if (tqs->expected_amount_picked_up)
+  {
+    GNUNET_assert (GNUNET_OK == TALER_string_to_amount
+                     (tqs->expected_amount_picked_up, &a));
+    {
+      char *str;
+      str = TALER_amount_to_string (amount_picked_up);
+      TALER_LOG_INFO ("expected picked_up %s, actual %s\n",
+                      TALER_amount2s (&a),
+                      str);
+      GNUNET_free (str);
+    }
+    if (0 != TALER_amount_cmp (amount_picked_up, &a))
+      TALER_TESTING_FAIL (tqs->is);
+  }
+
+  if (tqs->http_status != http_status)
+    TALER_TESTING_FAIL (tqs->is);
+
+  TALER_TESTING_interpreter_next (tqs->is);
+}
+
+
+/**
+ * Free the state from a /tip-query CMD, and possibly cancel
+ * a pending /tip-query request.
+ *
+ * @param cls closure.
+ * @param cmd the /tip-query CMD to free.
+ */
+static void
+tip_query_cleanup (void *cls,
+                   const struct TALER_TESTING_Command *cmd)
+{
+  struct TipQueryState *tqs = cls;
+
+  if (NULL != tqs->tqo)
+  {
+    TALER_LOG_WARNING ("Tip-query operation"
+                       " did not complete\n");
+    TALER_MERCHANT_tip_query_cancel (tqs->tqo);
+  }
+  GNUNET_free (tqs);
+}
+
+
+/**
+ * Run a /tip-query CMD.
+ *
+ * @param cls closure.
+ * @param cmd the current /tip-query CMD.
+ * @param is the interpreter state.
+ */
+static void
+tip_query_run (void *cls,
+               const struct TALER_TESTING_Command *cmd,
+               struct TALER_TESTING_Interpreter *is)
+{
+  struct TipQueryState *tqs = cls;
+
+  tqs->is = is;
+  tqs->tqo = TALER_MERCHANT_tip_query (is->ctx,
+                                       tqs->merchant_url,
+                                       &tip_query_cb,
+                                       tqs);
+  GNUNET_assert (NULL != tqs->tqo);
+}
+
+
+/**
+ * Define a /tip-query CMD equipped with a expected amount.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ *        server the /tip-query request.
+ * @param http_status expected HTTP response code for the
+ *        /tip-query request.
+ * @param expected_amount_picked_up expected amount already
+ *        picked up.
+ * @param expected_amount_authorized expected amount that was
+ *        authorized in the first place.
+ * @param expected_amount_available expected amount which is
+ *        still available from the tip reserve
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_query_with_amounts
+  (const char *label,
+  const char *merchant_url,
+  unsigned int http_status,
+  const char *expected_amount_picked_up,
+  const char *expected_amount_authorized,
+  const char *expected_amount_available)
+{
+  struct TipQueryState *tqs;
+
+  tqs = GNUNET_new (struct TipQueryState);
+  tqs->merchant_url = merchant_url;
+  tqs->http_status = http_status;
+  tqs->expected_amount_picked_up = expected_amount_picked_up;
+  tqs->expected_amount_authorized = expected_amount_authorized;
+  tqs->expected_amount_available = expected_amount_available;
+
+  struct TALER_TESTING_Command cmd = {
+    .cls = tqs,
+    .label = label,
+    .run = &tip_query_run,
+    .cleanup = &tip_query_cleanup
+  };
+
+  return cmd;
+}
+
+
+/**
+ * Define a /tip-query CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ *        server the /tip-query request.
+ * @param http_status expected HTTP response code for the
+ *        /tip-query request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_query (const char *label,
+                             const char *merchant_url,
+                             unsigned int http_status)
+{
+  struct TipQueryState *tqs;
+
+  tqs = GNUNET_new (struct TipQueryState);
+  tqs->merchant_url = merchant_url;
+  tqs->http_status = http_status;
+
+  struct TALER_TESTING_Command cmd = {
+    .cls = tqs,
+    .label = label,
+    .run = &tip_query_run,
+    .cleanup = &tip_query_cleanup
+  };
+
+  return cmd;
+}
+
+
+/* end of testing_api_cmd_tip_query.c */
diff --git a/src/lib/testing_api_cmd_track_transaction.c 
b/src/lib/testing_api_cmd_track_transaction.c
new file mode 100644
index 0000000..6c0c61f
--- /dev/null
+++ b/src/lib/testing_api_cmd_track_transaction.c
@@ -0,0 +1,298 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014-2018 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 3, or
+  (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public
+  License along with TALER; see the file COPYING.  If not, see
+  <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file lib/testing_api_cmd_track_transaction.c
+ * @brief command to test /track/transaction
+ * @author Marcello Stanisci
+ */
+
+#include "platform.h"
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_testing_lib.h>
+#include "taler_merchant_service.h"
+#include "taler_merchant_testing_lib.h"
+
+
+/**
+ * State for a "track transaction" CMD.
+ */
+struct TrackTransactionState
+{
+  /**
+   * Handle for a pending /track/transaction request.
+   */
+  struct TALER_MERCHANT_TrackTransactionHandle *tth;
+
+  /**
+   * The interpreter state.
+   */
+  struct TALER_TESTING_Interpreter *is;
+
+  /**
+   * Base URL of the merchant serving the request.
+   */
+  const char *merchant_url;
+
+  /**
+   * Expected HTTP response code.
+   */
+  unsigned int http_status;
+
+  /**
+   * Reference to a "pay" CMD, used to get the order
+   * id to issue the track against.
+   */
+  const char *pay_reference;
+
+  /**
+   * Subject line of the wire transfer that payed
+   * the tracked contract back.  WARNING: impredictible
+   * behaviour if _multiple_ wire transfers were
+   * issued to pay this contract back.
+   */
+  const char *wtid_str;
+
+  /**
+   * Binary form of @a wtid_str, expected by other commands
+   * in this form.
+   */
+  struct TALER_WireTransferIdentifierRawP wtid;
+
+  /**
+   * base URL of the exchange that issued (or was supposed to,
+   * in case 202 Accepted was returned) the wire transfer to
+   * pay the tracked contract back.
+   */
+  const char *exchange_url;
+
+};
+
+
+/**
+ * Function called with detailed wire transfer data; checks
+ * if HTTP response code matches the expectation, and stores
+ * in the state what came from the backend.
+ *
+ * @param cls closure
+ * @param http_status HTTP status code we got,
+ *        0 on exchange protocol violation
+ * @param ec taler-specific error code
+ * @param json original json reply
+ */
+static void
+track_transaction_cb (void *cls,
+                      unsigned int http_status,
+                      enum TALER_ErrorCode ec,
+                      const json_t *json)
+{
+  struct TrackTransactionState *tts = cls;
+
+  tts->tth = NULL;
+  if (tts->http_status != http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u (%d) to command %s\n",
+                http_status,
+                ec,
+                TALER_TESTING_interpreter_get_current_label
+                  (tts->is));
+    TALER_TESTING_interpreter_fail (tts->is);
+    return;
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "/track/transaction, response code: %u\n",
+              http_status);
+  if (MHD_HTTP_OK == http_status)
+  {
+    /* Only storing first element's wtid, as this works around
+     * the disability of the real bank to provide a "bank check"
+     * CMD as the fakebank does.  */
+    json_t *wtid_str;
+    json_t *exchange_url;
+
+    if (NULL == (wtid_str = json_object_get
+                              (json_array_get (json, 0), "wtid")))
+    {
+      TALER_TESTING_interpreter_fail (tts->is);
+      return;
+    }
+
+    if (NULL == (exchange_url = json_object_get
+                                  (json_array_get (json, 0), "exchange")))
+    {
+
+      TALER_TESTING_interpreter_fail (tts->is);
+      return;
+    }
+
+    tts->exchange_url = GNUNET_strdup
+                          (json_string_value (exchange_url));
+    tts->wtid_str = GNUNET_strdup
+                      (json_string_value (wtid_str));
+  }
+  TALER_TESTING_interpreter_next (tts->is);
+}
+
+
+/**
+ * Run the "track transaction" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command being run now.
+ * @param is interpreter state.
+ */
+static void
+track_transaction_run (void *cls,
+                       const struct TALER_TESTING_Command *cmd,
+                       struct TALER_TESTING_Interpreter *is)
+{
+  struct TrackTransactionState *tts = cls;
+  const char *order_id;
+  const struct TALER_TESTING_Command *pay_cmd;
+
+  tts->is = is;
+  if (NULL ==
+      (pay_cmd = TALER_TESTING_interpreter_lookup_command
+                   (is, tts->pay_reference)))
+    TALER_TESTING_FAIL (is);
+
+  if (GNUNET_OK != TALER_TESTING_get_trait_order_id
+        (pay_cmd, 0, &order_id))
+    TALER_TESTING_FAIL (is);
+
+  tts->tth = TALER_MERCHANT_track_transaction
+               (is->ctx,
+               tts->merchant_url,
+               order_id,
+               &track_transaction_cb,
+               tts);
+
+  GNUNET_assert (NULL != tts->tth);
+}
+
+
+/**
+ * Free the state of a "track transaction" CMD, and possibly
+ * cancel a pending operation thereof.
+ *
+ * @param cls closure.
+ * @param cmd command being run.
+ */
+static void
+track_transaction_cleanup (void *cls,
+                           const struct TALER_TESTING_Command *cmd)
+{
+  struct TrackTransactionState *tts = cls;
+
+  if (NULL != tts->tth)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "/track/transaction (test) operation"
+                " did not complete\n");
+    TALER_MERCHANT_track_transaction_cancel (tts->tth);
+  }
+
+  /* Need to discard 'const' before freeing.  */
+  GNUNET_free_non_null ((char *) tts->exchange_url);
+  GNUNET_free_non_null ((char *) tts->wtid_str);
+
+  GNUNET_free (tts);
+}
+
+
+/**
+ * Offer internal data of a "track transaction" CMD, for
+ * other CMDs to use.
+ *
+ * @param cls closure.
+ * @param ret[out] return value.
+ * @param trait name of the trait.
+ * @param index index of the trait.
+ * @return #GNUNET_OK if it is successful.
+ */
+static int
+track_transaction_traits (void *cls,
+                          const void **ret,
+                          const char *trait,
+                          unsigned int index)
+{
+  struct TrackTransactionState *tts = cls;
+  struct TALER_WireTransferIdentifierRawP *wtid_ptr;
+
+  if (GNUNET_OK != GNUNET_STRINGS_string_to_data
+        (tts->wtid_str,
+        strlen (tts->wtid_str),
+        &tts->wtid,
+        sizeof (struct TALER_WireTransferIdentifierRawP)))
+    wtid_ptr = NULL;
+  else
+    wtid_ptr = &tts->wtid;
+
+  struct TALER_TESTING_Trait traits[] = {
+    TALER_TESTING_make_trait_wtid (0, wtid_ptr),
+    TALER_TESTING_make_trait_url (0, tts->exchange_url),
+    TALER_TESTING_trait_end ()
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+  return GNUNET_SYSERR;
+}
+
+
+/**
+ * Define a "track transaction" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ *        /track/transaction request.
+ * @param http_status expected HTTP response code.
+ * @param pay_reference used to retrieve the order id to track.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_track_transaction
+  (const char *label,
+  const char *merchant_url,
+  unsigned int http_status,
+  const char *pay_reference)
+{
+  struct TrackTransactionState *tts;
+
+  tts = GNUNET_new (struct TrackTransactionState);
+  tts->merchant_url = merchant_url;
+  tts->http_status = http_status;
+  tts->pay_reference = pay_reference;
+
+  struct TALER_TESTING_Command cmd = {
+    .cls = tts,
+    .label = label,
+    .run = &track_transaction_run,
+    .cleanup = &track_transaction_cleanup,
+    .traits = &track_transaction_traits
+  };
+
+  return cmd;
+}
+
+
+/* end of testing_api_cmd_track_transaction.c */
diff --git a/src/lib/testing_api_cmd_track.c 
b/src/lib/testing_api_cmd_track_transfer.c
similarity index 58%
rename from src/lib/testing_api_cmd_track.c
rename to src/lib/testing_api_cmd_track_transfer.c
index a651a50..3d1d76b 100644
--- a/src/lib/testing_api_cmd_track.c
+++ b/src/lib/testing_api_cmd_track_transfer.c
@@ -18,8 +18,8 @@
 */
 
 /**
- * @file lib/testing_api_cmd_track.c
- * @brief command to test /track/transaction and /track/transfer.
+ * @file lib/testing_api_cmd_track_transfer.c
+ * @brief command to test /track/transfer.
  * @author Marcello Stanisci
  */
 
@@ -30,61 +30,6 @@
 #include "taler_merchant_testing_lib.h"
 
 
-/**
- * State for a "track transaction" CMD.
- */
-struct TrackTransactionState
-{
-  /**
-   * Handle for a pending /track/transaction request.
-   */
-  struct TALER_MERCHANT_TrackTransactionHandle *tth;
-
-  /**
-   * The interpreter state.
-   */
-  struct TALER_TESTING_Interpreter *is;
-
-  /**
-   * Base URL of the merchant serving the request.
-   */
-  const char *merchant_url;
-
-  /**
-   * Expected HTTP response code.
-   */
-  unsigned int http_status;
-
-  /**
-   * Reference to a "pay" CMD, used to get the order
-   * id to issue the track against.
-   */
-  const char *pay_reference;
-
-  /**
-   * Subject line of the wire transfer that payed
-   * the tracked contract back.  WARNING: impredictible
-   * behaviour if _multiple_ wire transfers were
-   * issued to pay this contract back.
-   */
-  const char *wtid_str;
-
-  /**
-   * Binary form of @a wtid_str, expected by other commands
-   * in this form.
-   */
-  struct TALER_WireTransferIdentifierRawP wtid;
-
-  /**
-   * base URL of the exchange that issued (or was supposed to,
-   * in case 202 Accepted was returned) the wire transfer to
-   * pay the tracked contract back.
-   */
-  const char *exchange_url;
-
-};
-
-
 /**
  * State of a "track transfer" CMD.
  */
@@ -119,71 +64,6 @@ struct TrackTransferState
 
 };
 
-/**
- * Function called with detailed wire transfer data; checks
- * if HTTP response code matches the expectation, and stores
- * in the state what came from the backend.
- *
- * @param cls closure
- * @param http_status HTTP status code we got,
- *        0 on exchange protocol violation
- * @param ec taler-specific error code
- * @param json original json reply
- */
-static void
-track_transaction_cb (void *cls,
-                      unsigned int http_status,
-                      enum TALER_ErrorCode ec,
-                      const json_t *json)
-{
-  struct TrackTransactionState *tts = cls;
-
-  tts->tth = NULL;
-  if (tts->http_status != http_status)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected response code %u (%d) to command %s\n",
-                http_status,
-                ec,
-                TALER_TESTING_interpreter_get_current_label
-                  (tts->is));
-    TALER_TESTING_interpreter_fail (tts->is);
-    return;
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "/track/transaction, response code: %u\n",
-              http_status);
-  if (MHD_HTTP_OK == http_status)
-  {
-    /* Only storing first element's wtid, as this works around
-     * the disability of the real bank to provide a "bank check"
-     * CMD as the fakebank does.  */
-    json_t *wtid_str;
-    json_t *exchange_url;
-
-    if (NULL == (wtid_str = json_object_get
-                              (json_array_get (json, 0), "wtid")))
-    {
-      TALER_TESTING_interpreter_fail (tts->is);
-      return;
-    }
-
-    if (NULL == (exchange_url = json_object_get
-                                  (json_array_get (json, 0), "exchange")))
-    {
-
-      TALER_TESTING_interpreter_fail (tts->is);
-      return;
-    }
-
-    tts->exchange_url = GNUNET_strdup
-                          (json_string_value (exchange_url));
-    tts->wtid_str = GNUNET_strdup
-                      (json_string_value (wtid_str));
-  }
-  TALER_TESTING_interpreter_next (tts->is);
-}
-
 
 /**
  * Callback for a /track/transfer operation, only checks if
@@ -382,44 +262,6 @@ track_transfer_run (void *cls,
 }
 
 
-/**
- * Run the "track transaction" CMD.
- *
- *
- * @param cls closure.
- * @param cmd command being run now.
- * @param is interpreter state.
- */
-static void
-track_transaction_run (void *cls,
-                       const struct TALER_TESTING_Command *cmd,
-                       struct TALER_TESTING_Interpreter *is)
-{
-  struct TrackTransactionState *tts = cls;
-  const char *order_id;
-  const struct TALER_TESTING_Command *pay_cmd;
-
-  tts->is = is;
-  if (NULL ==
-      (pay_cmd = TALER_TESTING_interpreter_lookup_command
-                   (is, tts->pay_reference)))
-    TALER_TESTING_FAIL (is);
-
-  if (GNUNET_OK != TALER_TESTING_get_trait_order_id
-        (pay_cmd, 0, &order_id))
-    TALER_TESTING_FAIL (is);
-
-  tts->tth = TALER_MERCHANT_track_transaction
-               (is->ctx,
-               tts->merchant_url,
-               order_id,
-               &track_transaction_cb,
-               tts);
-
-  GNUNET_assert (NULL != tts->tth);
-}
-
-
 /**
  * Free the state of a "track transfer" CMD, and possibly
  * cancel a pending operation thereof.
@@ -444,114 +286,6 @@ track_transfer_cleanup (void *cls,
 }
 
 
-/**
- * Free the state of a "track transaction" CMD, and possibly
- * cancel a pending operation thereof.
- *
- * @param cls closure.
- * @param cmd command being run.
- */
-static void
-track_transaction_cleanup (void *cls,
-                           const struct TALER_TESTING_Command *cmd)
-{
-  struct TrackTransactionState *tts = cls;
-
-  if (NULL != tts->tth)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "/track/transaction (test) operation"
-                " did not complete\n");
-    TALER_MERCHANT_track_transaction_cancel (tts->tth);
-  }
-
-  /* Need to discard 'const' before freeing.  */
-  GNUNET_free_non_null ((char *) tts->exchange_url);
-  GNUNET_free_non_null ((char *) tts->wtid_str);
-
-  GNUNET_free (tts);
-}
-
-
-/**
- * Offer internal data of a "track transaction" CMD, for
- * other CMDs to use.
- *
- * @param cls closure.
- * @param ret[out] return value.
- * @param trait name of the trait.
- * @param index index of the trait.
- *
- * @return GNUNET_OK if it is successful.
- */
-static int
-track_transaction_traits (void *cls,
-                          const void **ret,
-                          const char *trait,
-                          unsigned int index)
-{
-  struct TrackTransactionState *tts = cls;
-  struct TALER_WireTransferIdentifierRawP *wtid_ptr;
-
-  if (GNUNET_OK != GNUNET_STRINGS_string_to_data
-        (tts->wtid_str,
-        strlen (tts->wtid_str),
-        &tts->wtid,
-        sizeof (struct TALER_WireTransferIdentifierRawP)))
-    wtid_ptr = NULL;
-  else
-    wtid_ptr = &tts->wtid;
-
-  struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_wtid (0, wtid_ptr),
-    TALER_TESTING_make_trait_url (0, tts->exchange_url),
-    TALER_TESTING_trait_end ()
-  };
-
-  return TALER_TESTING_get_trait (traits,
-                                  ret,
-                                  trait,
-                                  index);
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Define a "track transaction" CMD.
- *
- * @param label command label.
- * @param merchant_url base URL of the merchant serving the
- *        /track/transaction request.
- * @param http_status expected HTTP response code.
- * @param pay_reference used to retrieve the order id to track.
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_track_transaction
-  (const char *label,
-  const char *merchant_url,
-  unsigned int http_status,
-  const char *pay_reference)
-{
-  struct TrackTransactionState *tts;
-
-  tts = GNUNET_new (struct TrackTransactionState);
-  tts->merchant_url = merchant_url;
-  tts->http_status = http_status;
-  tts->pay_reference = pay_reference;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = tts,
-    .label = label,
-    .run = &track_transaction_run,
-    .cleanup = &track_transaction_cleanup,
-    .traits = &track_transaction_traits
-  };
-
-  return cmd;
-}
-
-
 /**
  * Define a "track transfer" CMD.
  *
@@ -589,4 +323,4 @@ TALER_TESTING_cmd_merchant_track_transfer
 }
 
 
-/* end of testing_api_cmd_track.c */
+/* end of testing_api_cmd_track_transfer.c */

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



reply via email to

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