diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2020-01-13 11:35:07 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2020-01-13 11:35:07 +0100 |
commit | e54402d392c25aa0476308d51bcc75ce84178dc3 (patch) | |
tree | 1b4b0e48876099f5959900e51133c4c76e12f022 | |
parent | adfd806648d1a58e7ab67f7988f6a4e98500a8a3 (diff) | |
download | merchant-e54402d392c25aa0476308d51bcc75ce84178dc3.tar.gz merchant-e54402d392c25aa0476308d51bcc75ce84178dc3.tar.bz2 merchant-e54402d392c25aa0476308d51bcc75ce84178dc3.zip |
fix compilation after exchange refactor
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 49 | ||||
-rw-r--r-- | src/lib/test_merchant_api.c | 175 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay.c | 16 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_refund_increase.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_refund_lookup.c | 2 | ||||
-rw-r--r-- | src/merchant-tools/Makefile.am | 1 | ||||
-rw-r--r-- | src/merchant-tools/taler-merchant-benchmark.c | 56 |
7 files changed, 153 insertions, 148 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 671aa978..a7241a32 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -27,9 +27,8 @@ #include <taler/taler_util.h> #include <taler/taler_json_lib.h> #include <taler/taler_mhd_lib.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_wire_plugin.h> #include <taler/taler_wire_lib.h> +#include <taler/taler_exchange_service.h> #include "taler_merchantdb_lib.h" #include "taler-merchant-httpd.h" #include "taler-merchant-httpd_mhd.h" @@ -719,10 +718,7 @@ wireformat_iterator_cb (void *cls, struct WireMethod *wm; char *payto; char *fn; - char *plugin_name; - struct TALER_WIRE_Plugin *plugin; json_t *j; - enum TALER_ErrorCode ec; struct GNUNET_HashCode jh_wire; char *wire_file_mode; @@ -755,49 +751,6 @@ wireformat_iterator_cb (void *cls, return; } - /* check payto://-URL is well-formed and matches plugin */ - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (iic->config, - section, - "PLUGIN", - &plugin_name)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - section, - "PLUGIN"); - GNUNET_free (payto); - iic->ret = GNUNET_SYSERR; - return; - } - if (NULL == - (plugin = TALER_WIRE_plugin_load (iic->config, - plugin_name))) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to load wire plugin `%s'\n", - plugin_name); - GNUNET_free (plugin_name); - GNUNET_free (payto); - iic->ret = GNUNET_SYSERR; - return; - } - if (TALER_EC_NONE != - (ec = plugin->wire_validate (plugin->cls, - payto))) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "payto:// URL `%s' not supported by plugin `%s'\n", - payto, - plugin_name); - GNUNET_free (plugin_name); - GNUNET_free (payto); - TALER_WIRE_plugin_unload (plugin); - iic->ret = GNUNET_SYSERR; - return; - } - TALER_WIRE_plugin_unload (plugin); - GNUNET_free (plugin_name); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (iic->config, section, diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index 10471ce5..a14f10cf 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -54,6 +54,16 @@ static const char *pickup_amounts_1[] = {"EUR:5", NULL}; */ static char *fakebank_url; +static struct TALER_WireTransferIdentifierRawP wtid; +static char *payer_url; +static char *payer_payto; +static struct TALER_BANK_AuthenticationData auth; +static char *exchange_payto; +static char *exchange_account_url; +static char *merchant_payto; +static struct TALER_TESTING_BankConfiguration bc; +static struct TALER_TESTING_ExchangeConfiguration ec; + /** * Merchant base URL. */ @@ -131,11 +141,12 @@ static struct GNUNET_CONTAINER_MultiHashMap *interned_strings; * @param url exchange_url */ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - fakebank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, \ - EXCHANGE_URL) + TALER_TESTING_cmd_transfer (label, amount, \ + payer_url, \ + &auth, \ + exchange_payto, \ + &wtid, \ + EXCHANGE_URL) /** * Run wire transfer of funds from some user's account to the @@ -232,7 +243,8 @@ run (void *cls, CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", "EUR:10.02"), /** - * Make a reserve exist, according to the previous + * Make a reserve exist, + * according to the previous * transfer. */ CMD_EXEC_WIREWATCH ("wirewatch-1"), @@ -240,8 +252,9 @@ run (void *cls, ("check_bank_transfer-2", EXCHANGE_URL, "EUR:10.02", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + payer_payto, // payer payto + exchange_payto), // payee exchange payto + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", "create-reserve-1", @@ -327,6 +340,7 @@ run (void *cls, "EUR:5", "EUR:4.99", "EUR:0.01"), + TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"), CMD_EXEC_AGGREGATOR ("run-aggregator"), @@ -334,8 +348,9 @@ run (void *cls, ("check_bank_transfer-498c", EXCHANGE_URL, "EUR:4.98", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + exchange_payto, + merchant_payto), + TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"), TALER_TESTING_cmd_end () }; @@ -412,36 +427,34 @@ run (void *cls, merchant_url, MHD_HTTP_OK, "check_bank_transfer-498c"), - TALER_TESTING_cmd_fakebank_transfer + TALER_TESTING_cmd_transfer ("create-reserve-2", - "EUR:1", - fakebank_url, - USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, - "user62", - "pass62", - EXCHANGE_URL), - TALER_TESTING_cmd_fakebank_transfer_with_ref + "EUR:1", + payer_url, + &auth, + exchange_payto, + &wtid, + EXCHANGE_URL), + TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-2b", "EUR:4.01", - fakebank_url, - USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, - "user62", - "pass62", - "create-reserve-2", - EXCHANGE_URL), + exchange_account_url, + &auth, + exchange_payto, + "create-reserve-2"), CMD_EXEC_WIREWATCH ("wirewatch-2"), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-2a", EXCHANGE_URL, "EUR:1", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + payer_payto, + exchange_payto), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-2b", EXCHANGE_URL, "EUR:4.01", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + payer_payto, + exchange_payto), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", "create-reserve-2", "EUR:5", @@ -459,8 +472,8 @@ run (void *cls, ("check_bank_transfer-498c-2", EXCHANGE_URL, "EUR:4.98", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + exchange_payto, + merchant_payto), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_merchant_track_transfer ("track-transfer-2", @@ -573,8 +586,8 @@ run (void *cls, ("check_bank_transfer-unincreased-refund", EXCHANGE_URL, "EUR:5.01", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + payer_payto, + exchange_payto), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unincreased-refund", @@ -617,8 +630,8 @@ run (void *cls, ("check_bank_transfer-unincreased-refund", EXCHANGE_URL, "EUR:4.98", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + exchange_payto, + merchant_payto), /* Actually try to pick up the refund from the * "unincreased proposal". */ @@ -641,24 +654,23 @@ run (void *cls, struct TALER_TESTING_Command tip[] = { /* Test tipping. */ - TALER_TESTING_cmd_fakebank_transfer_with_instance + TALER_TESTING_cmd_admin_add_incoming_with_instance ("create-reserve-tip-1", "EUR:20.04", - fakebank_url, - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO, - USER_LOGIN_NAME, - USER_LOGIN_PASS, + exchange_account_url, + &auth, + payer_payto, "tip", - EXCHANGE_URL, CONFIG_FILE), CMD_EXEC_WIREWATCH ("wirewatch-3"), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-tip-1", - EXCHANGE_URL, - "EUR:20.04", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), + EXCHANGE_URL, + "EUR:20.04", + payer_payto, + exchange_payto), TALER_TESTING_cmd_tip_authorize ("authorize-tip-1", merchant_url_internal ("tip"), @@ -724,24 +736,21 @@ run (void *cls, "EUR:10.02", // auth "EUR:10.02"), // ava - TALER_TESTING_cmd_fakebank_transfer_with_instance + TALER_TESTING_cmd_admin_add_incoming_with_instance ("create-reserve-insufficient-funds", "EUR:1.01", - fakebank_url, - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO, - USER_LOGIN_NAME, - USER_LOGIN_PASS, + exchange_account_url, + &auth, + payer_payto, "dtip", - EXCHANGE_URL, CONFIG_FILE), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-insufficient-tip-funds", EXCHANGE_URL, "EUR:1.01", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + payer_payto, + exchange_payto), CMD_EXEC_WIREWATCH ("wirewatch-insufficient-tip-funds"), @@ -826,8 +835,8 @@ run (void *cls, ("check_bank_transfer-tip-498c", EXCHANGE_URL, "EUR:4.98", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + exchange_payto, + merchant_payto), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-at-tips"), @@ -836,14 +845,13 @@ run (void *cls, struct TALER_TESTING_Command pay_again[] = { - TALER_TESTING_cmd_fakebank_transfer + TALER_TESTING_cmd_transfer ("create-reserve-10", "EUR:10.02", - fakebank_url, - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO, - USER_LOGIN_NAME, - USER_LOGIN_PASS, + payer_url, + &auth, + exchange_payto, + &wtid, EXCHANGE_URL), CMD_EXEC_WIREWATCH ("wirewatch-10"), @@ -851,7 +859,9 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-10", EXCHANGE_URL, - "EUR:10.02", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), + "EUR:10.02", + payer_payto, + exchange_payto), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10a", "create-reserve-10", @@ -910,8 +920,8 @@ run (void *cls, ("check_bank_transfer-9.97-10", EXCHANGE_URL, "EUR:9.97", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + exchange_payto, + merchant_payto), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-10"), @@ -928,8 +938,8 @@ run (void *cls, ("check_bank_transfer-11", EXCHANGE_URL, "EUR:10.02", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + payer_payto, + exchange_payto), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11a", "create-reserve-11", @@ -1064,11 +1074,35 @@ main (int argc, GNUNET_log_setup ("test-merchant-api", "DEBUG", NULL); - if (NULL == - (fakebank_url = TALER_TESTING_prepare_fakebank - (CONFIG_FILE, - "account-exchange"))) + if (GNUNET_OK != TALER_TESTING_prepare_fakebank (CONFIG_FILE, + "account-exchange", + &bc)) return 77; + + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf (&payer_url, + "%s/%d", + USER_ACCOUNT_NO)); + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf (&payer_payto, + "payto://x-taler-bank/%s/%d", + strchr (strchr (fakebank_url, '/') + 1, '/') + 1, + USER_ACCOUNT_NO)); + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf (&exchange_account_url, + "%s/%d", + fakebank_url, + EXCHANGE_ACCOUNT_NO)); + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf (&exchange_payto, + "payto://x-taler-bank/%s/%d", + strchr (strchr (fakebank_url, '/') + 1, '/') + 1, + EXCHANGE_ACCOUNT_NO)); + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf (&merchant_payto, + "payto://x-taler-bank/%s/%d", + strchr (strchr (fakebank_url, '/') + 1, '/') + 1, + MERCHANT_ACCOUNT_NO)); if (NULL == (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE))) return 77; @@ -1076,8 +1110,7 @@ main (int argc, TALER_TESTING_cleanup_files (CONFIG_FILE); switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, - &auditor_url, - &exchange_url)) + &ec)) { case GNUNET_SYSERR: GNUNET_break (0); diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c index d248dd5a..cc436905 100644 --- a/src/lib/testing_api_cmd_pay.c +++ b/src/lib/testing_api_cmd_pay.c @@ -736,11 +736,11 @@ pay_traits (void *cls, } { struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_amount + TALER_TESTING_make_trait_string (AMOUNT_WITH_FEE, ps->amount_with_fee), - TALER_TESTING_make_trait_amount + TALER_TESTING_make_trait_string (AMOUNT_WITHOUT_FEE, ps->amount_without_fee), - TALER_TESTING_make_trait_amount + TALER_TESTING_make_trait_string (REFUND_FEE, ps->refund_fee), TALER_TESTING_make_trait_proposal_reference (0, ps->proposal_reference), @@ -871,15 +871,15 @@ pay_abort_run (void *cls, (pay_cmd, 0, &coin_reference)) TALER_TESTING_FAIL (is); - if (GNUNET_OK != TALER_TESTING_get_trait_amount + if (GNUNET_OK != TALER_TESTING_get_trait_string (pay_cmd, AMOUNT_WITH_FEE, &amount_with_fee)) TALER_TESTING_FAIL (is); - if (GNUNET_OK != TALER_TESTING_get_trait_amount + if (GNUNET_OK != TALER_TESTING_get_trait_string (pay_cmd, AMOUNT_WITHOUT_FEE, &amount_without_fee)) TALER_TESTING_FAIL (is); - if (GNUNET_OK != TALER_TESTING_get_trait_amount + if (GNUNET_OK != TALER_TESTING_get_trait_string (pay_cmd, REFUND_FEE, &refund_fee)) TALER_TESTING_FAIL (is); @@ -1079,11 +1079,11 @@ pay_again_run (void *cls, (pay_cmd, 0, &proposal_reference)) TALER_TESTING_FAIL (is); - if (GNUNET_OK != TALER_TESTING_get_trait_amount + if (GNUNET_OK != TALER_TESTING_get_trait_string (pay_cmd, AMOUNT_WITH_FEE, &amount_with_fee)) TALER_TESTING_FAIL (is); - if (GNUNET_OK != TALER_TESTING_get_trait_amount + if (GNUNET_OK != TALER_TESTING_get_trait_string (pay_cmd, AMOUNT_WITHOUT_FEE, &amount_without_fee)) TALER_TESTING_FAIL (is); diff --git a/src/lib/testing_api_cmd_refund_increase.c b/src/lib/testing_api_cmd_refund_increase.c index 57f661b5..8a544d61 100644 --- a/src/lib/testing_api_cmd_refund_increase.c +++ b/src/lib/testing_api_cmd_refund_increase.c @@ -172,7 +172,7 @@ refund_increase_traits (void *cls, { struct RefundIncreaseState *ris = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_amount (0, + TALER_TESTING_make_trait_string (0, ris->refund_amount), TALER_TESTING_trait_end () }; diff --git a/src/lib/testing_api_cmd_refund_lookup.c b/src/lib/testing_api_cmd_refund_lookup.c index fa02d6a4..35703cd4 100644 --- a/src/lib/testing_api_cmd_refund_lookup.c +++ b/src/lib/testing_api_cmd_refund_lookup.c @@ -269,7 +269,7 @@ refund_lookup_cb (void *cls, (increase_cmd = TALER_TESTING_interpreter_lookup_command (rls->is, rls->increase_reference))) { - if (GNUNET_OK != TALER_TESTING_get_trait_amount + if (GNUNET_OK != TALER_TESTING_get_trait_string (increase_cmd, 0, &refund_amount)) TALER_TESTING_FAIL (rls->is); diff --git a/src/merchant-tools/Makefile.am b/src/merchant-tools/Makefile.am index bf52f500..00e3f883 100644 --- a/src/merchant-tools/Makefile.am +++ b/src/merchant-tools/Makefile.am @@ -26,6 +26,7 @@ taler_merchant_benchmark_LDADD = \ -ltalertesting \ -ltalerfakebank \ -ltalerbank \ + -ltalerwire \ -ltalerbanktesting \ -ltalerexchange \ -ltalerjson \ diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c index 49c3cdd7..d9c6dcc4 100644 --- a/src/merchant-tools/taler-merchant-benchmark.c +++ b/src/merchant-tools/taler-merchant-benchmark.c @@ -33,7 +33,6 @@ #include <taler/taler_bank_service.h> #include <taler/taler_fakebank_lib.h> #include <taler/taler_testing_lib.h> -#include <taler/taler_testing_bank_lib.h> #include <taler/taler_error_codes.h> #include "taler_merchant_testing_lib.h" @@ -55,26 +54,16 @@ enum PaymentGeneratorError /* Hard-coded params. Note, the bank is expected to * have the Tor user with account number 3 and password 'x'. - * - * This is not a problem _so far_, as the fakebank mocks logins, - * and the Python bank makes that account by default. */ -#define USER_ACCOUNT_NO 3 + */ +#define PAYER_URL "FIXME/3" #define EXCHANGE_ACCOUNT_NO 2 #define USER_LOGIN_NAME "Tor" #define USER_LOGIN_PASS "x" #define EXCHANGE_URL "http://example.com/" - #define FIRST_INSTRUCTION -1 #define TRACKS_INSTRUCTION 9 #define TWOCOINS_INSTRUCTION 5 -#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - bank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, \ - EXCHANGE_URL) - /** * Help string shown if NO subcommand is given on command line. */ @@ -180,6 +169,14 @@ static char *merchant_url; static char *currency; /** + * Authentication data to use. FIXME: init ! + */ +static struct TALER_BANK_AuthenticationData auth; + +static char *exchange_payto; +static struct TALER_WireTransferIdentifierRawP wtid; + +/** * Convenience macros to allocate all the currency-dependant * strings; note that the argument list of the macro is ignored. * It is kept as a way to make the macro more auto-descriptive @@ -336,9 +333,14 @@ run (void *cls, struct TALER_TESTING_Command ordinary_commands[] = { - CMD_TRANSFER_TO_EXCHANGE + TALER_TESTING_cmd_transfer ("create-reserve-1", - CURRENCY_10_02), + CURRENCY_10_02, + PAYER_URL, // bank base URL + path to the payer account. + &auth, + exchange_payto, + &wtid, + EXCHANGE_URL), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", @@ -425,9 +427,14 @@ run (void *cls, struct TALER_TESTING_Command corner_commands[] = { - CMD_TRANSFER_TO_EXCHANGE + TALER_TESTING_cmd_transfer ("create-reserve-1", - CURRENCY_5_01), + CURRENCY_5_01, + PAYER_URL, + &auth, + exchange_payto, + &wtid, + EXCHANGE_URL), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", @@ -460,9 +467,14 @@ run (void *cls, FIRST_INSTRUCTION, &unaggregated_number), - CMD_TRANSFER_TO_EXCHANGE + TALER_TESTING_cmd_transfer ("create-reserve-2", - CURRENCY_10_02), + CURRENCY_10_02, + PAYER_URL, + &auth, + exchange_payto, + &wtid, + EXCHANGE_URL), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-2", @@ -785,6 +797,12 @@ main (int argc, return FAILED_TO_LAUNCH_BANK; } + /** + * FIXME: Need to retrieve the bank base URL! + */ + exchange_payto = TALER_TESTING_make_xtalerbank_payto ("FIXME-BANK-HOSTNAME:PORT", + "/2"); + result = TALER_TESTING_setup_with_exchange (run, NULL, |