gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: update


From: gnunet
Subject: [taler-merchant] branch master updated: update
Date: Thu, 12 Jan 2023 14:17:50 +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 aa625266 update
aa625266 is described below

commit aa6252669673433a9443e40f336fdd7348a1e006
Author: priscilla <priscilla.huang@efrei.net>
AuthorDate: Thu Jan 12 08:17:38 2023 -0500

    update
---
 ...r-merchant-httpd_private-get-pending-webhooks.c |  4 +--
 src/backenddb/plugin_merchantdb_postgres.c         |  4 +--
 src/backenddb/test_merchantdb.c                    | 32 +++++++++++-----------
 src/include/taler_merchantdb_lib.h                 |  9 ++++++
 4 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-pending-webhooks.c 
b/src/backend/taler-merchant-httpd_private-get-pending-webhooks.c
index c6cd53e5..690b0c14 100644
--- a/src/backend/taler-merchant-httpd_private-get-pending-webhooks.c
+++ b/src/backend/taler-merchant-httpd_private-get-pending-webhooks.c
@@ -41,7 +41,8 @@ add_pending_webhook (void *cls,
                      GNUNET_JSON_pack_uint64 ("webhook_serial",
                                               webhook_serial),
                      GNUNET_JSON_pack_string ("next_attempt",
-                                              next_attempt))));
+                                              next_attempt)
+                                     )));
 }
 
 
@@ -56,7 +57,6 @@ TMH_private_get_pending_webhooks (const struct 
TMH_RequestHandler *rh,
   pa = json_array ();
   GNUNET_assert (NULL != pa);
   qs = TMH_db->lookup_pending_webhooks (TMH_db->cls,
-                                        hc->instance->settings.id,
                                         &add_pending_webhook,
                                         pa);
   if (0 > qs)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index e252c8db..a747ea48 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -10447,11 +10447,11 @@ postgres_connect (void *cls)
                             ",http_method"
                             ",header"
                             ",body"
-                            " FROM merchant_pending_webhook"
+                            " FROM merchant_pending_webhooks"
                             " JOIN merchant_instances"
                             "   USING (merchant_serial)"
                             " WHERE merchant_instances.merchant_id=$1"
-                            "   AND 
merchant_pending_webhook.webhook_serial=$2"),
+                            "   AND 
merchant_pending_webhooks.webhook_serial=$2"),
     /* for postgres_lookup_pending_webhooks() */
     GNUNET_PQ_make_prepare ("lookup_pending_webhooks",
                             "SELECT"
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index cd2f2b16..69a376aa 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -7827,6 +7827,8 @@ make_pending_webhook (uint64_t webhook_serial,
                       struct PendingWebhookData *pwebhook)
 {
   pwebhook->webhook_serial = webhook_serial;
+  pwebhook->pwebhook.next_attempt = GNUNET_TIME_UNIT_ZERO_ABS;
+  pwebhook->pwebhook.retries= 0;
   pwebhook->pwebhook.url = "https://exampletest.com";;
   pwebhook->pwebhook.http_method = "POST";
   pwebhook->pwebhook.header = "Authorization:XYJAORKJEO";
@@ -7844,12 +7846,10 @@ static int
 check_pending_webhooks_equal (const struct 
TALER_MERCHANTDB_PendingWebhookDetails *a,
                       const struct TALER_MERCHANTDB_PendingWebhookDetails *b)
 {
-  if ((GNUNET_TIME_absolute_cmp (a->next_attempt,
-                                 !=,
-                                 b->next_attempt)) &&
-      (a->retries != b->retries) &&
-      (0 != strcmp (a->event_type,
-                    b->event_type)) ||
+  if (GNUNET_TIME_absolute_cmp (a->next_attempt,
+                                !=,
+                                b->next_attempt) ||
+      (a->retries != b->retries) ||
       (0 != strcmp (a->url,
                     b->url)) ||
       (0 != strcmp (a->http_method,
@@ -7858,7 +7858,10 @@ check_pending_webhooks_equal (const struct 
TALER_MERCHANTDB_PendingWebhookDetail
                     b->header)) ||
       (0 != strcmp (a->body,
                     b->body)))
-    return 1;
+    {
+      fprintf(stdout, " retries %d vs %d", a->retries, b->retries);
+      return 1;
+    }
   return 0;
 }
 
@@ -7921,23 +7924,23 @@ test_update_pending_webhook (const struct InstanceData 
*instance,
  */
 static int
 test_lookup_pending_webhook (const struct InstanceData *instance,
-                             const struct PendingWebhookData *pwebhook)
+                             struct PendingWebhookData *pwebhook)
 {
   struct TALER_MERCHANTDB_PendingWebhookDetails lookup_result;
   if (0 > plugin->lookup_pending_webhook (plugin->cls,
                                           instance->instance.id,
-                                          pwebhook->pwebhook_serial,
+                                          &pwebhook->webhook_serial,
                                           &lookup_result))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Lookup pending webhook failed\n");
-    TALER_MERCHANTDB_webhook_details_free (&lookup_result);
+    TALER_MERCHANTDB_pending_webhook_details_free (&lookup_result);
     return 1;
   }
   const struct TALER_MERCHANTDB_PendingWebhookDetails *to_cmp = 
&pwebhook->pwebhook;
   if (0 != check_pending_webhooks_equal (&lookup_result,
                                          to_cmp))
-  {
+    {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Lookup pending webhook failed: incorrect pending webhook 
returned\n");
@@ -8027,7 +8030,7 @@ test_lookup_pending_webhooks (const struct InstanceData 
*instance,
     .results_length = 0
   };
   memset (results_matching, 0, sizeof (unsigned int) * pwebhooks_length);
-  if (0 > plugin->lookup_pending_webhook (plugin->cls,
+  if (0 > plugin->lookup_pending_webhooks (plugin->cls,
                                           &lookup_pending_webhooks_cb,
                                           &cls))
   {
@@ -8113,7 +8116,7 @@ test_lookup_all_webhooks (const struct InstanceData 
*instance,
                           unsigned int pwebhooks_length,
                           const struct PendingWebhookData *pwebhooks)
 {
-  uint32_t max_results=pwebhooks_length;
+  uint64_t max_results=2;
   uint64_t min_row=0;
   unsigned int results_matching[pwebhooks_length];
   struct TestLookupPendingWebhooks_Closure cls = {
@@ -8261,9 +8264,6 @@ run_test_pending_webhooks (struct 
TestPendingWebhooks_Closure *cls)
   TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance,
                                                  &cls->pwebhooks[1],
                                                  
GNUNET_DB_STATUS_SUCCESS_NO_RESULTS));
-  /* Test lookup of individual pending webhook */
-  TEST_RET_ON_FAIL (test_lookup_pending_webhook (&cls->instance,
-                                                 &cls->pwebhooks[0]));
 
   /* Test collective pending webhook lookup */
   TEST_RET_ON_FAIL (test_insert_pending_webhook (&cls->instance,
diff --git a/src/include/taler_merchantdb_lib.h 
b/src/include/taler_merchantdb_lib.h
index 09184661..1120b864 100644
--- a/src/include/taler_merchantdb_lib.h
+++ b/src/include/taler_merchantdb_lib.h
@@ -78,6 +78,15 @@ void
 TALER_MERCHANTDB_webhook_details_free (
   struct TALER_MERCHANTDB_WebhookDetails *wb);
 
+/**
+ * Free members of @a pwb, but not @a pwb itself.
+ *
+ * @param[in] pwb pending webhook details to clean up
+ */
+void
+TALER_MERCHANTDB_pending_webhook_details_free (
+  struct TALER_MERCHANTDB_PendingWebhookDetails *pwb);
+
 #endif  /* MERCHANT_DB_H */
 
 /* end of taler_merchantdb_lib.h */

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