Inserting "now" argument into "/keys".

Also using this new logic from the cherry-pick test case.
This commit is contained in:
Marcello Stanisci 2019-04-04 12:14:25 +02:00
parent ce71d83ad6
commit 3e757cdeda
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
4 changed files with 62 additions and 32 deletions

View File

@ -935,6 +935,30 @@ TALER_TESTING_cmd_exec_keyup_with_now
struct GNUNET_TIME_Absolute now);
/**
* 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 exchange connection handle to the exchange to test.
*
* @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);
/**
* Make a "auditor sign" CMD.
*

View File

@ -218,7 +218,7 @@ struct TALER_EXCHANGE_Handle
* If GNUNET_YES, use fake now given by the user, in
* request of "/keys".
*/
unsigned int with_now;
int with_now;
/**
* Fake now given by the user.
@ -1824,30 +1824,36 @@ request_keys (void *cls)
struct TALER_EXCHANGE_Handle *exchange = cls;
struct KeysRequest *kr;
CURL *eh;
char url[200] = "/keys?";
exchange->retry_task = NULL;
GNUNET_assert (NULL == exchange->kr);
kr = GNUNET_new (struct KeysRequest);
kr->exchange = exchange;
if (GNUNET_YES ==
TEAH_handle_is_ready (exchange))
{
char *arg;
if (GNUNET_YES == TEAH_handle_is_ready (exchange))
{
TALER_LOG_DEBUG ("Last DK issue date (before GETting /keys): %s\n",
GNUNET_STRINGS_absolute_time_to_string (exchange->key_data.last_denom_issue_date));
GNUNET_asprintf (&arg,
"/keys?last_issue_date=%llu",
(unsigned long long) exchange->key_data.last_denom_issue_date.abs_value_us / 1000000LLU);
kr->url = TEAH_path_to_url (exchange,
arg);
GNUNET_free (arg);
sprintf (&url[strlen (url)],
"last_issue_date=%llu&",
(unsigned long long) exchange->key_data.last_denom_issue_date.abs_value_us / 1000000LLU);
}
else
if (GNUNET_YES == exchange->with_now)
{
kr->url = TEAH_path_to_url (exchange,
"/keys");
TALER_LOG_DEBUG ("Faking now to GET /keys): %s\n",
GNUNET_STRINGS_absolute_time_to_string (exchange->now));
sprintf (&url[strlen (url)],
"now=%llu&",
(unsigned long long) exchange->now.abs_value_us / 1000000LLU);
}
/* Clean the last '&'/'?' sign that we optimistically put. */
url[strlen (url) - 1] = '\0';
kr->url = TEAH_path_to_url (exchange,
url);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting keys with URL `%s'.\n",
kr->url);

View File

@ -151,6 +151,7 @@ run (void *cls,
};
now = GNUNET_TIME_absolute_get ();
struct TALER_TESTING_Command ordinary_cherry_pick[] = {
/* Trigger keys reloading from disk. */
@ -164,11 +165,12 @@ run (void *cls,
1, /* generation */
1),
/**
* We now set lookahead_sign to 90s, and fake 10s passed.
* We now set lookahead_sign to 90s, and expect a new DK
* to be created. The first one lives (= has withdraw_duration of)
* only 80s.
*/
TALER_TESTING_cmd_exec_keyup_with_now ("keyup-2",
CONFIG_FILE_EXTENDED,
NOWPLUSSECS (10)),
TALER_TESTING_cmd_exec_keyup ("keyup-2",
CONFIG_FILE_EXTENDED),
TALER_TESTING_cmd_exec_auditor_sign ("sign-keys-1",
CONFIG_FILE_EXTENDED),
@ -177,19 +179,15 @@ run (void *cls,
is->exchanged,
SIGUSR1),
/**
* First DK has still 70s of remaining life
* (duration_withdraw), so it's not enough to cover the new
* 90s window, so a new one should be created.
* Total 2 DKs.
*/
TALER_TESTING_cmd_check_keys ("check-keys-2",
2, /* generation */
2),
/* Must fake 20s lapse now. */
TALER_TESTING_cmd_exec_keyup_with_now ("keyup-3",
CONFIG_FILE_EXTENDED,
NOWPLUSSECS (20)),
/* Nothing should happen now. */
TALER_TESTING_cmd_exec_keyup ("keyup-3",
CONFIG_FILE_EXTENDED),
TALER_TESTING_cmd_exec_auditor_sign ("sign-keys-2",
CONFIG_FILE),
TALER_TESTING_cmd_signal ("trigger-keys-reload-2",
@ -197,13 +195,15 @@ run (void *cls,
SIGUSR1),
/**
* First DK has 50s of remaining life (duration_withdraw).
* The second DK has ~60s of remaining life, therefore two
* keys should be (still) returned.
* Make 30s time lapse (by passing the "now" argument to
* "/keys"). First DK has 50s of remaining life
* (duration_withdraw). The second DK has ~60s of remaining
* life, therefore two keys should be (still) returned.
*/
TALER_TESTING_cmd_check_keys ("check-keys-3",
3,
2),
TALER_TESTING_cmd_check_keys_with_now ("check-keys-3",
3,
2,
NOWPLUSSECS (30)),
TALER_TESTING_cmd_end ()
};
struct TALER_TESTING_Command commands[] = {

View File

@ -73,7 +73,7 @@ struct CheckKeysState
* If GNUNET_YES, then we'll provide the "/keys" request.
* with the "now" argument.
*/
unsigned int with_now;
int with_now;
/**
* Fake now as passed by the user.