From 35c064b93739795832598893b1885ff7cfd9faf8 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Wed, 3 Apr 2019 16:07:04 +0200 Subject: Faking the time. Cherry-pick tests now uses the now-faked version of taler-exchange-keyup. Fails. --- src/lib/testing_api_cmd_exec_keyup.c | 78 +++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 9 deletions(-) (limited to 'src/lib/testing_api_cmd_exec_keyup.c') diff --git a/src/lib/testing_api_cmd_exec_keyup.c b/src/lib/testing_api_cmd_exec_keyup.c index 576aab3c7..d534db06e 100644 --- a/src/lib/testing_api_cmd_exec_keyup.c +++ b/src/lib/testing_api_cmd_exec_keyup.c @@ -46,6 +46,18 @@ struct KeyupState * Configuration file used by the command. */ const char *config_filename; + + /** + * If GNUNET_YES, then the fake @e now value will be + * passed to taler-exchange-keyup via the --timestamp + * option. + */ + unsigned int with_now; + + /** + * User-provided fake now. + */ + struct GNUNET_TIME_Absolute now; }; @@ -63,15 +75,30 @@ keyup_run (void *cls, { struct KeyupState *ks = cls; - ks->keyup_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", ks->config_filename, - "-o", "auditor.in", - NULL); + if (GNUNET_YES == ks->with_now) + { + ks->keyup_proc = GNUNET_OS_start_process + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-keyup", + "taler-exchange-keyup", + "-c", ks->config_filename, + "-o", "auditor.in", + "--timestamp", + GNUNET_STRINGS_absolute_time_to_string (ks->now), + NULL); + } + else + ks->keyup_proc = GNUNET_OS_start_process + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-keyup", + "taler-exchange-keyup", + "-c", ks->config_filename, + "-o", "auditor.in", + NULL); if (NULL == ks->keyup_proc) { @@ -138,6 +165,39 @@ keyup_traits (void *cls, } +/** + * Make the "keyup" CMD, with "--timestamp" option. + * + * @param label command label. + * @param config_filename configuration filename. + * @param now Unix timestamp representing the fake "now". + * + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_keyup_with_now + (const char *label, + const char *config_filename, + struct GNUNET_TIME_Absolute now) +{ + struct KeyupState *ks; + + ks = GNUNET_new (struct KeyupState); + ks->config_filename = config_filename; + ks->now = now; + ks->with_now = GNUNET_YES; + + struct TALER_TESTING_Command cmd = { + .cls = ks, + .label = label, + .run = &keyup_run, + .cleanup = &keyup_cleanup, + .traits = &keyup_traits + }; + + return cmd; +} + /** * Make the "keyup" CMD. * -- cgit v1.2.3