Commenting the "wire" CMD.

This commit is contained in:
Marcello Stanisci 2018-05-28 15:41:47 +02:00
parent d08d25e101
commit 027da0f1a3
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F

View File

@ -30,6 +30,10 @@
#include "taler_wire_lib.h" #include "taler_wire_lib.h"
#include "taler_testing_lib.h" #include "taler_testing_lib.h"
/**
* State for a "wire" CMD.
*/
struct WireState struct WireState
{ {
@ -39,7 +43,7 @@ struct WireState
struct TALER_EXCHANGE_WireHandle *wh; struct TALER_EXCHANGE_WireHandle *wh;
/** /**
* Which wire-method we expect are offered by the exchange. * Which wire-method we expect is offered by the exchange.
*/ */
const char *expected_method; const char *expected_method;
@ -72,16 +76,16 @@ struct WireState
/** /**
* Callbacks called with the result(s) of a wire format inquiry * Check whether the HTTP response code is acceptable, that
* request to the exchange. * the expected wire method is offered by the exchange, and
* that the wire fee is acceptable too.
* *
* @param cls closure with the interpreter state * @param cls closure.
* @param http_status HTTP response code, #MHD_HTTP_OK (200) * @param http_status HTTP response code.
* for successful request; 0 if the exchange's * @param ec taler-specific error code.
* reply is bogus (fails to follow the protocol) * @param accounts_len length of the @a accounts array.
* @param ec taler-specific error code, #TALER_EC_NONE on success * @param accounts list of wire accounts of the exchange,
* @param accounts_len length of the @a accounts array * NULL on error.
* @param accounts list of wire accounts of the exchange, NULL on error
*/ */
static void static void
wire_cb (void *cls, wire_cb (void *cls,
@ -91,7 +95,8 @@ wire_cb (void *cls,
const struct TALER_EXCHANGE_WireAccount *accounts) const struct TALER_EXCHANGE_WireAccount *accounts)
{ {
struct WireState *ws = cls; struct WireState *ws = cls;
struct TALER_TESTING_Command *cmd = &ws->is->commands[ws->is->ip]; struct TALER_TESTING_Command *cmd = \
&ws->is->commands[ws->is->ip];
struct TALER_Amount expected_fee; struct TALER_Amount expected_fee;
ws->wh = NULL; ws->wh = NULL;
@ -115,23 +120,25 @@ wire_cb (void *cls,
ws->method_found = GNUNET_OK; ws->method_found = GNUNET_OK;
if (NULL != ws->expected_fee) if (NULL != ws->expected_fee)
{ {
GNUNET_assert (GNUNET_OK == GNUNET_assert
TALER_string_to_amount (ws->expected_fee, (GNUNET_OK ==
&expected_fee)); TALER_string_to_amount (ws->expected_fee,
for (const struct TALER_EXCHANGE_WireAggregateFees *waf = accounts[i].fees; &expected_fee));
const struct TALER_EXCHANGE_WireAggregateFees *waf;
for (waf = accounts[i].fees;
NULL != waf; NULL != waf;
waf = waf->next) waf = waf->next)
{ {
if (0 != TALER_amount_cmp (&waf->wire_fee, if (0 != TALER_amount_cmp (&waf->wire_fee,
&expected_fee)) &expected_fee))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire fee missmatch to command %s\n", "Wire fee missmatch to command %s\n",
cmd->label); cmd->label);
TALER_TESTING_interpreter_fail (ws->is); TALER_TESTING_interpreter_fail (ws->is);
GNUNET_free (method); GNUNET_free (method);
return; return;
} }
} }
} }
} }
@ -153,14 +160,14 @@ wire_cb (void *cls,
/** /**
* Run the command. * Run the command.
* *
* @param cls closure, typically a #struct WireState. * @param cls closure.
* @param cmd the command to execute, a /wire one. * @param cmd the command to execute.
* @param i the interpreter state. * @param is the interpreter state.
*/ */
void void
wire_run (void *cls, wire_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *i) struct TALER_TESTING_Interpreter *is)
{ {
struct WireState *ws = cls; struct WireState *ws = cls;
ws->is = i; ws->is = i;
@ -171,9 +178,10 @@ wire_run (void *cls,
/** /**
* Cleanup the state. * Cleanup the state of a "wire" CMD, and possibly cancel a
* pending operation thereof.
* *
* @param cls closure, typically a #struct WireState. * @param cls closure.
* @param cmd the command which is being cleaned up. * @param cmd the command which is being cleaned up.
*/ */
void void
@ -195,7 +203,7 @@ wire_cleanup (void *cls,
} }
/** /**
* Create a /wire command. * Create a "wire" command.
* *
* @param label the command label. * @param label the command label.
* @param exchange the exchange to connect to. * @param exchange the exchange to connect to.
@ -205,7 +213,7 @@ wire_cleanup (void *cls,
* @param expected_response_code the HTTP response the exchange * @param expected_response_code the HTTP response the exchange
* should return. * should return.
* *
* @return the command to be executed by the interpreter. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_wire (const char *label, TALER_TESTING_cmd_wire (const char *label,