diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-06-07 23:11:05 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-06-07 23:11:05 +0200 |
commit | a2dde02b64a8ee75c9243632eb45a6ceb9b62dd5 (patch) | |
tree | 378cb6aefaf7f00894a7c8916fad9c3de84e31b4 /src/testing/testing_api_cmd_withdraw.c | |
parent | 015b08b0489d72f3fda587eec900bc4193a6a57e (diff) | |
download | exchange-a2dde02b64a8ee75c9243632eb45a6ceb9b62dd5.tar.xz |
major libtalertesting API refactoring, including no longer having taler-specific logic in the test engine core
Diffstat (limited to 'src/testing/testing_api_cmd_withdraw.c')
-rw-r--r-- | src/testing/testing_api_cmd_withdraw.c | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index 8d53f4d07..8188eeae9 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -67,6 +67,11 @@ struct WithdrawState const char *reuse_coin_key_ref; /** + * Our command. + */ + const struct TALER_TESTING_Command *cmd; + + /** * String describing the denomination value we should withdraw. * A corresponding denomination key must exist in the exchange's * offerings. Can be NULL if @e pk is set instead. @@ -220,8 +225,7 @@ do_retry (void *cls) struct WithdrawState *ws = cls; ws->retry_task = NULL; - ws->is->commands[ws->is->ip].last_req_time - = GNUNET_TIME_absolute_get (); + TALER_TESTING_touch_cmd (ws->is); withdraw_run (ws, NULL, ws->is); @@ -272,25 +276,15 @@ reserve_withdraw_cb (void *cls, UNKNOWN_MAX_BACKOFF); ws->total_backoff = GNUNET_TIME_relative_add (ws->total_backoff, ws->backoff); - ws->is->commands[ws->is->ip].num_tries++; + TALER_TESTING_inc_tries (ws->is); ws->retry_task = GNUNET_SCHEDULER_add_delayed (ws->backoff, &do_retry, ws); return; } } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u/%d to command %s in %s:%u\n", - wr->hr.http_status, - (int) wr->hr.ec, - TALER_TESTING_interpreter_get_current_label (is), - __FILE__, - __LINE__); - json_dumpf (wr->hr.reply, - stderr, - 0); - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); + TALER_TESTING_unexpected_status (is, + wr->hr.http_status); return; } switch (wr->hr.http_status) @@ -305,9 +299,9 @@ reserve_withdraw_cb (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total withdraw backoff for %s was %s\n", - is->commands[is->ip].label, + ws->cmd->label, GNUNET_STRINGS_relative_time_to_string (ws->total_backoff, - GNUNET_YES)); + true)); } break; case MHD_HTTP_FORBIDDEN: @@ -353,8 +347,9 @@ withdraw_run (void *cls, const struct TALER_ReservePrivateKeyP *rp; const struct TALER_TESTING_Command *create_reserve; const struct TALER_EXCHANGE_DenomPublicKey *dpk; + struct TALER_EXCHANGE_Handle *exchange; - (void) cmd; + ws->cmd = cmd; ws->is = is; create_reserve = TALER_TESTING_interpreter_lookup_command ( @@ -374,9 +369,12 @@ withdraw_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } + exchange = TALER_TESTING_get_exchange (is); + if (NULL == exchange) + return; if (NULL == ws->exchange_url) ws->exchange_url - = GNUNET_strdup (TALER_EXCHANGE_get_base_url (is->exchange)); + = GNUNET_strdup (TALER_EXCHANGE_get_base_url (exchange)); ws->reserve_priv = *rp; GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv, &ws->reserve_pub.eddsa_pub); @@ -412,7 +410,7 @@ withdraw_run (void *cls, if (NULL == ws->pk) { - dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange), + dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (exchange), &ws->amount, ws->age > 0); if (NULL == dpk) @@ -445,7 +443,7 @@ withdraw_run (void *cls, .ps = &ws->ps, .ach = ws->h_age_commitment }; - ws->wsh = TALER_EXCHANGE_withdraw (is->exchange, + ws->wsh = TALER_EXCHANGE_withdraw (exchange, rp, &wci, &reserve_withdraw_cb, @@ -475,9 +473,8 @@ withdraw_cleanup (void *cls, if (NULL != ws->wsh) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %s did not complete\n", - cmd->label); + TALER_TESTING_command_incomplete (ws->is, + cmd->label); TALER_EXCHANGE_withdraw_cancel (ws->wsh); ws->wsh = NULL; } @@ -544,12 +541,9 @@ withdraw_traits (void *cls, TALER_TESTING_make_trait_reserve_pub (&ws->reserve_pub), TALER_TESTING_make_trait_amount (&ws->amount), TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row), - TALER_TESTING_make_trait_h_payto ( - &ws->h_payto), - TALER_TESTING_make_trait_payto_uri ( - (const char **) &ws->reserve_payto_uri), - TALER_TESTING_make_trait_exchange_url ( - (const char **) &ws->exchange_url), + TALER_TESTING_make_trait_h_payto (&ws->h_payto), + TALER_TESTING_make_trait_payto_uri (ws->reserve_payto_uri), + TALER_TESTING_make_trait_exchange_url (ws->exchange_url), TALER_TESTING_make_trait_age_commitment_proof (0, ws->age_commitment_proof), TALER_TESTING_make_trait_h_age_commitment (0, @@ -570,13 +564,12 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_withdraw_amount (const char *label, const char *reserve_reference, const char *amount, - const uint8_t age, + uint8_t age, unsigned int expected_response_code) { struct WithdrawState *ws; ws = GNUNET_new (struct WithdrawState); - ws->age = age; if (0 < age) { @@ -605,8 +598,8 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, label); GNUNET_assert (0); } - - TALER_age_commitment_hash (&acp->commitment,hac); + TALER_age_commitment_hash (&acp->commitment, + hac); ws->age_commitment_proof = acp; ws->h_age_commitment = hac; } |