gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] 04/04: Provide testing API to fake now for


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 04/04: Provide testing API to fake now for "/keys".
Date: Wed, 03 Apr 2019 18:09:51 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository exchange.

commit ce71d83ad6b651b3cac43d131bf62afa1583bf67
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Apr 3 18:09:10 2019 +0200

    Provide testing API to fake now for "/keys".
---
 src/lib/testing_api_cmd_check_keys.c | 63 +++++++++++++++++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/src/lib/testing_api_cmd_check_keys.c 
b/src/lib/testing_api_cmd_check_keys.c
index 375a35c4..983098ce 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.

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]