From 148b546435a8fdd83372d4f546d809f5322ae05b Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Thu, 17 Jan 2019 16:37:16 +0100 Subject: /keys API. Adding method to override the last_denom value for a key set. --- src/lib/testing_api_cmd_check_keys.c | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'src/lib/testing_api_cmd_check_keys.c') diff --git a/src/lib/testing_api_cmd_check_keys.c b/src/lib/testing_api_cmd_check_keys.c index 6cd605c38..976639ae0 100644 --- a/src/lib/testing_api_cmd_check_keys.c +++ b/src/lib/testing_api_cmd_check_keys.c @@ -54,6 +54,20 @@ struct CheckKeysState * downloaded. */ unsigned int pull_all_keys; + + /** + * If GNUNET_YES, then the user must specify the + * last_denom_issue_date manually. This way, it is possible + * to force whatever X value here: /keys?last_denom_issue=X. + */ + unsigned int set_last_denom; + + /** + * Value X to set as the URL parameter: + * "/keys?last_denom_issue=X" is used only when `set_last_denom' + * equals GNUNET_YES. + */ + struct GNUNET_TIME_Absolute last_denom_date; }; @@ -82,6 +96,13 @@ check_keys_run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Triggering GET /keys, cmd `%s'\n", cmd->label); + + if (GNUNET_YES == cks->set_last_denom) + { + TALER_LOG_DEBUG ("Forcing last_denom_date URL argument\n"); + TALER_EXCHANGE_set_last_denom (is->exchange, + cks->last_denom_date); + } /* Means re-download /keys. */ GNUNET_break @@ -134,6 +155,51 @@ 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 exchange connection handle to the exchange to test. + * @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) +{ + 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; + + 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 -- cgit v1.2.3