diff options
Diffstat (limited to 'src/testing/testing_api_cmd_bank_transfer.c')
-rw-r--r-- | src/testing/testing_api_cmd_bank_transfer.c | 93 |
1 files changed, 30 insertions, 63 deletions
diff --git a/src/testing/testing_api_cmd_bank_transfer.c b/src/testing/testing_api_cmd_bank_transfer.c index 565d6e460..bfb29e120 100644 --- a/src/testing/testing_api_cmd_bank_transfer.c +++ b/src/testing/testing_api_cmd_bank_transfer.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2020 Taler Systems SA + Copyright (C) 2018-2021 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 @@ -97,7 +97,7 @@ struct TransferState /** * Timestamp of the transaction (as returned from the bank). */ - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; /** * Configuration filename. Used to get the tip reserve key @@ -149,8 +149,7 @@ do_retry (void *cls) struct TransferState *fts = cls; fts->retry_task = NULL; - fts->is->commands[fts->is->ip].last_req_time - = GNUNET_TIME_absolute_get (); + TALER_TESTING_touch_cmd (fts->is); transfer_run (fts, NULL, fts->is); @@ -163,43 +162,35 @@ do_retry (void *cls) * acceptable. * * @param cls closure with the interpreter state - * @param http_status HTTP response code, #MHD_HTTP_OK (200) for - * successful status request; 0 if the exchange's reply is - * bogus (fails to follow the protocol) - * @param ec taler-specific error code, #TALER_EC_NONE on success - * @param serial_id unique ID of the wire transfer - * @param timestamp time stamp of the transaction made. + * @param tr response details */ static void confirmation_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - uint64_t serial_id, - struct GNUNET_TIME_Absolute timestamp) + const struct TALER_BANK_TransferResponse *tr) { struct TransferState *fts = cls; struct TALER_TESTING_Interpreter *is = fts->is; fts->weh = NULL; - if (MHD_HTTP_OK != http_status) + if (MHD_HTTP_OK != tr->http_status) { if (0 != fts->do_retry) { fts->do_retry--; - if ( (0 == http_status) || - (TALER_EC_GENERIC_DB_SOFT_FAILURE == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + if ( (0 == tr->http_status) || + (TALER_EC_GENERIC_DB_SOFT_FAILURE == tr->ec) || + (MHD_HTTP_INTERNAL_SERVER_ERROR == tr->http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying transfer failed with %u/%d\n", - http_status, - (int) ec); + tr->http_status, + (int) tr->ec); /* on DB conflicts, do not use backoff */ - if (TALER_EC_GENERIC_DB_SOFT_FAILURE == ec) + if (TALER_EC_GENERIC_DB_SOFT_FAILURE == tr->ec) fts->backoff = GNUNET_TIME_UNIT_ZERO; else fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff); - fts->is->commands[fts->is->ip].num_tries++; + TALER_TESTING_inc_tries (fts->is); fts->retry_task = GNUNET_SCHEDULER_add_delayed (fts->backoff, &do_retry, @@ -207,17 +198,14 @@ confirmation_cb (void *cls, return; } } - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Bank returned HTTP status %u/%d\n", - http_status, - (int) ec); - TALER_TESTING_interpreter_fail (is); + TALER_TESTING_unexpected_status (is, + tr->http_status, + MHD_HTTP_OK); return; } - fts->serial_id = serial_id; - fts->timestamp = timestamp; + fts->serial_id = tr->details.ok.row_id; + fts->timestamp = tr->details.ok.timestamp; TALER_TESTING_interpreter_next (is); } @@ -284,9 +272,8 @@ transfer_cleanup (void *cls, if (NULL != fts->weh) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %s did not complete\n", - cmd->label); + TALER_TESTING_command_incomplete (fts->is, + cmd->label); TALER_BANK_transfer_cancel (fts->weh); fts->weh = NULL; } @@ -310,7 +297,7 @@ transfer_cleanup (void *cls, * @param index index number of the object to offer. * @return #GNUNET_OK on success. */ -static int +static enum GNUNET_GenericReturnValue transfer_traits (void *cls, const void **ret, const char *trait, @@ -318,17 +305,16 @@ transfer_traits (void *cls, { struct TransferState *fts = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL, - fts->exchange_base_url), + TALER_TESTING_make_trait_exchange_url ( + fts->exchange_base_url), TALER_TESTING_make_trait_bank_row (&fts->serial_id), - TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT, - fts->payto_credit_account), - TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT, - fts->payto_debit_account), - TALER_TESTING_make_trait_amount_obj (0, &fts->amount), - TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp), - TALER_TESTING_make_trait_wtid (0, - &fts->wtid), + TALER_TESTING_make_trait_credit_payto_uri ( + fts->payto_credit_account), + TALER_TESTING_make_trait_debit_payto_uri ( + fts->payto_debit_account), + TALER_TESTING_make_trait_amount (&fts->amount), + TALER_TESTING_make_trait_timestamp (0, &fts->timestamp), + TALER_TESTING_make_trait_wtid (&fts->wtid), TALER_TESTING_trait_end () }; @@ -339,18 +325,6 @@ transfer_traits (void *cls, } -/** - * Create transfer command. - * - * @param label command label. - * @param amount amount to transfer. - * @param auth authentication data to use - * @param payto_debit_account which account sends money. - * @param payto_credit_account which account receives money. - * @param wtid wire transfer identifier to use - * @param exchange_base_url exchange URL to use - * @return the command. - */ struct TALER_TESTING_Command TALER_TESTING_cmd_transfer (const char *label, const char *amount, @@ -394,13 +368,6 @@ TALER_TESTING_cmd_transfer (const char *label, } -/** - * Modify a transfer command to enable retries when the reserve is not yet - * full or we get other transient errors from the bank. - * - * @param cmd a fakebank transfer command - * @return the command with retries enabled - */ struct TALER_TESTING_Command TALER_TESTING_cmd_transfer_retry (struct TALER_TESTING_Command cmd) { |