diff options
Diffstat (limited to 'src/testing/testing_api_cmd_set_wire_fee.c')
-rw-r--r-- | src/testing/testing_api_cmd_set_wire_fee.c | 113 |
1 files changed, 56 insertions, 57 deletions
diff --git a/src/testing/testing_api_cmd_set_wire_fee.c b/src/testing/testing_api_cmd_set_wire_fee.c index 613e0f713..460a71e40 100644 --- a/src/testing/testing_api_cmd_set_wire_fee.c +++ b/src/testing/testing_api_cmd_set_wire_fee.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020 Taler Systems SA + Copyright (C) 2020, 2022 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 @@ -77,27 +77,21 @@ struct WireFeeState * if the response code is acceptable. * * @param cls closure. - * @param hr HTTP response details + * @param sfr response details */ static void wire_add_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr) + const struct TALER_EXCHANGE_ManagementSetWireFeeResponse *sfr) { struct WireFeeState *ds = cls; + const struct TALER_EXCHANGE_HttpResponse *hr = &sfr->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); @@ -119,25 +113,41 @@ wire_add_run (void *cls, struct WireFeeState *ds = cls; struct TALER_MasterSignatureP master_sig; struct GNUNET_TIME_Absolute now; - struct GNUNET_TIME_Absolute start_time; - struct GNUNET_TIME_Absolute end_time; - struct TALER_Amount wire_fee; - struct TALER_Amount closing_fee; + struct GNUNET_TIME_Timestamp start_time; + struct GNUNET_TIME_Timestamp end_time; + struct TALER_WireFeeSet fees; + const char *exchange_url; (void) cmd; + { + 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)); + } ds->is = is; now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); - start_time = GNUNET_TIME_absolute_subtract (now, - GNUNET_TIME_UNIT_HOURS); - end_time = GNUNET_TIME_absolute_add (now, - GNUNET_TIME_UNIT_HOURS); + start_time = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_subtract (now, + GNUNET_TIME_UNIT_HOURS)); + end_time = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_add (now, + GNUNET_TIME_UNIT_HOURS)); if ( (GNUNET_OK != TALER_string_to_amount (ds->closing_fee, - &closing_fee)) || + &fees.closing)) || (GNUNET_OK != TALER_string_to_amount (ds->wire_fee, - &wire_fee)) ) + &fees.wire)) ) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -152,22 +162,34 @@ 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_fee_sign (ds->wire_method, start_time, end_time, - &wire_fee, - &closing_fee, - &is->master_priv, + &fees, + master_priv, &master_sig); } ds->dh = TALER_EXCHANGE_management_set_wire_fees ( - is->ctx, - is->exchange_url, + TALER_TESTING_interpreter_get_context (is), + exchange_url, ds->wire_method, start_time, end_time, - &wire_fee, - &closing_fee, + &fees, &master_sig, &wire_add_cb, ds); @@ -195,10 +217,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_set_wire_fees_cancel (ds->dh); ds->dh = NULL; } @@ -206,26 +226,6 @@ wire_add_cleanup (void *cls, } -/** - * Offer internal data from a "wire_add" CMD, to other commands. - * - * @param cls closure. - * @param[out] ret result. - * @param trait name of the trait. - * @param index index number of the object to offer. - * - * @return #GNUNET_OK on success. - */ -static int -wire_add_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - return GNUNET_NO; -} - - struct TALER_TESTING_Command TALER_TESTING_cmd_set_wire_fee (const char *label, const char *wire_method, @@ -247,8 +247,7 @@ TALER_TESTING_cmd_set_wire_fee (const char *label, .cls = ds, .label = label, .run = &wire_add_run, - .cleanup = &wire_add_cleanup, - .traits = &wire_add_traits + .cleanup = &wire_add_cleanup }; return cmd; |