gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated: [testing] finish get charities


From: gnunet
Subject: [taler-donau] branch master updated: [testing] finish get charities
Date: Wed, 28 Feb 2024 23:35:20 +0100

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

lukas-matyja pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new a1e0ac1  [testing] finish get charities
     new 7ef32ba  Merge remote-tracking branch 'refs/remotes/origin/master'
a1e0ac1 is described below

commit a1e0ac1f097806255e1aadd9fe6edd95644fa502
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Wed Feb 28 23:35:06 2024 +0100

    [testing] finish get charities
---
 src/include/donau_service.h                        |  2 -
 src/include/donau_testing_lib.h                    | 12 ++++-
 src/lib/donau_api_charities_get.c                  | 22 +--------
 src/lib/donau_api_charity_get.c                    | 34 ++-----------
 src/testing/Makefile.am                            |  1 +
 src/testing/test_donau_api.c                       |  5 +-
 ...arity_get.c => testing_api_cmd_charities_get.c} | 56 +++++-----------------
 src/testing/testing_api_cmd_charity_get.c          | 26 +---------
 8 files changed, 35 insertions(+), 123 deletions(-)

diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index 13e8b4a..7f7fd54 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -881,7 +881,6 @@ DONAU_charities_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const struct DONAU_BearerToken bearer,
-  const struct GNUNET_TIME_Relative timeout,
   DONAU_GetCharitiesResponseCallback cb,
   void *cb_cls);
 
@@ -1011,7 +1010,6 @@ DONAU_charity_get (
   const char *url,
   const uint64_t id,
   const struct DONAU_BearerToken bearer,
-  struct GNUNET_TIME_Relative timeout,
   DONAU_GetCharityResponseCallback cb,
   void *cb_cls);
 
diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h
index da00bd6..7a4a18b 100644
--- a/src/include/donau_testing_lib.h
+++ b/src/include/donau_testing_lib.h
@@ -65,9 +65,19 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_get (const char *label,
                                                                const uint64_t 
charity_id,
                                                                const struct 
DONAU_BearerToken bearer,
-                                                               const struct 
GNUNET_TIME_Relative timeout,
                                 unsigned int expected_response_code);
 
+/**
+ * Create a GET "charities" command.
+ *
+ * @param label the command label.
+ * @param expected_response_code expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_charities_get (const char *label,
+                                                        unsigned int 
expected_response_code);
+
   /**
  * Convenience function to run a test.
  *
diff --git a/src/lib/donau_api_charities_get.c 
b/src/lib/donau_api_charities_get.c
index d33e73e..96e7e15 100644
--- a/src/lib/donau_api_charities_get.c
+++ b/src/lib/donau_api_charities_get.c
@@ -131,8 +131,6 @@ handle_charities_get_finished (void *cls,
                              long response_code,
                              const void *resp_obj)
 {
-  // struct DONAU_Charities *cd = NULL;
-
   struct DONAU_CharitiesGetHandle *cgh = cls;
   const json_t *j = resp_obj;
   struct DONAU_GetCharitiesResponse gcresp = {
@@ -186,6 +184,7 @@ handle_charities_get_finished (void *cls,
                 cgh->url);
     break;
   }
+
   if (NULL != cgh->cb)
   {
     cgh->cb (cgh->cb_cls,
@@ -201,7 +200,6 @@ DONAU_charities_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const struct DONAU_BearerToken bearer, // TODO: check authorization
-  struct GNUNET_TIME_Relative timeout,
   DONAU_GetCharitiesResponseCallback cb,
   void *cb_cls)
 {
@@ -214,16 +212,7 @@ DONAU_charities_get (
   cgh->url = GNUNET_strdup (url);
   cgh->cb = cb;
   cgh->cb_cls = cb_cls;
-  char *arg_str;
-  unsigned long long tms
-    = timeout.rel_value_us
-      / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
-  if (tms == 0)
-         arg_str = "charities";
-  else
-      GNUNET_asprintf (&arg_str,
-                       "charities?timeout_ms=%llu",
-                                          tms);
+  char *arg_str = "charities";
   cgh->url = TALER_url_join (url,
                              arg_str,
                              NULL);
@@ -243,13 +232,6 @@ DONAU_charities_get (
     GNUNET_free (cgh);
     return NULL;
   }
-  if (0 != tms)
-  {
-    GNUNET_break (CURLE_OK ==
-                  curl_easy_setopt (eh,
-                                    CURLOPT_TIMEOUT_MS,
-                                    (long) (tms + 100L)));
-  }
   cgh->job = GNUNET_CURL_job_add_with_ct_json (ctx,
                                   eh,
                                   &handle_charities_get_finished,
diff --git a/src/lib/donau_api_charity_get.c b/src/lib/donau_api_charity_get.c
index 8148e63..006c8e5 100644
--- a/src/lib/donau_api_charity_get.c
+++ b/src/lib/donau_api_charity_get.c
@@ -198,7 +198,6 @@ DONAU_charity_get (
   const char *url,
   const uint64_t id,
   const struct DONAU_BearerToken bearer, // TODO: check authorization
-  struct GNUNET_TIME_Relative timeout,
   DONAU_GetCharityResponseCallback cb,
   void *cb_cls)
 {
@@ -213,27 +212,11 @@ DONAU_charity_get (
   cgh->charity_id = id;
   cgh->cb_cls = cb_cls;
   char arg_str[sizeof (id) * 2 + 32];
-  char timeout_str[32];
-  unsigned int tms
-    = (unsigned int) timeout.rel_value_us
-      / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
-  GNUNET_snprintf (timeout_str,
-                                  sizeof (timeout_str),
-                                  "%u",
-                                  tms);
-  if (tms == 0)
-         GNUNET_snprintf (arg_str,
-                                          sizeof (arg_str),
-                                          "charities/%llu",
-                                          (unsigned long long)
-                                          id);
-  else
-      GNUNET_snprintf (arg_str,
-                       sizeof (arg_str),
-                       "charities/%llu?timeout_ms=%s",
-                                          (unsigned long long)
-                                          id,
-                       timeout_str); //TODO: query by year
+  GNUNET_snprintf (arg_str,
+                                  sizeof (arg_str),
+                                  "charities/%llu",
+                                  (unsigned long long)
+                                  id);
   cgh->url = TALER_url_join (url,
                              arg_str,
                              NULL);
@@ -253,13 +236,6 @@ DONAU_charity_get (
     GNUNET_free (cgh);
     return NULL;
   }
-  if (0 != tms)
-  {
-    GNUNET_break (CURLE_OK ==
-                  curl_easy_setopt (eh,
-                                    CURLOPT_TIMEOUT_MS,
-                                    (long) (tms + 100L)));
-  }
   cgh->job = GNUNET_CURL_job_add_with_ct_json (ctx,
                                   eh,
                                   &handle_charity_get_finished,
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 3989dcc..415d4e2 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -22,6 +22,7 @@ libdonautesting_la_LDFLAGS = \
 libdonautesting_la_SOURCES = \
   testing_api_cmd_get_donau.c \
   testing_api_cmd_charity_get.c \
+  testing_api_cmd_charities_get.c \
   testing_api_traits.c \
   testing_api_loop.c
 
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c
index 1965d37..15f97d5 100644
--- a/src/testing/test_donau_api.c
+++ b/src/testing/test_donau_api.c
@@ -79,9 +79,10 @@ run (void *cls,
       TALER_TESTING_cmd_charity_get ("get-charity-by-id",
                                                                  4,
                                                                          
bearer,
-                                                                 
GNUNET_TIME_relative_get_zero_ (),
                                       MHD_HTTP_OK),
-         //TODO: test POST charity, GET charities, DELETE charity
+         TALER_TESTING_cmd_charities_get ("get-charities",
+                                                                         
MHD_HTTP_OK),
+         //TODO: test POST charity, DELETE charity
       /* End the suite. */
       TALER_TESTING_cmd_end ()
     };
diff --git a/src/testing/testing_api_cmd_charity_get.c 
b/src/testing/testing_api_cmd_charities_get.c
similarity index 72%
copy from src/testing/testing_api_cmd_charity_get.c
copy to src/testing/testing_api_cmd_charities_get.c
index 7e18f3c..78e2bea 100644
--- a/src/testing/testing_api_cmd_charity_get.c
+++ b/src/testing/testing_api_cmd_charities_get.c
@@ -17,9 +17,8 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file testing/testing_api_cmd_charity_get.c
- * @brief Implement the GET /reserve/$RID test command.
- * @author Marcello Stanisci
+ * @file testing/testing_api_cmd_charities_get.c
+ * @brief Implement the GET /charities test command.
  * @author Lukas Matyja
  */
 #include <taler/platform.h>
@@ -34,32 +33,16 @@
  */
 struct StatusState
 {
-
-  /**
-   * How long do we give the donau to respond?
-   */
-  struct GNUNET_TIME_Relative timeout;
-
   /**
-   * Poller waiting for us.
+   * Handle to the "charities status" operation.
    */
-//  struct PollState *ps;
-
-  /**
-   * Handle to the "charity status" operation.
-   */
-  struct DONAU_CharityGetHandle *cgh;
+  struct DONAU_CharitiesGetHandle *cgh;
 
   /**
    * The bearer token for authorization.
    */
   struct DONAU_BearerToken bearer;
 
-  /**
-   * The ID of the requested charity.
-   */
-  uint64_t charity_id;
-
   /**
    * Expected HTTP response code.
    */
@@ -81,12 +64,10 @@ struct StatusState
  * @param gcr HTTP response details
  */
 static void
-charity_status_cb (void *cls,
-                   const struct DONAU_GetCharityResponse *gcr)
+charities_status_cb (void *cls,
+                   const struct DONAU_GetCharitiesResponse *gcr)
 {
   struct StatusState *ss = cls;
-  struct TALER_TESTING_Interpreter *is = ss->is;
-
 
   ss->cgh = NULL;
   if (ss->expected_response_code != gcr->hr.http_status)
@@ -102,9 +83,7 @@ charity_status_cb (void *cls,
     TALER_TESTING_interpreter_fail (ss->is);
     return;
   }
-
-  if (GNUNET_TIME_relative_is_zero (ss->timeout))
-    TALER_TESTING_interpreter_next (is);
+  TALER_TESTING_interpreter_next (ss->is);
 }
 
 
@@ -124,19 +103,12 @@ status_run (void *cls,
 
   ss->is = is;
 
-  ss->cgh = DONAU_charity_get (
+  ss->cgh = DONAU_charities_get (
     TALER_TESTING_interpreter_get_context (is),
        "http://localhost:8080/";, //TODO: TALER_TESTING_get_donau_url (is),
-    ss->charity_id,
     ss->bearer,
-    ss->timeout,
-    &charity_status_cb,
+    &charities_status_cb,
     ss);
-  if (! GNUNET_TIME_relative_is_zero (ss->timeout))
-  {
-    TALER_TESTING_interpreter_next (is);
-    return;
-  }
 }
 
 /**
@@ -157,7 +129,7 @@ status_cleanup (void *cls,
        // log incomplete command
        TALER_TESTING_command_incomplete (ss->is,
                                                                           
cmd->label);
-    DONAU_charity_get_cancel (ss->cgh);
+    DONAU_charities_get_cancel (ss->cgh);
     ss->cgh = NULL;
   }
   GNUNET_free (ss);
@@ -165,19 +137,13 @@ status_cleanup (void *cls,
 
 
 struct TALER_TESTING_Command
-TALER_TESTING_cmd_charity_get (const char *label,
-                                                               const uint64_t 
charity_id,
-                                                               const struct 
DONAU_BearerToken bearer,
-                                                               const struct 
GNUNET_TIME_Relative timeout,
+TALER_TESTING_cmd_charities_get (const char *label,
                                 unsigned int expected_response_code)
 {
   struct StatusState *ss;
 
   ss = GNUNET_new (struct StatusState);
   ss->expected_response_code = expected_response_code;
-  ss->timeout = timeout;
-  ss->bearer = bearer;
-  ss->charity_id = charity_id;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ss,
diff --git a/src/testing/testing_api_cmd_charity_get.c 
b/src/testing/testing_api_cmd_charity_get.c
index 7e18f3c..7ea3183 100644
--- a/src/testing/testing_api_cmd_charity_get.c
+++ b/src/testing/testing_api_cmd_charity_get.c
@@ -18,7 +18,7 @@
 */
 /**
  * @file testing/testing_api_cmd_charity_get.c
- * @brief Implement the GET /reserve/$RID test command.
+ * @brief Implement the GET /charities/$ID test command.
  * @author Marcello Stanisci
  * @author Lukas Matyja
  */
@@ -34,17 +34,6 @@
  */
 struct StatusState
 {
-
-  /**
-   * How long do we give the donau to respond?
-   */
-  struct GNUNET_TIME_Relative timeout;
-
-  /**
-   * Poller waiting for us.
-   */
-//  struct PollState *ps;
-
   /**
    * Handle to the "charity status" operation.
    */
@@ -85,7 +74,6 @@ charity_status_cb (void *cls,
                    const struct DONAU_GetCharityResponse *gcr)
 {
   struct StatusState *ss = cls;
-  struct TALER_TESTING_Interpreter *is = ss->is;
 
 
   ss->cgh = NULL;
@@ -102,9 +90,7 @@ charity_status_cb (void *cls,
     TALER_TESTING_interpreter_fail (ss->is);
     return;
   }
-
-  if (GNUNET_TIME_relative_is_zero (ss->timeout))
-    TALER_TESTING_interpreter_next (is);
+  TALER_TESTING_interpreter_next (ss->is);
 }
 
 
@@ -129,14 +115,8 @@ status_run (void *cls,
        "http://localhost:8080/";, //TODO: TALER_TESTING_get_donau_url (is),
     ss->charity_id,
     ss->bearer,
-    ss->timeout,
     &charity_status_cb,
     ss);
-  if (! GNUNET_TIME_relative_is_zero (ss->timeout))
-  {
-    TALER_TESTING_interpreter_next (is);
-    return;
-  }
 }
 
 /**
@@ -168,14 +148,12 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_get (const char *label,
                                                                const uint64_t 
charity_id,
                                                                const struct 
DONAU_BearerToken bearer,
-                                                               const struct 
GNUNET_TIME_Relative timeout,
                                 unsigned int expected_response_code)
 {
   struct StatusState *ss;
 
   ss = GNUNET_new (struct StatusState);
   ss->expected_response_code = expected_response_code;
-  ss->timeout = timeout;
   ss->bearer = bearer;
   ss->charity_id = charity_id;
   {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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