From 84d7b090aadde0c8d85384180feb2084744d11a7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 31 Oct 2020 00:50:51 +0100 Subject: fix FIXME, get taler-merchant-benchmark to kind-of work in ordinary mode --- .../taler-merchant-httpd_private-post-transfers.c | 6 +++ src/merchant-tools/taler-merchant-benchmark.c | 49 +++++++++++++--------- src/testing/testing_api_cmd_get_transfers.c | 12 +++++- src/testing/testing_api_cmd_post_orders.c | 2 +- src/testing/testing_api_cmd_post_transfers.c | 38 +++++++++++++---- 5 files changed, 78 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index d12156f8..92e3be36 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -1035,10 +1035,16 @@ fetch: ptc->payto_uri, &account_serial); if (0 >= qs) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Bank account `%s' not configured for instance `%s'\n", + ptc->payto_uri, + ptc->hc->instance->settings.id); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, TALER_EC_POST_TRANSFERS_ACCOUNT_NOT_FOUND, ptc->payto_uri); + } } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c index b17fe83b..86c2d2bb 100644 --- a/src/merchant-tools/taler-merchant-benchmark.c +++ b/src/merchant-tools/taler-merchant-benchmark.c @@ -36,7 +36,7 @@ #include #include "taler_merchant_testing_lib.h" -#define PAYTO_I1 "payto://x-taler-bank/localhost/3" +#define PAYTO_I1 "payto://x-taler-bank/localhost/42" /** * Maximum length of an amount (value plus currency string) needed by the test. @@ -51,7 +51,7 @@ #define MAX_ORDER_LEN (MAX_AMOUNT_LEN * 4 + 2048) -/* Error codes. */ +/* Error codes. */ enum PaymentGeneratorError { PG_SUCCESS = 0, @@ -222,7 +222,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1", merchant_url, MHD_HTTP_OK, - "order-worth-5", + NULL, /* random order ID please */ GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_FOREVER_ABS, "EUR:5.0"), @@ -259,12 +259,14 @@ run (void *cls, TALER_TESTING_cmd_exec_aggregator ("aggregate-1", cfg_filename), + TALER_TESTING_cmd_exec_transfer ("transfer-1", + cfg_filename), TALER_TESTING_cmd_merchant_post_transfer ( "post-transfer-1", &bc.exchange_auth, bc.exchange_auth.wire_gateway_url, merchant_url, - "EUR:4.98", /* FIXME: check amount! */ + "EUR:4.98", MHD_HTTP_OK, "deposit-simple-2", NULL), @@ -272,7 +274,7 @@ run (void *cls, merchant_url, bc.user42_payto, MHD_HTTP_OK, - "post-transaction-1", + "post-transfer-1", NULL), TALER_TESTING_cmd_rewind_ip ("rewind-tracks", "track-transfer-1", @@ -353,6 +355,8 @@ run (void *cls, NULL), TALER_TESTING_cmd_exec_aggregator ("aggregate-twocoins", cfg_filename), + TALER_TESTING_cmd_exec_transfer ("transfer-twocoins", + cfg_filename), TALER_TESTING_cmd_rewind_ip ("rewind-twocoins", "create-reserve-2", twocoins_number), @@ -392,7 +396,7 @@ int main (int argc, char *const *argv) { - char *loglev = "INFO"; + char *loglev = NULL; char *logfile = NULL; char *exchange_account = NULL; char *alt_instance_id = NULL; @@ -404,11 +408,22 @@ main (int argc, GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION), GNUNET_GETOPT_option_help ("Runs benchmark logic against merchant backend. " "Must be used with either 'ordinary' or 'corner' sub-commands."), + GNUNET_GETOPT_option_string ('l', + "logfile", + "LF", + "will log to file LF", + &logfile), + GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_OPTION_END }; struct GNUNET_GETOPT_CommandLineOption corner_options[] = { - GNUNET_GETOPT_option_help ("Populate databases with corner case payments"), + GNUNET_GETOPT_option_string ('l', + "logfile", + "LF", + "will log to file LF", + &logfile), GNUNET_GETOPT_option_loglevel (&loglev), + GNUNET_GETOPT_option_help ("Populate databases with corner case payments"), GNUNET_GETOPT_option_uint ('u', "unaggregated-number", "UN", @@ -447,19 +462,19 @@ main (int argc, " as they would get those far future ones" " aggregated too.", &alt_instance_id)), + GNUNET_GETOPT_OPTION_END + }; + struct GNUNET_GETOPT_CommandLineOption ordinary_options[] = { GNUNET_GETOPT_option_string ('l', "logfile", "LF", "will log to file LF", &logfile), - GNUNET_GETOPT_OPTION_END - }; - struct GNUNET_GETOPT_CommandLineOption ordinary_options[] = { + GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_cfgfile (&cfg_filename), GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION), GNUNET_GETOPT_option_help ("Generate Taler ordinary payments" " to populate the databases"), - GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_mandatory ( GNUNET_GETOPT_option_string ('e', "exchange-account", @@ -481,20 +496,11 @@ main (int argc, "TN", "will perform TN /track operations, defaults to 1", &tracks_number), - GNUNET_GETOPT_option_string ('l', - "logfile", - "LF", - "will log to file LF", - &logfile), GNUNET_GETOPT_OPTION_END }; const char *default_config_file; default_config_file = GNUNET_OS_project_data_get ()->user_config_file; - loglev = NULL; - GNUNET_log_setup ("taler-merchant-benchmark", - loglev, - logfile); options = root_options; if (NULL != argv[1]) { @@ -524,6 +530,9 @@ main (int argc, if (0 == result) return PG_SUCCESS; } + GNUNET_log_setup ("taler-merchant-benchmark", + loglev, + logfile); if ( (! ordinary) && (! corner) ) { diff --git a/src/testing/testing_api_cmd_get_transfers.c b/src/testing/testing_api_cmd_get_transfers.c index 19e198af..3c0181cb 100644 --- a/src/testing/testing_api_cmd_get_transfers.c +++ b/src/testing/testing_api_cmd_get_transfers.c @@ -124,6 +124,14 @@ get_transfers_cb ( transfer_cmd = TALER_TESTING_interpreter_lookup_command ( gts->is, gts->transfers[i]); + if (NULL == transfer_cmd) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Command `%s' not found!\n", + gts->transfers[i]); + TALER_TESTING_interpreter_fail (gts->is); + return; + } { const struct TALER_WireTransferIdentifierRawP *wtid; @@ -163,7 +171,9 @@ get_transfers_cb ( transfers[i].payto_uri)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Wire transfer payto uri does not match\n"); + "Wire transfer payto uri does not match: %s != %s\n", + payto_uri, + transfers[i].payto_uri); TALER_TESTING_interpreter_fail (gts->is); return; } diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c index b4a56ee3..8ccfb005 100644 --- a/src/testing/testing_api_cmd_post_orders.c +++ b/src/testing/testing_api_cmd_post_orders.c @@ -629,7 +629,7 @@ mark_forgettable (void *cls, /** * Constructs the json for a POST order request. * - * @param order_id the name of the order to add. + * @param order_id the name of the order to add, can be NULL. * @param refund_deadline the deadline for refunds on this order. * @param pay_deadline the deadline for payment on this order. * @param amount the amount this order is for. diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c index 5faba8ea..1fa9dfc0 100644 --- a/src/testing/testing_api_cmd_post_transfers.c +++ b/src/testing/testing_api_cmd_post_transfers.c @@ -59,6 +59,11 @@ struct PostTransfersState */ char *exchange_url; + /** + * Credit account of the merchant (set once @e found is set). + */ + char *credit_account; + /** * Payto URI to filter on. */ @@ -154,6 +159,11 @@ transfers_cb (void *cls, { pts->execution_time = execution_time; pts->wire_fee = *wire_fee; + fprintf (stderr, + "FIXME"); + json_dumpf (hr->reply, + stderr, + 0); #if FIXME_WRITE_PROPPER_CHECK_OF_RETURNED_DATA_HERE /* this code is some legacy logic that is close to what we need but needs to be updated to the current API */ @@ -291,7 +301,8 @@ transfers_cb (void *cls, default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %d.\n", + hr->http_status); } TALER_TESTING_interpreter_next (pts->is); } @@ -316,7 +327,7 @@ post_transfers_traits (void *cls, struct PostTransfersState *pts = cls; struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_wtid (0, &pts->wtid), - TALER_TESTING_make_trait_string (0, pts->payto_uri), + TALER_TESTING_make_trait_string (0, pts->credit_account), TALER_TESTING_make_trait_amount_obj (0, &pts->credit_amount), TALER_TESTING_make_trait_amount_obj (1, &pts->wire_fee), TALER_TESTING_make_trait_string (1, pts->exchange_url), @@ -368,11 +379,18 @@ debit_cb ( return GNUNET_OK; } GNUNET_assert (NULL != pts->exchange_url); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Bank transfer found, checking with merchant backend at %s about %s from %s to %s with %s\n", + pts->merchant_url, + TALER_amount2s (&pts->credit_amount), + pts->payto_uri, + pts->exchange_url, + TALER_B2S (&pts->wtid)); pts->pth = TALER_MERCHANT_transfers_post (pts->is->ctx, pts->merchant_url, &pts->credit_amount, &pts->wtid, - pts->payto_uri, + pts->credit_account, pts->exchange_url, &transfers_cb, pts); @@ -387,15 +405,16 @@ debit_cb ( } if (pts->found) return GNUNET_OK; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Bank reports transfer of %s to %s\n", + TALER_amount2s (&details->amount), + details->credit_account_url); if (0 != TALER_amount_cmp (&pts->credit_amount, &details->amount)) return GNUNET_OK; - if ( (NULL != pts->payto_uri) && - (0 != strcasecmp (pts->payto_uri, - details->credit_account_url)) ) - return GNUNET_OK; pts->found = true; pts->wtid = details->wtid; + pts->credit_account = GNUNET_strdup (details->credit_account_url); pts->exchange_url = GNUNET_strdup (details->exchange_base_url); return GNUNET_OK; } @@ -417,6 +436,10 @@ post_transfers_run (void *cls, struct PostTransfersState *pts = cls; pts->is = is; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Looking for transfer of %s from %s at bank\n", + TALER_amount2s (&pts->credit_amount), + pts->payto_uri); pts->dhh = TALER_BANK_debit_history (is->ctx, &pts->auth, UINT64_MAX, @@ -456,6 +479,7 @@ post_transfers_cleanup (void *cls, pts->deposits_length, 0); GNUNET_free (pts->exchange_url); + GNUNET_free (pts->credit_account); GNUNET_free (pts); } -- cgit v1.2.3