aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/testing_api_cmd_check_keys.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/lib/testing_api_cmd_check_keys.c b/src/lib/testing_api_cmd_check_keys.c
index 375a35c4f..983098ce9 100644
--- a/src/lib/testing_api_cmd_check_keys.c
+++ b/src/lib/testing_api_cmd_check_keys.c
@@ -68,6 +68,18 @@ struct CheckKeysState
* equals GNUNET_YES.
*/
struct GNUNET_TIME_Absolute last_denom_date;
+
+ /**
+ * If GNUNET_YES, then we'll provide the "/keys" request.
+ * with the "now" argument.
+ */
+ unsigned int with_now;
+
+ /**
+ * Fake now as passed by the user.
+ */
+ struct GNUNET_TIME_Absolute now;
+
};
@@ -105,7 +117,10 @@ check_keys_run (void *cls,
cks->last_denom_date);
}
- /* Means re-download /keys. */
+ if (GNUNET_YES == cks->with_now)
+ TALER_EXCHANGE_set_now (is->exchange,
+ cks->now);
+ /* Redownload /keys. */
GNUNET_break
(0 == TALER_EXCHANGE_check_keys_current
(is->exchange,
@@ -147,6 +162,9 @@ check_keys_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
+
+ /* Let's unset the fake now before moving on. */
+ TALER_EXCHANGE_unset_now (is->exchange);
TALER_TESTING_interpreter_next (is);
}
@@ -252,6 +270,49 @@ TALER_TESTING_cmd_check_keys
/**
+ * 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)
+{
+ struct CheckKeysState *cks;
+
+ cks = GNUNET_new (struct CheckKeysState);
+ cks->generation = generation;
+ cks->num_denom_keys = num_denom_keys;
+ cks->now = now;
+ cks->with_now = GNUNET_YES;
+
+ struct TALER_TESTING_Command cmd = {
+ .cls = cks,
+ .label = label,
+ .run = &check_keys_run,
+ .cleanup = &check_keys_cleanup
+ };
+
+ return cmd;
+}
+
+
+
+/**
* Make a "check keys" command that forcedly does NOT cherry pick;
* just redownload the whole /keys. Then checks whether the number
* of denomination keys from @a exchange matches @a num_denom_keys.