From 04f2e9a4d5b64000b5e29b4603c9bc57c732c4f7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 14 Dec 2020 17:12:25 +0100 Subject: (start to) remove logic no longer needed with new key management --- src/testing/Makefile.am | 2 +- src/testing/test_auditor_api.c | 3 +- src/testing/test_exchange_api.c | 7 +- .../test_exchange_api_overlapping_keys_bug.c | 5 +- src/testing/test_exchange_api_revocation.c | 3 +- src/testing/test_exchange_api_twisted.c | 6 +- src/testing/test_exchange_management_api.c | 3 +- src/testing/test_taler_exchange_wirewatch.c | 3 +- src/testing/testing_api_cmd_check_keys.c | 127 +------------- src/testing/testing_api_cmd_offline_sign_fees.c | 192 +++++++++++++++++++++ src/testing/testing_api_cmd_revoke.c | 2 - src/testing/testing_api_loop.c | 18 -- 12 files changed, 211 insertions(+), 160 deletions(-) create mode 100644 src/testing/testing_api_cmd_offline_sign_fees.c (limited to 'src/testing') diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index ceba62201..0e09b1462 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -56,10 +56,10 @@ libtalertesting_la_SOURCES = \ testing_api_cmd_exec_aggregator.c \ testing_api_cmd_exec_auditor-sign.c \ testing_api_cmd_exec_closer.c \ - testing_api_cmd_exec_keyup.c \ testing_api_cmd_exec_transfer.c \ testing_api_cmd_exec_wirewatch.c \ testing_api_cmd_insert_deposit.c \ + testing_api_cmd_offline_sign_fees.c \ testing_api_cmd_offline_sign_keys.c \ testing_api_cmd_set_wire_fee.c \ testing_api_cmd_recoup.c \ diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index 48f03119e..c4f890e62 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c @@ -630,8 +630,7 @@ 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", - 2, - 270 /* FIXME: wrong number... */), + 2), 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 f24a3ff73..18f7237b6 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -956,9 +956,12 @@ run (void *cls, false), TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", CONFIG_FILE), + TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", + CONFIG_FILE, + "EUR:0.01", + "EUR:0.01"), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 1, - 270 /* FIXME: wrong number... */), + 1), TALER_TESTING_cmd_batch ("wire", wire), TALER_TESTING_cmd_batch ("withdraw", diff --git a/src/testing/test_exchange_api_overlapping_keys_bug.c b/src/testing/test_exchange_api_overlapping_keys_bug.c index 19093243e..86f75f935 100644 --- a/src/testing/test_exchange_api_overlapping_keys_bug.c +++ b/src/testing/test_exchange_api_overlapping_keys_bug.c @@ -81,14 +81,11 @@ 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, - 1 /* FIXME: wrong number... */), + 1), TALER_TESTING_cmd_check_keys ("first-download", - 1, 1), /* Causes GET /keys?last_denom_issue=0 */ TALER_TESTING_cmd_check_keys_with_last_denom ("second-download", - 3, 1, GNUNET_TIME_UNIT_ZERO_ABS), TALER_TESTING_cmd_end () diff --git a/src/testing/test_exchange_api_revocation.c b/src/testing/test_exchange_api_revocation.c index 555891497..94e162b9a 100644 --- a/src/testing/test_exchange_api_revocation.c +++ b/src/testing/test_exchange_api_revocation.c @@ -72,8 +72,7 @@ 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, - 270 /* FIXME: wrong number... */), + 1), /** * 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 05867f89b..818b54deb 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -221,8 +221,7 @@ run (void *cls, "Wed, 19 Jan 586524 08:01:49 GMT"), TALER_TESTING_cmd_check_keys_pull_all_keys ( "check-keys-expiration-0", - 2, - 270), + 2), /** * Run some normal commands after this to make sure everything is fine. */ @@ -244,8 +243,7 @@ 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, - 270 /* FIXME: wrong number... */), + 1), 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 18f6dedf6..b53926fd2 100644 --- a/src/testing/test_exchange_management_api.c +++ b/src/testing/test_exchange_management_api.c @@ -143,8 +143,7 @@ run (void *cls, TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys", CONFIG_FILE), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 1, - 270 /* FIXME: wrong number... */), + 1), TALER_TESTING_cmd_end () }; diff --git a/src/testing/test_taler_exchange_wirewatch.c b/src/testing/test_taler_exchange_wirewatch.c index 169c959be..08c5936fd 100644 --- a/src/testing/test_taler_exchange_wirewatch.c +++ b/src/testing/test_taler_exchange_wirewatch.c @@ -92,8 +92,7 @@ run (void *cls, TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", config_filename), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 1, - 58 /* FIXME: wrong number... */), + 1), 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_check_keys.c b/src/testing/testing_api_cmd_check_keys.c index 20dbfb85b..bdf142ddc 100644 --- a/src/testing/testing_api_cmd_check_keys.c +++ b/src/testing/testing_api_cmd_check_keys.c @@ -46,12 +46,6 @@ struct CheckKeysState */ unsigned int generation; - /** - * How many denomination keys the exchange is - * supposed to have. - */ - unsigned int num_denom_keys; - /** * If this value is GNUNET_YES, then the "cherry * picking" facility is turned off; whole /keys is @@ -156,19 +150,6 @@ check_keys_run (void *cls, return; } #endif - /* "/keys" was updated, let's check they were OK! */ - if (cks->num_denom_keys != is->keys->num_denom_keys) - { - /* Did not get the expected number of denomination keys! */ - GNUNET_break (0); - TALER_LOG_ERROR ("Got %u keys in step %s, expected %u\n", - is->keys->num_denom_keys, - cmd->label, - cks->num_denom_keys); - TALER_TESTING_interpreter_fail (is); - return; - } - /* Let's unset the fake now before moving on. */ TALER_EXCHANGE_unset_now (is->exchange); TALER_TESTING_interpreter_next (is); @@ -192,36 +173,16 @@ check_keys_cleanup (void *cls, } -/** - * Make a "check keys" command. This type of command - * checks whether the number of denomination keys from - * @a exchange matches @a num_denom_keys. Additionally, - * it lets the user set a last denom issue date to be - * used in the request for /keys. - * - * @param label command label - * @param generation when this command is run, exactly @a - * generation /keys downloads took place. If the number - * of downloads is less than @a generation, the logic will - * first make sure that @a generation downloads are done, - * and _then_ execute the rest of the command. - * @param num_denom_keys expected number of denomination keys. - * @param last_denom_date date to be set in the "last_denom_issue" - * URL parameter of /keys. - * @return the command. - */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_last_denom (const char *label, - unsigned int generation, - unsigned int num_denom_keys, - struct GNUNET_TIME_Absolute - last_denom_date) +TALER_TESTING_cmd_check_keys_with_last_denom ( + const char *label, + unsigned int generation, + struct GNUNET_TIME_Absolute last_denom_date) { struct CheckKeysState *cks; cks = GNUNET_new (struct CheckKeysState); cks->generation = generation; - cks->num_denom_keys = num_denom_keys; cks->set_last_denom = GNUNET_YES; cks->last_denom_date = last_denom_date; { @@ -237,74 +198,14 @@ TALER_TESTING_cmd_check_keys_with_last_denom (const char *label, } -/** - * Make a "check keys" command. This type of command - * checks whether the number of denomination keys from - * @a exchange matches @a num_denom_keys. - * - * @param label command label - * @param generation when this command is run, exactly @a - * generation /keys downloads took place. If the number - * of downloads is less than @a generation, the logic will - * first make sure that @a generation downloads are done, - * and _then_ execute the rest of the command. - * @param num_denom_keys expected number of denomination keys. - * @return the command. - */ struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys (const char *label, - unsigned int generation, - unsigned int num_denom_keys) -{ - struct CheckKeysState *cks; - - cks = GNUNET_new (struct CheckKeysState); - cks->generation = generation; - cks->num_denom_keys = num_denom_keys; - { - struct TALER_TESTING_Command cmd = { - .cls = cks, - .label = label, - .run = &check_keys_run, - .cleanup = &check_keys_cleanup - }; - - return cmd; - } -} - - -/** - * Make a "check keys" command. This type of command - * checks whether the number of denomination keys from - * @a exchange matches @a num_denom_keys. - * - * @param label command label - * @param generation when this command is run, exactly @a - * generation /keys downloads took place. If the number - * of downloads is less than @a generation, the logic will - * first make sure that @a generation downloads are done, - * and _then_ execute the rest of the command. - * @param num_denom_keys expected number of denomination keys. - * @param now timestamp to use when fetching keys - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_now (const char *label, - unsigned int generation, - unsigned int num_denom_keys, - struct GNUNET_TIME_Absolute now) + unsigned int generation) { struct CheckKeysState *cks; cks = GNUNET_new (struct CheckKeysState); cks->generation = generation; - cks->num_denom_keys = num_denom_keys; - cks->now = now; - cks->with_now = GNUNET_YES; - - /* Force to NOT cherry pick, otherwise they conflict. */ - cks->pull_all_keys = GNUNET_YES; { struct TALER_TESTING_Command cmd = { .cls = cks, @@ -318,30 +219,14 @@ TALER_TESTING_cmd_check_keys_with_now (const char *label, } -/** - * Make a "check keys" command that forcedly does NOT cherry pick; - * just redownload the whole /keys. Then checks whether the number - * of denomination keys from @a exchange matches @a num_denom_keys. - * - * @param label command label - * @param generation when this command is run, exactly @a - * generation /keys downloads took place. If the number - * of downloads is less than @a generation, the logic will - * first make sure that @a generation downloads are done, - * and _then_ execute the rest of the command. - * @param num_denom_keys expected number of denomination keys. - * @return the command. - */ struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label, - unsigned int generation, - unsigned int num_denom_keys) + unsigned int generation) { struct CheckKeysState *cks; cks = GNUNET_new (struct CheckKeysState); cks->generation = generation; - cks->num_denom_keys = num_denom_keys; cks->pull_all_keys = GNUNET_YES; { struct TALER_TESTING_Command cmd = { diff --git a/src/testing/testing_api_cmd_offline_sign_fees.c b/src/testing/testing_api_cmd_offline_sign_fees.c new file mode 100644 index 000000000..500953202 --- /dev/null +++ b/src/testing/testing_api_cmd_offline_sign_fees.c @@ -0,0 +1,192 @@ +/* + This file is part of TALER + Copyright (C) 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 published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + TALER is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with TALER; see the file COPYING. If not, + see +*/ + +/** + * @file testing/testing_api_cmd_offline_sign_fees.c + * @brief run the taler-exchange-offline command to download, sign and upload wire fees + * @author Marcello Stanisci + * @author Christian Grothoff + */ +#include "platform.h" +#include "taler_json_lib.h" +#include +#include "taler_signatures.h" +#include "taler_testing_lib.h" + + +/** + * State for a "offlinesign" CMD. + */ +struct OfflineSignState +{ + + /** + * Process for the "offlinesign" command. + */ + struct GNUNET_OS_Process *offlinesign_proc; + + /** + * Configuration file used by the command. + */ + const char *config_filename; + + /** + * The wire fee to sign. + */ + const char *wire_fee_s; + + /** + * The closing fee to sign. + */ + const char *closing_fee_s; + +}; + + +/** + * Run the command; calls the `taler-exchange-offline' program. + * + * @param cls closure. + * @param cmd the commaind being run. + * @param is interpreter state. + */ +static void +offlinesign_run (void *cls, + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) +{ + struct OfflineSignState *ks = cls; + + ks->offlinesign_proc + = GNUNET_OS_start_process ( + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-offline", + "taler-exchange-offline", + "-c", ks->config_filename, + "-L", "INFO", + "wire-fee", + "now", + "x-taler-bank", + ks->wire_fee_s, + ks->closing_fee_s, + "upload", + NULL); + if (NULL == ks->offlinesign_proc) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + TALER_TESTING_wait_for_sigchld (is); +} + + +/** + * Free the state of a "offlinesign" CMD, and possibly kills its + * process if it did not terminate correctly. + * + * @param cls closure. + * @param cmd the command being freed. + */ +static void +offlinesign_cleanup (void *cls, + const struct TALER_TESTING_Command *cmd) +{ + struct OfflineSignState *ks = cls; + + (void) cmd; + if (NULL != ks->offlinesign_proc) + { + GNUNET_break (0 == + GNUNET_OS_process_kill (ks->offlinesign_proc, + SIGKILL)); + GNUNET_OS_process_wait (ks->offlinesign_proc); + GNUNET_OS_process_destroy (ks->offlinesign_proc); + ks->offlinesign_proc = NULL; + } + GNUNET_free (ks); +} + + +/** + * Offer "offlinesign" CMD internal data to other commands. + * + * @param cls closure. + * @param[out] ret result + * @param trait name of the trait. + * @param index index number of the object to offer. + * @return #GNUNET_OK on success. + */ +static int +offlinesign_traits (void *cls, + const void **ret, + const char *trait, + unsigned int index) +{ + struct OfflineSignState *ks = cls; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_process (0, + &ks->offlinesign_proc), + TALER_TESTING_trait_end () + }; + + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); +} + + +/** + * Sign a wire fee. + * + * @param label command label. + * @param config_filename configuration filename. + * @param wire_fee the wire fee to affirm (for the current year) + * @param closing_fee the closing fee to affirm (for the current year) + * @return the command + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_offline_sign_fees (const char *label, + const char *config_filename, + const char *wire_fee, + const char *closing_fee) +{ + struct OfflineSignState *ks; + + ks = GNUNET_new (struct OfflineSignState); + ks->config_filename = config_filename; + ks->wire_fee_s = wire_fee; + ks->closing_fee_s = closing_fee; + { + struct TALER_TESTING_Command cmd = { + .cls = ks, + .label = label, + .run = &offlinesign_run, + .cleanup = &offlinesign_cleanup, + .traits = &offlinesign_traits + }; + + return cmd; + } +} + + +/* end of testing_api_cmd_exec_offline_sign_fees.c */ diff --git a/src/testing/testing_api_cmd_revoke.c b/src/testing/testing_api_cmd_revoke.c index 8863110bd..f17f351ec 100644 --- a/src/testing/testing_api_cmd_revoke.c +++ b/src/testing/testing_api_cmd_revoke.c @@ -181,8 +181,6 @@ revoke_run (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Revoke is ongoing..\n"); - - is->reload_keys = GNUNET_OK; TALER_TESTING_wait_for_sigchld (is); } diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index f269274ec..c89073a18 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -463,24 +463,6 @@ maint_child_death (void *cls) return; } - // FIXME: remove reload_keys, obsolete! - if (GNUNET_OK == is->reload_keys) - { - if (NULL == is->exchanged) - { - GNUNET_break (0); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Triggering key state reload at exchange\n"); - GNUNET_break (0 == - GNUNET_OS_process_kill (is->exchanged, - SIGUSR1)); - sleep (5); /* make sure signal was received and processed */ - } - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dead child, go on with next command.\n"); TALER_TESTING_interpreter_next (is); -- cgit v1.2.3