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 (041ad71 -> 7508093)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (041ad71 -> 7508093)
Date: Thu, 24 May 2018 18:40:10 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from 041ad71  Fix bugs strongly related to #5330.
     new 0084d79  Commenting the "rewind" CMD.
     new f78a678  Commenting "refund" CMD.
     new 7508093  Commenting "track"(s) CMDs.

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


Summary of changes:
 src/lib/testing_api_cmd_refund.c                   | 159 +++++++++++++++++++--
 src/lib/testing_api_cmd_rewind.c                   |  29 +++-
 src/lib/testing_api_cmd_track.c                    | 157 +++++++++++++++-----
 .../taler-merchant-generate-payments_new.c         |   2 +-
 4 files changed, 301 insertions(+), 46 deletions(-)

diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c
index d008f65..0fc0e88 100644
--- a/src/lib/testing_api_cmd_refund.c
+++ b/src/lib/testing_api_cmd_refund.c
@@ -30,54 +30,119 @@
 #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;
 
+  /**
+   * CURL context.
+   */
   struct GNUNET_CURL_Context *ctx;
 
+  /**
+   * 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;
 
+  /**
+   * CURL context.
+   */
   struct GNUNET_CURL_Context *ctx;
 
+  /**
+   * 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;
 };
 
 
 /**
- * Clean up after the command.  Run during forced termination
- * (CTRL-C) or test failure or test success.
+ * 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,
@@ -94,11 +159,13 @@ refund_increase_cleanup (void *cls,
   GNUNET_free (ris);
 }
 
+
 /**
- * Clean up after the command.  Run during forced termination
- * (CTRL-C) or test failure or test success.
+ * 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,
@@ -117,7 +184,8 @@ refund_lookup_cleanup (void *cls,
 }
 
 /**
- * Process POST /refund (increase) response
+ * 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
@@ -139,6 +207,14 @@ refund_increase_cb (void *cls,
   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,
@@ -168,6 +244,7 @@ refund_increase_run (void *cls,
  * @param cls closure, NULL
  * @param key current key
  * @param value a `struct TALER_Amount`
+ *
  * @return always #GNUNET_YES (continue to iterate)
  */
 static int
@@ -183,7 +260,9 @@ hashmap_free (void *cls,
 
 
 /**
- * Process GET /refund (increase) response.
+ * Process "GET /public/refund" (lookup) response;
+ * mainly checking if the refunded amount matches the
+ * expectation.
  *
  * @param cls closure
  * @param http_status HTTP status code
@@ -228,6 +307,7 @@ refund_lookup_cb (void *cls,
     return;
   }
 
+  /* Put in array every refunded coin.  */
   json_array_foreach (arr, index, elem)
   {
     struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -253,6 +333,8 @@ refund_lookup_cb (void *cls,
        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)))
@@ -359,6 +441,13 @@ refund_lookup_cb (void *cls,
 }
 
 
+/**
+ * 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,
@@ -378,8 +467,8 @@ refund_lookup_run (void *cls,
 
 
 /**
- * Extract information from a command that is useful for other
- * commands.
+ * Offer internal data from the "refund increase" CMD
+ * state to other commands.
  *
  * @param cls closure
  * @param ret[out] result (could be anything)
@@ -411,7 +500,19 @@ refund_increase_traits (void *cls,
 }
 
 /**
- * FIXME
+ * Define a "refund increase" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend serving the
+ *        "refund increase" request.
+ * @param ctx CURL context.
+ * @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
@@ -446,7 +547,22 @@ TALER_TESTING_cmd_refund_increase
 }
 
 /**
- * FIXME
+ * Define a "refund lookup" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ *        "refund lookup" request.
+ * @param ctx CURL context.
+ * @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
@@ -477,6 +593,29 @@ TALER_TESTING_cmd_refund_lookup
   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 ctx CURL context.
+ * @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,
diff --git a/src/lib/testing_api_cmd_rewind.c b/src/lib/testing_api_cmd_rewind.c
index 3e51f00..de8bb73 100644
--- a/src/lib/testing_api_cmd_rewind.c
+++ b/src/lib/testing_api_cmd_rewind.c
@@ -29,17 +29,43 @@
 #include "taler_merchant_service.h"
 #include "taler_merchant_testing_lib.h"
 
+
+/**
+ * State for a "rewind" CMD.
+ */
 struct RewindIpState
 {
+  /**
+   * Instruction pointer to set into the interpreter.
+   */
   unsigned int new_ip;
+
+  /**
+   * How many times this set should take place.
+   * However, this value lives at the calling process,
+   * and this CMD is only in charge of checking and
+   * decremeting it.
+   */
   unsigned int *counter;
 };
 
+
+/**
+ * Only defined to respect the API.
+ */
 static void
 rewind_ip_cleanup (void *cls,
                    const struct TALER_TESTING_Command *cmd)
 {}
 
+
+/**
+ * Run the "rewind" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command being executed now.
+ * @param is the interpreter state.
+ */
 static void
 rewind_ip_run (void *cls,
                const struct TALER_TESTING_Command *cmd,
@@ -47,6 +73,7 @@ rewind_ip_run (void *cls,
 {
   struct RewindIpState *ris = cls;
 
+  /* FIXME: do check if '1<' is good */
   if (1 < *ris->counter)
   {
     is->ip = ris->new_ip;
@@ -63,7 +90,7 @@ rewind_ip_run (void *cls,
  * @param label command label
  * @param new_ip new instruction pointer's value.  Note that,
  * when the next instruction will be called, the interpreter
- * will increment the ip under the hood so this value must be
+ * will increment the ip _anyway_ so this value must be
  * set to the index of the instruction we want to execute next
  * MINUS one.
  * @param counter counts how many times the rewinding has
diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c
index f58ed16..b6d0455 100644
--- a/src/lib/testing_api_cmd_track.c
+++ b/src/lib/testing_api_cmd_track.c
@@ -29,66 +29,126 @@
 #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;
 
+  /**
+   * CURL context.
+   */
   struct GNUNET_CURL_Context *ctx;
 
+  /**
+   * Expected HTTP response code.
+   */
   unsigned int http_status;
 
+  /**
+   * Not used at the moment.  FIXME: remove?
+   */
   const char *transfer_reference;
 
+  /**
+   * Reference to a "pay" CMD, used to get the order
+   * id to issue the track against.
+   */
   const char *pay_reference;
 
+  /**
+   * Not used at the moment.  FIXME: remove?
+   */
   const char *wire_fee;
 
-  /* This only accounts for the *first* wire transfer that
-   * payed back this transaction.  So far, this suffices to
-   * make the paygen work.  */
+  /**
+   * 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 wtid.  Some commands expect it - via
-   * appropriate traits - to be in binary form.
+   * Binary form of @a wtid_str, expected by other commands
+   * in this form.  FIXME: ponder if one of the forms (string
+   * or binary) should be fired from this state.
    */
   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.
+ */
 struct TrackTransferState
 {
 
+  /**
+   * Handle for a "track transfer" request.
+   */
   struct TALER_MERCHANT_TrackTransferHandle *tth;
 
+  /**
+   * The interpreter state.
+   */
   struct TALER_TESTING_Interpreter *is;
 
+  /** 
+   * Base URL of the merchant serving the request.
+   */
   const char *merchant_url;
 
+  /**
+   * CURL context.
+   */
   struct GNUNET_CURL_Context *ctx;
 
+  /**
+   * Expected HTTP response code.
+   */
   unsigned int http_status;
 
+
+  /**
+   * Reference for a "check bank" CMD.  It offers the
+   * WTID to track.
+   */
   const char *check_bank_reference;
 
   /**
-   * #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.
+   * FIXME currently not used.
    */
   const char *pay_reference;
 };
 
 /**
- * Function called with detailed wire transfer data.
+ * 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,
@@ -151,7 +211,8 @@ track_transaction_cb (void *cls,
 }
 
 /**
- * Callback for a /track/transfer operation
+ * Callback for a /track/transfer operation, only checks if
+ * response code is the expected one.
  *
  * @param cls closure for this function
  * @param http_status HTTP response code returned by the server
@@ -209,14 +270,12 @@ track_transfer_cb
 
 
 /**
- * Runs the command.  Note that upon return, the interpreter
- * will not automatically run the next command, as the command
- * may continue asynchronously in other scheduler tasks.  Thus,
- * the command must ensure to eventually call
- * #TALER_TESTING_interpreter_next() or
- * #TALER_TESTING_interpreter_fail().
+ * Run the "track transfer" CMD.
+ *
  *
- * @param is interpreter state
+ * @param cls closure.
+ * @param cmd command being run now.
+ * @param is interpreter state.
  */
 static void
 track_transfer_run (void *cls,
@@ -251,14 +310,12 @@ track_transfer_run (void *cls,
 }
 
 /**
- * Runs the command.  Note that upon return, the interpreter
- * will not automatically run the next command, as the command
- * may continue asynchronously in other scheduler tasks.  Thus,
- * the command must ensure to eventually call
- * #TALER_TESTING_interpreter_next() or
- * #TALER_TESTING_interpreter_fail().
+ * Run the "track transaction" CMD.
  *
- * @param is interpreter state
+ *
+ * @param cls closure.
+ * @param cmd command being run now.
+ * @param is interpreter state.
  */
 static void
 track_transaction_run (void *cls,
@@ -293,10 +350,11 @@ track_transaction_run (void *cls,
 
 
 /**
- * Clean up after the command.  Run during forced termination
- * (CTRL-C) or test failure or test success.
+ * Free the state of a "track transfer" CMD, and possibly
+ * cancel a pending operation thereof.
  *
- * @param cls closure
+ * @param cls closure.
+ * @param cmd command being run.
  */
 static void
 track_transfer_cleanup (void *cls,
@@ -315,10 +373,11 @@ track_transfer_cleanup (void *cls,
 }
 
 /**
- * Clean up after the command.  Run during forced termination
- * (CTRL-C) or test failure or test success.
+ * Free the state of a "track transaction" CMD, and possibly
+ * cancel a pending operation thereof.
  *
- * @param cls closure
+ * @param cls closure.
+ * @param cmd command being run.
  */
 static void
 track_transaction_cleanup (void *cls,
@@ -342,6 +401,17 @@ track_transaction_cleanup (void *cls,
 }
 
 
+/**
+ * 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,
                           void **ret,
@@ -374,7 +444,16 @@ track_transaction_traits (void *cls,
 }
 
 /**
- * FIXME
+ * Define a "track transaction" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ *        /track/transaction request.
+ * @param ctx CURL context.
+ * @param http_status expected HTTP response code.
+ * @param transfer_reference FIXME not used.
+ * @param pay_reference used to retrieve the order id to track.
+ * @param wire_fee FIXME not used.
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_track_transaction
@@ -409,7 +488,17 @@ TALER_TESTING_cmd_merchant_track_transaction
 
 
 /**
- * FIXME
+ * Define a "track transfer" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ *        /track/transfer request.
+ * @param ctx CURL context.
+ * @param http_status expected HTTP response code.
+ * @param check_bank_reference reference to a "check bank" CMD
+ *        that will provide the WTID and exchange URL to issue
+ *        the track against.
+ * @param pay_reference FIXME not used.
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_track_transfer
diff --git a/src/merchant-tools/taler-merchant-generate-payments_new.c 
b/src/merchant-tools/taler-merchant-generate-payments_new.c
index a92c8c0..4039d85 100644
--- a/src/merchant-tools/taler-merchant-generate-payments_new.c
+++ b/src/merchant-tools/taler-merchant-generate-payments_new.c
@@ -87,7 +87,7 @@ static unsigned int payments_number = 1;
 /**
  * How many /tracks operation we want to perform.
  */
-static unsigned int tracks_number;
+static unsigned int tracks_number = 1;
 
 
 static const char *default_config_file;

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



reply via email to

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