summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_wire_add.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_wire_add.c')
-rw-r--r--src/testing/testing_api_cmd_wire_add.c86
1 files changed, 62 insertions, 24 deletions
diff --git a/src/testing/testing_api_cmd_wire_add.c b/src/testing/testing_api_cmd_wire_add.c
index f36eaa85b..d2a15894a 100644
--- a/src/testing/testing_api_cmd_wire_add.c
+++ b/src/testing/testing_api_cmd_wire_add.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020-2023 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
@@ -67,27 +67,21 @@ struct WireAddState
* if the response code is acceptable.
*
* @param cls closure.
- * @param hr HTTP response details
+ * @param wer response details
*/
static void
wire_add_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementWireEnableResponse *wer)
{
struct WireAddState *ds = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &wer->hr;
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- hr->http_status,
- ds->is->commands[ds->is->ip].label,
- __FILE__,
- __LINE__);
- json_dumpf (hr->reply,
- stderr,
- 0);
- TALER_TESTING_interpreter_fail (ds->is);
+ TALER_TESTING_unexpected_status (ds->is,
+ hr->http_status,
+ ds->expected_response_code);
return;
}
TALER_TESTING_interpreter_next (ds->is);
@@ -109,12 +103,31 @@ wire_add_run (void *cls,
struct WireAddState *ds = cls;
struct TALER_MasterSignatureP master_sig1;
struct TALER_MasterSignatureP master_sig2;
- struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Timestamp now;
+ json_t *credit_rest;
+ json_t *debit_rest;
+ const char *exchange_url;
(void) cmd;
- now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
+ {
+ const struct TALER_TESTING_Command *exchange_cmd;
+
+ exchange_cmd = TALER_TESTING_interpreter_get_command (is,
+ "exchange");
+ if (NULL == exchange_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_exchange_url (exchange_cmd,
+ &exchange_url));
+ }
+ now = GNUNET_TIME_timestamp_get ();
ds->is = is;
+ debit_rest = json_array ();
+ credit_rest = json_array ();
if (ds->bad_sig)
{
memset (&master_sig1,
@@ -126,23 +139,50 @@ wire_add_run (void *cls,
}
else
{
+ const struct TALER_TESTING_Command *exchange_cmd;
+ const struct TALER_MasterPrivateKeyP *master_priv;
+
+ exchange_cmd = TALER_TESTING_interpreter_get_command (is,
+ "exchange");
+ if (NULL == exchange_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_master_priv (exchange_cmd,
+ &master_priv));
TALER_exchange_offline_wire_add_sign (ds->payto_uri,
+ NULL,
+ debit_rest,
+ credit_rest,
now,
- &is->master_priv,
+ master_priv,
&master_sig1);
TALER_exchange_wire_signature_make (ds->payto_uri,
- &is->master_priv,
+ NULL,
+ debit_rest,
+ credit_rest,
+ master_priv,
&master_sig2);
}
ds->dh = TALER_EXCHANGE_management_enable_wire (
- is->ctx,
- is->exchange_url,
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
ds->payto_uri,
+ NULL,
+ debit_rest,
+ credit_rest,
now,
&master_sig1,
&master_sig2,
+ NULL,
+ 0LL,
&wire_add_cb,
ds);
+ json_decref (debit_rest);
+ json_decref (credit_rest);
if (NULL == ds->dh)
{
GNUNET_break (0);
@@ -167,10 +207,8 @@ wire_add_cleanup (void *cls,
if (NULL != ds->dh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command %u (%s) did not complete\n",
- ds->is->ip,
- cmd->label);
+ TALER_TESTING_command_incomplete (ds->is,
+ cmd->label);
TALER_EXCHANGE_management_enable_wire_cancel (ds->dh);
ds->dh = NULL;
}