summaryrefslogtreecommitdiff
path: root/src/lib/testing_api_cmd_check_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/testing_api_cmd_check_keys.c')
-rw-r--r--src/lib/testing_api_cmd_check_keys.c66
1 files changed, 66 insertions, 0 deletions
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
@@ -137,6 +158,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
* @a exchange matches @a num_denom_keys.
*
* @param label command label