From b5d88fc2d1832fd27bdd7df0860c07ae3c61312c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 14 Dec 2020 15:42:32 +0100 Subject: activating implementation of #6175 --- src/testing/Makefile.am | 5 +- src/testing/test_auditor_api.c | 6 +- src/testing/test_exchange_api.c | 10 +-- .../test_exchange_api_keys_cherry_picking.c | 8 +-- src/testing/test_exchange_api_revocation.c | 2 +- src/testing/test_exchange_api_twisted.c | 11 ++- src/testing/test_exchange_management_api.c | 2 +- src/testing/test_taler_exchange_wirewatch.c | 2 +- src/testing/testing_api_cmd_offline_sign_keys.c | 3 +- src/testing/testing_api_cmd_revoke.c | 13 ++-- src/testing/testing_api_helpers_exchange.c | 2 +- src/testing/testing_api_loop.c | 81 ++++++++++++++-------- 12 files changed, 91 insertions(+), 54 deletions(-) (limited to 'src/testing') diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 0d50d95c6..ceba62201 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -131,7 +131,6 @@ check_PROGRAMS = \ test_bank_api_with_pybank \ test_bank_api_with_nexus \ test_exchange_api \ - test_exchange_api_keys_cherry_picking \ test_exchange_api_revocation \ test_exchange_api_overlapping_keys_bug \ test_exchange_management_api \ @@ -144,6 +143,10 @@ if HAVE_TWISTER test_bank_api_with_pybank_twisted endif +# test_exchange_api_keys_cherry_picking disabled for now: +# needs to be rewritten as we no longer support /keys timetravel! + + TESTS = \ $(check_PROGRAMS) diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index f0184143a..48f03119e 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018 Taler Systems SA + Copyright (C) 2014-2020 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 @@ -630,8 +630,8 @@ run (void *cls, TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", CONFIG_FILE), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 1, - 5 /* FIXME: wrong number... */), + 2, + 270 /* FIXME: wrong number... */), CMD_RUN_AUDITOR ("virgin-auditor"), TALER_TESTING_cmd_exchanges_with_url ("check-exchange", MHD_HTTP_OK, diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index d2e18c41b..f24a3ff73 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -880,11 +880,11 @@ run (void *cls, "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", - MHD_HTTP_NOT_FOUND), + MHD_HTTP_GONE), /* Test deposit fails after recoup, with proof in recoup */ /* Note that, the exchange will never return the coin's transaction - * history with recoup data, as we get a 404 on the DK! */ + * history with recoup data, as we get a 410 on the DK! */ TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup", "recoup-withdraw-coin-2a", 0, @@ -892,7 +892,7 @@ run (void *cls, "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", GNUNET_TIME_UNIT_ZERO, "EUR:0.5", - MHD_HTTP_NOT_FOUND), + MHD_HTTP_GONE), /* Test that revoked coins cannot be withdrawn */ CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-3", "EUR:1.01"), @@ -906,7 +906,7 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked", "recoup-create-reserve-3", "EUR:1", - MHD_HTTP_NOT_FOUND), + MHD_HTTP_GONE), /* check that we are empty before the rejection test */ TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), @@ -958,7 +958,7 @@ run (void *cls, CONFIG_FILE), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", 1, - 5 /* FIXME: wrong number... */), + 270 /* FIXME: wrong number... */), TALER_TESTING_cmd_batch ("wire", wire), TALER_TESTING_cmd_batch ("withdraw", diff --git a/src/testing/test_exchange_api_keys_cherry_picking.c b/src/testing/test_exchange_api_keys_cherry_picking.c index aab94d68a..588ef7520 100644 --- a/src/testing/test_exchange_api_keys_cherry_picking.c +++ b/src/testing/test_exchange_api_keys_cherry_picking.c @@ -129,8 +129,8 @@ run (void *cls, * Make sure we have the same keys situation as * it was before the serialization. */ - TALER_TESTING_cmd_check_keys_with_now - ("check-keys-after-deserialization", + TALER_TESTING_cmd_check_keys_with_now ( + "check-keys-after-deserialization", 4, NDKS_RIGHT_BEFORE_SERIALIZATION, /** @@ -198,8 +198,8 @@ run (void *cls, * ---- * 40 */// - TALER_TESTING_cmd_check_keys_with_now - ("check-keys-3", + TALER_TESTING_cmd_check_keys_with_now ( + "check-keys-3", 3 /* generation */, NDKS_RIGHT_BEFORE_SERIALIZATION, TTH_parse_time (JAN2030)), diff --git a/src/testing/test_exchange_api_revocation.c b/src/testing/test_exchange_api_revocation.c index a952d360c..555891497 100644 --- a/src/testing/test_exchange_api_revocation.c +++ b/src/testing/test_exchange_api_revocation.c @@ -73,7 +73,7 @@ run (void *cls, CONFIG_FILE), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", 1, - 5 /* FIXME: wrong number... */), + 270 /* FIXME: wrong number... */), /** * Fill reserve with EUR:10.02, as withdraw fee is 1 ct per * config. diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 446bdccc4..05867f89b 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -222,7 +222,7 @@ run (void *cls, TALER_TESTING_cmd_check_keys_pull_all_keys ( "check-keys-expiration-0", 2, - 5), + 270), /** * Run some normal commands after this to make sure everything is fine. */ @@ -237,6 +237,15 @@ run (void *cls, }; struct TALER_TESTING_Command commands[] = { + 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", + 1, + 270 /* FIXME: wrong number... */), TALER_TESTING_cmd_batch ("refresh-reveal-409-conflict", refresh_409_conflict), TALER_TESTING_cmd_batch ("refund", diff --git a/src/testing/test_exchange_management_api.c b/src/testing/test_exchange_management_api.c index 26c6cae8a..18f6dedf6 100644 --- a/src/testing/test_exchange_management_api.c +++ b/src/testing/test_exchange_management_api.c @@ -144,7 +144,7 @@ run (void *cls, CONFIG_FILE), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", 1, - 5 /* FIXME: wrong number... */), + 270 /* FIXME: wrong number... */), TALER_TESTING_cmd_end () }; diff --git a/src/testing/test_taler_exchange_wirewatch.c b/src/testing/test_taler_exchange_wirewatch.c index b16a9e769..169c959be 100644 --- a/src/testing/test_taler_exchange_wirewatch.c +++ b/src/testing/test_taler_exchange_wirewatch.c @@ -93,7 +93,7 @@ run (void *cls, config_filename), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", 1, - 5 /* FIXME: wrong number... */), + 58 /* FIXME: wrong number... */), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"), CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty"), TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-on-empty", diff --git a/src/testing/testing_api_cmd_offline_sign_keys.c b/src/testing/testing_api_cmd_offline_sign_keys.c index 70654ea10..dd6170d90 100644 --- a/src/testing/testing_api_cmd_offline_sign_keys.c +++ b/src/testing/testing_api_cmd_offline_sign_keys.c @@ -70,6 +70,7 @@ offlinesign_run (void *cls, "taler-exchange-offline", "taler-exchange-offline", "-c", ks->config_filename, + "-L", "INFO", "download", "sign", "upload", @@ -80,8 +81,6 @@ offlinesign_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - /* This function does not tell whether the command - * succeeded or not! */ TALER_TESTING_wait_for_sigchld (is); } diff --git a/src/testing/testing_api_cmd_revoke.c b/src/testing/testing_api_cmd_revoke.c index c43f53727..8863110bd 100644 --- a/src/testing/testing_api_cmd_revoke.c +++ b/src/testing/testing_api_cmd_revoke.c @@ -79,8 +79,9 @@ revoke_cleanup (void *cls, if (NULL != rs->revoke_proc) { - GNUNET_break (0 == GNUNET_OS_process_kill - (rs->revoke_proc, SIGKILL)); + GNUNET_break (0 == + GNUNET_OS_process_kill (rs->revoke_proc, + SIGKILL)); GNUNET_OS_process_wait (rs->revoke_proc); GNUNET_OS_process_destroy (rs->revoke_proc); rs->revoke_proc = NULL; @@ -163,13 +164,13 @@ revoke_run (void *cls, rs->dhks = GNUNET_STRINGS_data_to_string_alloc ( &denom_pub->h_key, sizeof (struct GNUNET_HashCode)); - rs->revoke_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", + "taler-exchange-offline", + "taler-exchange-offline", "-c", rs->config_filename, - "-r", rs->dhks, + "revoke-denomination", rs->dhks, + "upload", NULL); if (NULL == rs->revoke_proc) diff --git a/src/testing/testing_api_helpers_exchange.c b/src/testing/testing_api_helpers_exchange.c index 95ba71b7d..a12998e29 100644 --- a/src/testing/testing_api_helpers_exchange.c +++ b/src/testing/testing_api_helpers_exchange.c @@ -617,7 +617,7 @@ TALER_TESTING_wait_exchange_ready (const char *base_url) unsigned int iter; GNUNET_asprintf (&wget_cmd, - "wget -q -t 1 -T 1 %skeys -o /dev/null -O /dev/null", + "wget -q -t 1 -T 1 %sseed -o /dev/null -O /dev/null", base_url); // make sure ends with '/' /* give child time to start and bind against the socket */ fprintf (stderr, diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 88af481ea..f269274ec 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -388,24 +388,25 @@ maint_child_death (void *cls) struct TALER_TESTING_Interpreter *is = cls; struct TALER_TESTING_Command *cmd = &is->commands[is->ip]; const struct GNUNET_DISK_FileHandle *pr; - struct GNUNET_OS_Process **processp; char c[16]; + enum GNUNET_OS_ProcessStatusType type; + unsigned long code; if (TALER_TESTING_cmd_is_batch (cmd)) { struct TALER_TESTING_Command *batch_cmd; - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_cmd - (cmd, 0, &batch_cmd)); /* bad? */ + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_cmd (cmd, + 0, + &batch_cmd)); cmd = batch_cmd; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got SIGCHLD for `%s'.\n", cmd->label); - is->child_death_task = NULL; pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); @@ -424,16 +425,45 @@ maint_child_death (void *cls) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got the dead child process handle" - ", waiting for termination ...\n"); - - GNUNET_OS_process_wait (*processp); + "Got the dead child process handle, waiting for termination ...\n"); + GNUNET_OS_process_wait_status (*processp, + &type, + &code); GNUNET_OS_process_destroy (*processp); *processp = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "... definitively terminated\n"); + switch (type) + { + case GNUNET_OS_PROCESS_UNKNOWN: + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + case GNUNET_OS_PROCESS_RUNNING: + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + case GNUNET_OS_PROCESS_STOPPED: + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + case GNUNET_OS_PROCESS_EXITED: + if (0 != code) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Process exited with unexpected status %u\n", + (unsigned int) code); + TALER_TESTING_interpreter_fail (is); + return; + } + break; + case GNUNET_OS_PROCESS_SIGNALED: + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + // FIXME: remove reload_keys, obsolete! if (GNUNET_OK == is->reload_keys) { if (NULL == is->exchanged) @@ -444,8 +474,9 @@ maint_child_death (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Triggering key state reload at exchange\n"); - GNUNET_break (0 == GNUNET_OS_process_kill - (is->exchanged, SIGUSR1)); + GNUNET_break (0 == + GNUNET_OS_process_kill (is->exchanged, + SIGUSR1)); sleep (5); /* make sure signal was received and processed */ } } @@ -643,19 +674,8 @@ TALER_TESTING_cert_cb (void *cls, * the interpreter is already running. */ if (GNUNET_YES == is->working) return; - is->working = GNUNET_YES; - - /* Very first start of tests, call "run()" */ - if (1 == is->key_generation) - { - main_ctx->main_cb (main_ctx->main_cb_cls, - is); - return; - } - - /* Tests already started, just trigger the - * next command. */ + /* Trigger the next command. */ TALER_LOG_DEBUG ("Cert_cb, scheduling CMD (ip: %d)\n", is->ip); GNUNET_SCHEDULER_add_now (&interpreter_run, @@ -740,6 +760,7 @@ main_wrapper_exchange_connect (void *cls) main_ctx->exchange_url = exchange_url; is->timeout_task = GNUNET_SCHEDULER_add_shutdown (&do_abort, main_ctx); + is->working = GNUNET_YES; GNUNET_break (NULL != (is->exchange = TALER_EXCHANGE_connect (is->ctx, @@ -747,6 +768,10 @@ main_wrapper_exchange_connect (void *cls) &TALER_TESTING_cert_cb, main_ctx, TALER_EXCHANGE_OPTION_END))); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Starting main test loop\n"); + main_ctx->main_cb (main_ctx->main_cb_cls, + is); } @@ -842,10 +867,10 @@ static int load_urls (struct TALER_TESTING_Interpreter *is) { if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (is->cfg, - "auditor", - "BASE_URL", - &is->auditor_url)) + GNUNET_CONFIGURATION_get_value_string (is->cfg, + "auditor", + "BASE_URL", + &is->auditor_url)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "auditor", -- cgit v1.2.3