gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: backenddb pending webhook test o


From: gnunet
Subject: [taler-merchant] branch master updated: backenddb pending webhook test ok
Date: Tue, 07 Feb 2023 17:58:45 +0100

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

priscilla-huang pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new d1ea7e9a backenddb pending webhook test ok
d1ea7e9a is described below

commit d1ea7e9a6ff85f3951cb31c6c5c0a5cfd3c62930
Author: priscilla <priscilla.huang@efrei.net>
AuthorDate: Tue Feb 7 11:58:28 2023 -0500

    backenddb pending webhook test ok
---
 src/backenddb/test_merchantdb.c          | 81 +++++++++++++++-----------------
 src/testing/testing_api_cmd_testserver.c | 48 +++++++++----------
 2 files changed, 63 insertions(+), 66 deletions(-)

diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index fea6c521..3dbf9cbb 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -7880,12 +7880,13 @@ test_update_pending_webhook (const struct InstanceData 
*instance,
                              struct PendingWebhookData *pwebhook,
                              enum GNUNET_DB_QueryStatus expected_result)
 {
-  struct GNUNET_TIME_Absolute next_attempt; // FIXME: uninitialized!
-
+  pwebhook->pwebhook.next_attempt = GNUNET_TIME_relative_to_absolute (
+    GNUNET_TIME_UNIT_HOURS);
+  pwebhook->pwebhook.retries++;
   TEST_COND_RET_ON_FAIL (expected_result ==
                          plugin->update_pending_webhook (plugin->cls,
                                                          
pwebhook->webhook_serial,
-                                                         next_attempt),
+                                                         
pwebhook->pwebhook.next_attempt),
                          "Update pending webhook failed\n");
   return 0;
 }
@@ -7926,14 +7927,8 @@ get_pending_serial_cb (void *cls,
                        const char *body)
 {
   struct LookupPendingWebhookSerial_Closure *lpw = cls;
-  if (NULL == lpw)
-    return;
-  if ((GNUNET_TIME_absolute_cmp (
-                                 lpw->pwebhook->pwebhook.next_attempt,
-                                 ==,
-                                 next_attempt)) &&
-      (lpw->pwebhook->pwebhook.retries == retries) &&
-      (0 == strcmp (lpw->pwebhook->pwebhook.url,
+
+  if ((0 == strcmp (lpw->pwebhook->pwebhook.url,
                     url)) &&
       (0 == strcmp (lpw->pwebhook->pwebhook.http_method,
                     http_method)) &&
@@ -7944,6 +7939,15 @@ get_pending_serial_cb (void *cls,
     {
       lpw->webhook_pending_serial = webhook_pending_serial;
     }
+  /* else
+    {
+      fprintf(stdout, "next_attempt: %lu vs %lu\n", 
lpw->pwebhook->pwebhook.next_attempt.abs_value_us, next_attempt.abs_value_us);
+      fprintf(stdout, "retries: %d vs %d\n", lpw->pwebhook->pwebhook.retries, 
retries);
+      fprintf(stdout, "url: %s vs %s\n", lpw->pwebhook->pwebhook.url, url);
+      fprintf(stdout, "http_method: %s vs %s\n", 
lpw->pwebhook->pwebhook.http_method, http_method);
+      fprintf(stdout, "header: %s vs %s\n", lpw->pwebhook->pwebhook.header, 
header);
+      fprintf(stdout, "body: %s vs %s\n", lpw->pwebhook->pwebhook.body, body);
+      }*/
 }
 
 
@@ -7964,9 +7968,12 @@ get_pending_serial (const struct InstanceData *instance,
   };
 
   GNUNET_assert (0 <
-                 plugin->lookup_future_webhook (plugin->cls,
-                                                &get_pending_serial_cb,
-                                                &lpw));
+                 plugin->lookup_all_webhooks (plugin->cls,
+                                              instance->instance.id,
+                                              0,
+                                              INT_MAX,
+                                              &get_pending_serial_cb,
+                                              &lpw));
   GNUNET_assert (0 != lpw.webhook_pending_serial);
 
   return lpw.webhook_pending_serial;
@@ -8009,7 +8016,7 @@ struct TestLookupPendingWebhooks_Closure
  */
 static void
 lookup_pending_webhooks_cb (void *cls,
-                            uint64_t webhook_serial,
+                            uint64_t webhook_pending_serial,
                             struct GNUNET_TIME_Absolute next_attempt,
                             uint32_t retries,
                             const char *url,
@@ -8018,18 +8025,11 @@ lookup_pending_webhooks_cb (void *cls,
                             const char *body)
 {
   struct TestLookupPendingWebhooks_Closure *cmp = cls;
-  if (NULL == cmp)
-    return;
+
   cmp->results_length++;
   for (unsigned int i = 0; cmp->webhooks_to_cmp_length > i; ++i)
   {
-    if ((cmp->webhooks_to_cmp[i].webhook_serial == webhook_serial) &&
-        (GNUNET_TIME_absolute_cmp (
-           cmp->webhooks_to_cmp[i].pwebhook.next_attempt,
-           ==,
-           next_attempt)) &&
-        (cmp->webhooks_to_cmp[i].pwebhook.retries == retries) &&
-        (0 == strcmp (cmp->webhooks_to_cmp[i].pwebhook.url,
+    if ((0 == strcmp (cmp->webhooks_to_cmp[i].pwebhook.url,
                       url)) &&
         (0 == strcmp (cmp->webhooks_to_cmp[i].pwebhook.http_method,
                       http_method)) &&
@@ -8038,9 +8038,8 @@ lookup_pending_webhooks_cb (void *cls,
         (0 == strcmp (cmp->webhooks_to_cmp[i].pwebhook.body,
                       body)) )
       {
-        cmp->results_matching[i] += 1;
+        cmp->results_matching[i]++;
       }
-    
   }
 }
 
@@ -8065,7 +8064,7 @@ test_lookup_pending_webhooks (const struct InstanceData 
*instance,
     .results_matching = results_matching,
     .results_length = 0
   };
-  
+
   memset (results_matching, 0, sizeof (results_matching));
   if (0 > plugin->lookup_pending_webhooks (plugin->cls,
                                            &lookup_pending_webhooks_cb,
@@ -8114,7 +8113,8 @@ test_lookup_future_webhook (const struct InstanceData 
*instance,
     .results_matching = results_matching,
     .results_length = 0
   };
-  memset (results_matching, 0, sizeof (unsigned int) * pwebhooks_length);
+
+  memset (results_matching, 0, sizeof (results_matching));
   if (0 > plugin->lookup_future_webhook (plugin->cls,
                                          &lookup_pending_webhooks_cb,
                                          &cls))
@@ -8291,29 +8291,26 @@ run_test_pending_webhooks (struct 
TestPendingWebhooks_Closure *cls)
   TEST_RET_ON_FAIL (test_insert_pending_webhook (&cls->instance,
                                                  &cls->pwebhooks[0],
                                                  
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
-  /* Test pending webhook update */
-  cls->pwebhooks[0].pwebhook.next_attempt = GNUNET_TIME_absolute_get ();
-
-  TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance,
-                                                 &cls->pwebhooks[0],
-                                                 
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
-  TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance,
-                                                 &cls->pwebhooks[1],
-                                                 
GNUNET_DB_STATUS_SUCCESS_NO_RESULTS));
-
-  /* Test collective pending webhook lookup */
   TEST_RET_ON_FAIL (test_insert_pending_webhook (&cls->instance,
                                                  &cls->pwebhooks[1],
                                                  
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
+  /* Test collective pending webhook lookup */
   TEST_RET_ON_FAIL (test_lookup_pending_webhooks (&cls->instance,
                                                   2,
                                                   cls->pwebhooks));
+  /* Test pending webhook update */
+  TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance,
+                                                 &cls->pwebhooks[0],
+                                                 
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
+  TEST_RET_ON_FAIL (test_lookup_future_webhook (&cls->instance,
+                                                1,
+                                                &cls->pwebhooks[1]));
+  TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance,
+                                                 &cls->pwebhooks[1],
+                                                 
GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); //???
   TEST_RET_ON_FAIL (test_lookup_all_webhooks (&cls->instance,
                                               2,
                                               cls->pwebhooks));
-  TEST_RET_ON_FAIL (test_lookup_future_webhook (&cls->instance,
-                                                1,
-                                                cls->pwebhooks));
 
   uint64_t webhook_pending_serial0 = get_pending_serial (&cls->instance,
                                                          &cls->pwebhooks[0]);
diff --git a/src/testing/testing_api_cmd_testserver.c 
b/src/testing/testing_api_cmd_testserver.c
index 0becdbde..77f0e692 100644
--- a/src/testing/testing_api_cmd_testserver.c
+++ b/src/testing/testing_api_cmd_testserver.c
@@ -93,6 +93,7 @@ handle_post (void *cls,
   (void) content_type;
   (void) transfer_encoding;
   (void) off;
+
   return MHD_YES;
 }
 
@@ -270,6 +271,27 @@ testserver_cleanup (void *cls,
 }
 
 
+static int
+traits_testserver (void *cls,
+                   const void **ret,
+                   const char *trait,
+                   unsigned int index)
+{
+  struct TestserverState *ser = cls;
+  struct TALER_TESTING_Trait traits[] = {
+    TALER_TESTING_make_trait_url (&ser->url),
+    TALER_TESTING_make_trait_http_method (&ser->http_method),
+    TALER_TESTING_make_trait_header_template (&ser->header),
+    TALER_TESTING_make_trait_body_template (&ser->body),
+    TALER_TESTING_trait_end (),
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
 /**
  * This function is used to start the web server.
  *
@@ -289,7 +311,8 @@ TALER_TESTING_cmd_testserver (const char *label,
       .cls = ser,
       .label = label,
       .run = &testserver_run,
-      .cleanup = &testserver_cleanup
+      .cleanup = &testserver_cleanup,
+      .traits = &traits_testserver
     };
 
     return cmd;
@@ -297,28 +320,6 @@ TALER_TESTING_cmd_testserver (const char *label,
 }
 
 
-static int
-traits_testserver (void *cls,
-                   const void **ret,
-                   const char *trait,
-                   unsigned int index)
-{
-  struct TestserverState *ser = cls;
-  struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_url (&ser->url),
-    TALER_TESTING_make_trait_http_method (&ser->http_method),
-    TALER_TESTING_make_trait_header_template (&ser->header),
-    TALER_TESTING_make_trait_body_template (&ser->body),
-    TALER_TESTING_trait_end (),
-  };
-
-  return TALER_TESTING_get_trait (traits,
-                                  ret,
-                                  trait,
-                                  index);
-}
-
-
 /**
  * This function is used to check the web server
  *
@@ -351,7 +352,6 @@ TALER_TESTING_cmd_checkserver (const char *label,
       .label = label,
       .run = &testserver_run,
       .cleanup = &testserver_cleanup,
-      .traits = &traits_testserver
     };
 
     return cmd;

-- 
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]