diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-04-03 16:07:04 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-04-03 16:07:04 +0200 |
commit | 35c064b93739795832598893b1885ff7cfd9faf8 (patch) | |
tree | 36dc79df5790f97ec56604f395e01e8ea5c73311 /src/lib/testing_api_cmd_exec_keyup.c | |
parent | 219f702926c61adedea9458e07a6936e76cfe13e (diff) | |
download | exchange-35c064b93739795832598893b1885ff7cfd9faf8.tar.gz exchange-35c064b93739795832598893b1885ff7cfd9faf8.tar.bz2 exchange-35c064b93739795832598893b1885ff7cfd9faf8.zip |
Faking the time.
Cherry-pick tests now uses the now-faked version
of taler-exchange-keyup. Fails.
Diffstat (limited to 'src/lib/testing_api_cmd_exec_keyup.c')
-rw-r--r-- | src/lib/testing_api_cmd_exec_keyup.c | 78 |
1 files changed, 69 insertions, 9 deletions
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) { @@ -139,6 +166,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. * * @param label command label. |