diff options
Diffstat (limited to 'src/testing/testing_api_cmd_get_transfers.c')
-rw-r--r-- | src/testing/testing_api_cmd_get_transfers.c | 111 |
1 files changed, 46 insertions, 65 deletions
diff --git a/src/testing/testing_api_cmd_get_transfers.c b/src/testing/testing_api_cmd_get_transfers.c index fe50c349..b5b05295 100644 --- a/src/testing/testing_api_cmd_get_transfers.c +++ b/src/testing/testing_api_cmd_get_transfers.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018, 2020 Taler Systems SA + Copyright (C) 2014-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 @@ -83,42 +83,42 @@ struct GetTransfersState * Check the result of our GET /transfers request to a merchant * * @param cls closure - * @param hr HTTP response details - * @param transfers_length length of the @a transfers array - * @param transfers array with details about the transfers we received + * @param gtr response details */ static void get_transfers_cb ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int transfers_length, - const struct TALER_MERCHANT_TransferData transfers[]) + const struct TALER_MERCHANT_GetTransfersResponse *gtr) { struct GetTransfersState *gts = cls; gts->gth = NULL; - if (gts->http_status != hr->http_status) + if (gts->http_status != gtr->hr.http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u (%d) to command %s\n", - hr->http_status, - (int) hr->ec, + gtr->hr.http_status, + (int) gtr->hr.ec, TALER_TESTING_interpreter_get_current_label (gts->is)); TALER_TESTING_interpreter_fail (gts->is); return; } - switch (hr->http_status) + switch (gtr->hr.http_status) { case MHD_HTTP_OK: - if (transfers_length != gts->transfers_length) + if (gtr->details.ok.transfers_length != gts->transfers_length) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Transfers length does not match\n"); + "Transfers length does not match (got %u/want %u)\n", + gtr->details.ok.transfers_length, + gts->transfers_length); TALER_TESTING_interpreter_fail (gts->is); return; } - for (unsigned int i = 0; i < transfers_length; ++i) + for (unsigned int i = 0; i < gtr->details.ok.transfers_length; ++i) { + const struct TALER_MERCHANT_TransferData *transfer + = >r->details.ok.transfers[i]; const struct TALER_TESTING_Command *transfer_cmd; transfer_cmd = TALER_TESTING_interpreter_lookup_command ( @@ -145,7 +145,7 @@ get_transfers_cb ( return; } if (0 != GNUNET_memcmp (wtid, - &transfers[i].wtid)) + &transfer->wtid)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer id does not match\n"); @@ -154,10 +154,10 @@ get_transfers_cb ( } TALER_TESTING_cmd_merchant_post_transfer_set_serial ( (struct TALER_TESTING_Command *) transfer_cmd, - transfers[i].credit_serial); + transfer->credit_serial); } { - const char **payto_uri; + const char *payto_uri; if (GNUNET_OK != TALER_TESTING_get_trait_credit_payto_uri (transfer_cmd, @@ -168,13 +168,13 @@ get_transfers_cb ( TALER_TESTING_interpreter_fail (gts->is); return; } - if (0 != strcmp (*payto_uri, - transfers[i].payto_uri)) + if (0 != strcmp (payto_uri, + transfer->payto_uri)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer payto uri does not match: %s != %s\n", - *payto_uri, - transfers[i].payto_uri); + payto_uri, + transfer->payto_uri); TALER_TESTING_interpreter_fail (gts->is); return; } @@ -193,9 +193,9 @@ get_transfers_cb ( } if ( (GNUNET_OK != TALER_amount_cmp_currency (credit_amount, - &transfers[i].credit_amount)) || + &transfer->credit_amount)) || (0 != TALER_amount_cmp (credit_amount, - &transfers[i].credit_amount))) + &transfer->credit_amount))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer credit amount does not match\n"); @@ -204,7 +204,7 @@ get_transfers_cb ( } } { - const char **exchange_url; + const char *exchange_url; if (GNUNET_OK != TALER_TESTING_get_trait_exchange_url (transfer_cmd, @@ -215,8 +215,8 @@ get_transfers_cb ( TALER_TESTING_interpreter_fail (gts->is); return; } - if (0 != strcmp (*exchange_url, - transfers[i].exchange_url)) + if (0 != strcmp (exchange_url, + transfer->exchange_url)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer exchange url does not match\n"); @@ -224,34 +224,13 @@ get_transfers_cb ( return; } } - { - const struct GNUNET_TIME_Timestamp *execution_time; - - if (GNUNET_OK != - TALER_TESTING_get_trait_timestamp (transfer_cmd, - 0, - &execution_time)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not fetch wire transfer execution time\n"); - TALER_TESTING_interpreter_fail (gts->is); - return; - } - if (GNUNET_TIME_timestamp_cmp (*execution_time, - !=, - transfers[i].execution_time)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Wire transfer execution time does not match\n"); - TALER_TESTING_interpreter_fail (gts->is); - return; - } - } } break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u.\n", + gtr->hr.http_status); + break; } TALER_TESTING_interpreter_next (gts->is); } @@ -272,16 +251,17 @@ get_transfers_run (void *cls, struct GetTransfersState *gts = cls; gts->is = is; - gts->gth = TALER_MERCHANT_transfers_get (is->ctx, - gts->merchant_url, - gts->payto_uri, - GNUNET_TIME_UNIT_FOREVER_TS, - GNUNET_TIME_UNIT_ZERO_TS, - INT64_MAX, - 0, - TALER_EXCHANGE_YNA_ALL, - &get_transfers_cb, - gts); + gts->gth = TALER_MERCHANT_transfers_get ( + TALER_TESTING_interpreter_get_context (is), + gts->merchant_url, + gts->payto_uri, + GNUNET_TIME_UNIT_FOREVER_TS, + GNUNET_TIME_UNIT_ZERO_TS, + INT64_MAX, + 0, + TALER_EXCHANGE_YNA_ALL, + &get_transfers_cb, + gts); GNUNET_assert (NULL != gts->gth); } @@ -313,11 +293,12 @@ get_transfers_cleanup (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_merchant_get_transfers (const char *label, - const char *merchant_url, - const char *payto_uri, - unsigned int http_code, - ...) +TALER_TESTING_cmd_merchant_get_transfers ( + const char *label, + const char *merchant_url, + const char *payto_uri, + unsigned int http_code, + ...) { struct GetTransfersState *gts; |