diff options
Diffstat (limited to 'src/testing/test_auditor_api.c')
-rw-r--r-- | src/testing/test_auditor_api.c | 299 |
1 files changed, 152 insertions, 147 deletions
diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index 2ea173569..3810c601e 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c @@ -29,6 +29,7 @@ #include "taler_auditor_service.h" #include "taler_json_lib.h" #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_testing_lib.h> #include <microhttpd.h> #include "taler_bank_service.h" #include "taler_fakebank_lib.h" @@ -39,20 +40,14 @@ * Configuration file we use. One (big) configuration is used * for the various components for this test. */ -#define CONFIG_FILE "test_auditor_api.conf" +static char *config_file; -#define CONFIG_FILE_EXPIRE_RESERVE_NOW \ - "test_auditor_api_expire_reserve_now.conf" +static char *config_file_expire_reserve_now; /** - * Exchange configuration data. + * Our credentials. */ -static struct TALER_TESTING_ExchangeConfiguration ec; - -/** - * Bank configuration data. - */ -static struct TALER_TESTING_BankConfiguration bc; +static struct TALER_TESTING_Credentials cred; /** * Execute the taler-exchange-wirewatch command with @@ -61,7 +56,7 @@ static struct TALER_TESTING_BankConfiguration bc; * @param label label to use for the command. */ #define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_wirewatch2 (label, config_file, "exchange-account-2") /** * Execute the taler-exchange-aggregator, closer and transfer commands with @@ -70,8 +65,9 @@ static struct TALER_TESTING_BankConfiguration bc; * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE), \ - TALER_TESTING_cmd_exec_transfer (label, CONFIG_FILE) + TALER_TESTING_cmd_sleep (label "-sleep", 1), \ + TALER_TESTING_cmd_exec_aggregator (label, config_file), \ + TALER_TESTING_cmd_exec_transfer (label, config_file) /** * Run wire transfer of funds from some user's account to the @@ -82,8 +78,8 @@ static struct TALER_TESTING_BankConfiguration bc; */ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ TALER_TESTING_cmd_admin_add_incoming (label, amount, \ - &bc.exchange_auth, \ - bc.user42_payto) + &cred.ba, \ + cred.user42_payto) /** * Run the taler-auditor. @@ -91,7 +87,7 @@ static struct TALER_TESTING_BankConfiguration bc; * @param label label to use for the command. */ #define CMD_RUN_AUDITOR(label) \ - TALER_TESTING_cmd_exec_auditor (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_auditor (label, config_file) /** @@ -115,7 +111,7 @@ run (void *cls, "EUR:5.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", - "EUR:5.01", bc.user42_payto, bc.exchange_payto, + "EUR:5.01", cred.user42_payto, cred.exchange_payto, "create-reserve-1"), /** * Make a reserve exist, according to the previous transfer. @@ -127,6 +123,7 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", "create-reserve-1", "EUR:5", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_end () }; @@ -138,7 +135,7 @@ run (void *cls, TALER_TESTING_cmd_deposit ("deposit-simple", "withdraw-coin-1", 0, - bc.user42_payto, + cred.user42_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:5", @@ -155,7 +152,7 @@ run (void *cls, "EUR:5.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-refresh-create-reserve-1", - "EUR:5.01", bc.user42_payto, bc.exchange_payto, + "EUR:5.01", cred.user42_payto, cred.exchange_payto, "refresh-create-reserve-1"), /** * Make previous command effective. @@ -167,6 +164,7 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-1", "refresh-create-reserve-1", "EUR:5", + 0, /* age restriction off */ MHD_HTTP_OK), /** * Try to partially spend (deposit) 1 EUR of the 5 EUR coin (in @@ -175,14 +173,15 @@ run (void *cls, TALER_TESTING_cmd_deposit ("refresh-deposit-partial", "refresh-withdraw-coin-1", 0, - bc.user42_payto, + cred.user42_payto, "{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), /** * Melt the rest of the coin's value (EUR:4.00 = 3x EUR:1.03 + 7x - * EUR:0.13) */ + * EUR:0.13) + */ TALER_TESTING_cmd_melt_double ("refresh-melt-1", "refresh-withdraw-coin-1", MHD_HTTP_OK, @@ -199,7 +198,7 @@ run (void *cls, TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", "refresh-reveal-1", 3, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", GNUNET_TIME_UNIT_ZERO, "EUR:0.1", @@ -213,74 +212,83 @@ run (void *cls, * happen here, as each deposit operation is run with a * fresh merchant public key! NOTE: this comment comes * "verbatim" from the old test-suite, and IMO does not explain - * a lot!*/// + * a lot! */ CMD_EXEC_AGGREGATOR ("run-aggregator"), /** * Check all the transfers took place. */ - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-499c", ec.exchange_url, - "EUR:4.98", bc.exchange_payto, bc.user42_payto), - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-99c1", ec.exchange_url, - "EUR:0.98", bc.exchange_payto, bc.user42_payto), - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-99c", ec.exchange_url, - "EUR:0.08", bc.exchange_payto, bc.user43_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-499c", + cred.exchange_url, + "EUR:4.98", + cred.exchange_payto, + cred.user42_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-99c1", + cred.exchange_url, + "EUR:0.98", + cred.exchange_payto, + cred.user42_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-99c", + cred.exchange_url, + "EUR:0.08", + cred.exchange_payto, + cred.user43_payto), /* The following transactions got originated within * the "massive deposit confirms" batch. */ - TALER_TESTING_cmd_check_bank_transfer - ("check-massive-transfer-1", - ec.exchange_url, + TALER_TESTING_cmd_check_bank_transfer ( + "check-massive-transfer-1", + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-2", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-3", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-4", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-5", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-6", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-7", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-8", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-9", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-10", - ec.exchange_url, + cred.exchange_url, "EUR:0.98", - bc.exchange_payto, bc.user43_payto), + cred.exchange_payto, cred.user43_payto), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_end () }; @@ -298,17 +306,18 @@ run (void *cls, TALER_TESTING_cmd_check_bank_admin_transfer ( "check_bank_transfer-unaggregated", "EUR:5.01", - bc.user42_payto, - bc.exchange_payto, + cred.user42_payto, + cred.exchange_payto, "create-reserve-unaggregated"), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", "create-reserve-unaggregated", "EUR:5", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("deposit-unaggregated", "withdraw-coin-unaggregated", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, @@ -336,6 +345,7 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1", "create-reserve-r1", "EUR:5", + 0, /* age restriction off */ MHD_HTTP_OK), /** * Spend 5 EUR of the 5 EUR coin (in full). Merchant would @@ -344,7 +354,7 @@ run (void *cls, TALER_TESTING_cmd_deposit ("deposit-refund-1", "withdraw-coin-r1", 0, - bc.user42_payto, + cred.user42_payto, "{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}", GNUNET_TIME_UNIT_MINUTES, "EUR:5", @@ -361,7 +371,7 @@ run (void *cls, TALER_TESTING_cmd_deposit ("deposit-refund-2", "withdraw-coin-r1", 0, - bc.user42_payto, + cred.user42_payto, "{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}", GNUNET_TIME_UNIT_ZERO, "EUR:4.99", @@ -391,15 +401,15 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1", "recoup-create-reserve-1", "EUR:5", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_revoke ("revoke-1", MHD_HTTP_OK, "recoup-withdraw-coin-1", - CONFIG_FILE), + config_file), TALER_TESTING_cmd_recoup ("recoup-1", MHD_HTTP_OK, "recoup-withdraw-coin-1", - NULL, "EUR:5"), /** * Re-withdraw from this reserve @@ -407,17 +417,20 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2", "recoup-create-reserve-1", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), /** * These commands should close the reserve because the aggregator * is given a config file that overrides the reserve expiration * time (making it now-ish) - */CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", + */ + CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", "EUR:5.01"), - TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation", - CONFIG_FILE_EXPIRE_RESERVE_NOW), + TALER_TESTING_cmd_exec_wirewatch2 ("short-lived-aggregation", + config_file_expire_reserve_now, + "exchange-account-2"), TALER_TESTING_cmd_exec_aggregator ("close-reserves", - CONFIG_FILE_EXPIRE_RESERVE_NOW), + config_file_expire_reserve_now), /** * Fill reserve with EUR:2.02, as withdraw fee is 1 ct per * config, then withdraw two coin, partially spend one, and @@ -436,6 +449,7 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2a", "recoup-create-reserve-2", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), /** * Withdraw a 1 EUR coin, at fee of 1 ct @@ -443,11 +457,12 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2b", "recoup-create-reserve-2", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("recoup-deposit-partial", "recoup-withdraw-coin-2a", 0, - bc.user42_payto, + cred.user42_payto, "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:0.5", @@ -455,11 +470,10 @@ run (void *cls, TALER_TESTING_cmd_revoke ("revoke-2", MHD_HTTP_OK, "recoup-withdraw-coin-2a", - CONFIG_FILE), + config_file), TALER_TESTING_cmd_recoup ("recoup-2", MHD_HTTP_OK, "recoup-withdraw-coin-2a", - NULL, "EUR:0.5"), TALER_TESTING_cmd_end () }; @@ -472,57 +486,68 @@ run (void *cls, */ CMD_TRANSFER_TO_EXCHANGE ("massive-reserve", "EUR:10.10"), - TALER_TESTING_cmd_check_bank_admin_transfer - ("check-massive-transfer", + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-massive-transfer", "EUR:10.10", - bc.user42_payto, bc.exchange_payto, + cred.user42_payto, + cred.exchange_payto, "massive-reserve"), CMD_EXEC_WIREWATCH ("massive-wirewatch"), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-2", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-3", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-4", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-5", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-6", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-7", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-8", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-9", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-10", "massive-reserve", "EUR:1", + 0, /* age restriction off */ MHD_HTTP_OK), - TALER_TESTING_cmd_deposit - ("massive-deposit-1", + TALER_TESTING_cmd_deposit ( + "massive-deposit-1", "massive-withdraw-1", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -531,7 +556,7 @@ run (void *cls, ("massive-deposit-2", "massive-withdraw-2", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -540,7 +565,7 @@ run (void *cls, ("massive-deposit-3", "massive-withdraw-3", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -549,7 +574,7 @@ run (void *cls, ("massive-deposit-4", "massive-withdraw-4", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -558,7 +583,7 @@ run (void *cls, ("massive-deposit-5", "massive-withdraw-5", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -567,7 +592,7 @@ run (void *cls, ("massive-deposit-6", "massive-withdraw-6", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -576,7 +601,7 @@ run (void *cls, ("massive-deposit-7", "massive-withdraw-7", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -585,7 +610,7 @@ run (void *cls, ("massive-deposit-8", "massive-withdraw-8", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -594,24 +619,23 @@ run (void *cls, ("massive-deposit-9", "massive-withdraw-9", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), - TALER_TESTING_cmd_deposit - ("massive-deposit-10", + TALER_TESTING_cmd_deposit ( + "massive-deposit-10", "massive-withdraw-10", 0, - bc.user43_payto, + cred.user43_payto, "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation", - is->auditor, "massive-deposit-10", - 0, + 1, "EUR:0.99", MHD_HTTP_OK), CMD_RUN_AUDITOR ("massive-auditor"), @@ -620,25 +644,25 @@ run (void *cls, }; struct TALER_TESTING_Command commands[] = { - TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", - CONFIG_FILE, - "EUR:0.01", - "EUR:0.01"), - TALER_TESTING_cmd_auditor_add ("add-auditor-OK", - MHD_HTTP_NO_CONTENT, - false), - TALER_TESTING_cmd_wire_add ("add-wire-account", - "payto://x-taler-bank/localhost/2", - MHD_HTTP_NO_CONTENT, - false), - TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", - CONFIG_FILE), - TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 2), + TALER_TESTING_cmd_run_fakebank ("run-fakebank", + cred.cfg, + "exchange-account-2"), + TALER_TESTING_cmd_system_start ("start-taler", + config_file, + "-u", "exchange-account-2", + "-ae", + NULL), + TALER_TESTING_cmd_get_exchange ("get-exchange", + cred.cfg, + NULL, + true, + true), + TALER_TESTING_cmd_get_auditor ("get-auditor", + cred.cfg, + true), + TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline", + config_file), CMD_RUN_AUDITOR ("virgin-auditor"), - TALER_TESTING_cmd_exchanges_with_url ("check-exchange", - MHD_HTTP_OK, - "http://localhost:8081/"), TALER_TESTING_cmd_batch ("massive-deposit-confirms", massive_deposit_confirms), TALER_TESTING_cmd_batch ("withdraw", @@ -659,9 +683,9 @@ run (void *cls, TALER_TESTING_cmd_end () }; - TALER_TESTING_run_with_fakebank (is, - commands, - bc.exchange_auth.wire_gateway_url); + (void) cls; + TALER_TESTING_run (is, + commands); } @@ -669,47 +693,28 @@ int main (int argc, char *const *argv) { - /* These environment variables get in the way... */ - unsetenv ("XDG_DATA_HOME"); - unsetenv ("XDG_CONFIG_HOME"); - GNUNET_log_setup ("test-auditor-api", - "INFO", - NULL); - /* Check fakebank port is available and get configuration data. */ - if (GNUNET_OK != - TALER_TESTING_prepare_fakebank (CONFIG_FILE, - "exchange-account-2", - &bc)) - return 77; - TALER_TESTING_cleanup_files (CONFIG_FILE); - /* @helpers. Run keyup, create tables, ... Note: it - * fetches the port number from config in order to see - * if it's available. */ - switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, - GNUNET_YES, - &ec)) + (void) argc; { - case GNUNET_SYSERR: - GNUNET_break (0); - return 1; - case GNUNET_NO: - return 77; - case GNUNET_OK: - if (GNUNET_OK != - /* Set up event loop and reschedule context, plus - * start/stop the exchange. It calls TALER_TESTING_setup - * which creates the 'is' object. - */ - TALER_TESTING_auditor_setup (&run, - NULL, - CONFIG_FILE)) - return 1; - break; - default: - GNUNET_break (0); - return 1; + char *cipher; + + cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); + GNUNET_assert (NULL != cipher); + GNUNET_asprintf (&config_file, + "test_auditor_api-%s.conf", + cipher); + GNUNET_asprintf (&config_file_expire_reserve_now, + "test_auditor_api_expire_reserve_now-%s.conf", + cipher); + GNUNET_free (cipher); } - return 0; + return TALER_TESTING_main (argv, + "INFO", + config_file, + "exchange-account-2", + TALER_TESTING_BS_FAKEBANK, + &cred, + &run, + NULL); } |