gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated (35c064b9 -> ce71d83


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (35c064b9 -> ce71d83a)
Date: Wed, 03 Apr 2019 18:09:47 +0200

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

marcello pushed a change to branch master
in repository exchange.

    from 35c064b9 Faking the time.
     new 6e6ce685 Provide API to fake now when requesting /keys.
     new dc7d74ca fix keyup invocation.
     new ccd43ba4 gitignore
     new ce71d83a Provide testing API to fake now for "/keys".

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                           |  1 +
 src/include/taler_exchange_service.h | 20 ++++++++++++
 src/lib/exchange_api_handle.c        | 36 +++++++++++++++++++++
 src/lib/testing_api_cmd_check_keys.c | 63 +++++++++++++++++++++++++++++++++++-
 src/lib/testing_api_cmd_exec_keyup.c |  7 ++--
 5 files changed, 124 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index 82e95c25..8696558d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ doc/doxygen/doxygen_sqlite3.db
 src/auditor/taler-auditor
 src/auditor/taler-auditor-dbinit
 src/auditor/taler-auditor-sign
+src/bank-lib/taler-fakebank-run
 src/bank-lib/test_bank_api
 src/bank-lib/test_bank_api_new
 src/bank-lib/test_bank_api_with_fakebank
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 88fcf74a..880e6038 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -422,6 +422,26 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle 
*exchange);
 const struct TALER_EXCHANGE_Keys *
 TALER_EXCHANGE_get_keys (struct TALER_EXCHANGE_Handle *exchange);
 
+
+/**
+ * Set the fake now to be used when requesting "/keys".
+ *
+ * @param exchange exchange handle.
+ * @param now fake now to use.  Note: this value will be
+ *        used _until_ its use will be unset via @a TALER_EXCHANGE_unset_now()
+ */
+void
+TALER_EXCHANGE_set_now (struct TALER_EXCHANGE_Handle *exchange,
+                        struct GNUNET_TIME_Absolute now);
+
+/**
+ * Unset the fake now to be used when requesting "/keys".
+ *
+ * @param exchange exchange handle.
+ */
+void
+TALER_EXCHANGE_unset_now (struct TALER_EXCHANGE_Handle *exchange);
+
 /**
  * Let the user set the last valid denomination time manually.
  *
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 986bcc4c..5cc65de3 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -214,6 +214,17 @@ struct TALER_EXCHANGE_Handle
    */
   enum ExchangeHandleState state;
 
+  /**
+   * If GNUNET_YES, use fake now given by the user, in
+   * request of "/keys".
+   */
+  unsigned int with_now;
+
+  /**
+   * Fake now given by the user.
+   */
+  struct GNUNET_TIME_Absolute now;
+
 };
 
 
@@ -1086,6 +1097,31 @@ void
 TEAH_handle_reset (struct TALER_EXCHANGE_Handle *h);
 
 
+/**
+ * Set the fake now to be used when requesting "/keys".
+ *
+ * @param exchange exchange handle.
+ * @param now fake now to use.  Note: this value will be
+ *        used _until_ its use will be unset via @a TALER_EXCHANGE_unset_now()
+ */
+void
+TALER_EXCHANGE_set_now (struct TALER_EXCHANGE_Handle *exchange,
+                        struct GNUNET_TIME_Absolute now)
+{
+  exchange->with_now = GNUNET_YES;
+  exchange->now = now;
+}
+
+/**
+ * Unset the fake now to be used when requesting "/keys".
+ *
+ * @param exchange exchange handle.
+ */
+void
+TALER_EXCHANGE_unset_now (struct TALER_EXCHANGE_Handle *exchange)
+{
+  exchange->with_now = GNUNET_NO;
+}
 
 /**
  * Let the user set the last valid denomination time manually.
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.
diff --git a/src/lib/testing_api_cmd_exec_keyup.c 
b/src/lib/testing_api_cmd_exec_keyup.c
index d534db06..e457a28e 100644
--- a/src/lib/testing_api_cmd_exec_keyup.c
+++ b/src/lib/testing_api_cmd_exec_keyup.c
@@ -49,7 +49,7 @@ struct KeyupState
 
   /**
    * If GNUNET_YES, then the fake @e now value will be
-   * passed to taler-exchange-keyup via the --timestamp
+   * passed to taler-exchange-keyup via the --time
    * option.
    */
   unsigned int with_now;
@@ -85,7 +85,7 @@ keyup_run (void *cls,
        "taler-exchange-keyup",
        "-c", ks->config_filename,
        "-o", "auditor.in",
-       "--timestamp",
+       "--time",
        GNUNET_STRINGS_absolute_time_to_string (ks->now),
        NULL);
   }
@@ -106,6 +106,9 @@ keyup_run (void *cls,
     TALER_TESTING_interpreter_fail (is);
     return;
   }
+
+  /* This function does not tell whether the command
+   * succeeded or not!  */
   TALER_TESTING_wait_for_sigchld (is);
 }
 

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



reply via email to

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