gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: -misc bugfixes


From: gnunet
Subject: [taler-merchant] branch master updated: -misc bugfixes
Date: Mon, 11 Jul 2022 17:49:29 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 9556d832 -misc bugfixes
9556d832 is described below

commit 9556d8323344461999151069fc6b71b308b483bc
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jul 11 17:49:27 2022 +0200

    -misc bugfixes
---
 .../taler-merchant-httpd_post-orders-ID-claim.c    |  5 +-
 ...ler-merchant-httpd_private-patch-instances-ID.c | 17 ++---
 .../taler-merchant-httpd_private-post-orders.c     | 81 ++++++++++++----------
 src/backenddb/plugin_merchantdb_postgres.c         | 22 ++++--
 src/backenddb/test_merchantdb.c                    |  5 +-
 src/include/taler_merchantdb_plugin.h              |  4 +-
 src/lib/merchant_api_post_order_claim.c            |  4 ++
 src/testing/testing_api_cmd_post_orders.c          |  6 ++
 8 files changed, 87 insertions(+), 57 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
index c806390a..91a16814 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
@@ -172,8 +172,9 @@ claim_order (const char *instance_id,
     qs = TMH_db->insert_contract_terms (TMH_db->cls,
                                         instance_id,
                                         order_id,
-                                        *contract_terms);
-    if (0 > qs)
+                                        *contract_terms,
+                                        &order_serial);
+    if (0 >= qs)
     {
       TMH_db->rollback (TMH_db->cls);
       json_decref (*contract_terms);
diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c
index 24f7c097..188a3ee6 100644
--- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c
@@ -71,17 +71,17 @@ patch_instances_ID (struct TMH_MerchantInstance *mi,
                            &payto_uris),
     GNUNET_JSON_spec_string ("name",
                              &name),
-    GNUNET_JSON_spec_mark_optional(
+    GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_string ("website",
                                (const char **) &is.website),
       NULL),
-    GNUNET_JSON_spec_mark_optional(
+    GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_string ("email",
-                                (const char **) &is.email),
+                               (const char **) &is.email),
       NULL),
-    GNUNET_JSON_spec_mark_optional(
+    GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_string ("logo",
-                                (const char **) &is.logo),
+                               (const char **) &is.logo),
       NULL),
     GNUNET_JSON_spec_json ("address",
                            &is.address),
@@ -184,15 +184,15 @@ patch_instances_ID (struct TMH_MerchantInstance *mi,
             ((mi->settings.email == is.email) ||
              (NULL != is.email && NULL != mi->settings.email &&
               0 == strcmp (mi->settings.email,
-                            is.email))) &&
+                           is.email))) &&
             ((mi->settings.website == is.website) ||
              (NULL != is.website && NULL != mi->settings.website &&
               0 == strcmp (mi->settings.website,
-                            is.website))) &&
+                           is.website))) &&
             ((mi->settings.logo == is.logo) ||
              (NULL != is.logo && NULL != mi->settings.logo &&
               0 == strcmp (mi->settings.logo,
-                            is.logo))) &&
+                           is.logo))) &&
             (1 == json_equal (mi->settings.address,
                               is.address)) &&
             (1 == json_equal (mi->settings.jurisdiction,
@@ -322,6 +322,7 @@ patch_instances_ID (struct TMH_MerchantInstance *mi,
                                      wm_tail,
                                      wm);
         ad.h_wire = wm->h_wire;
+        ad.salt = wm->wire_salt;
         ad.active = true;
         qs = TMH_db->insert_account (TMH_db->cls,
                                      mi->settings.id,
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 10a8d503..5444222b 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1060,51 +1060,56 @@ patch_order (struct MHD_Connection *connection,
       TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_PROPOSAL_PARSE_ERROR,
       "'merchant' field already set, but must be provided by backend");
   }
-  jmerchant = GNUNET_JSON_PACK (
-    GNUNET_JSON_pack_string ("name",
-                             settings->name),
-    GNUNET_JSON_pack_allow_null (
-      GNUNET_JSON_pack_string ("website",
-                               settings->website)),
-    GNUNET_JSON_pack_allow_null (
-      GNUNET_JSON_pack_string ("email",
-                               settings->email)),
-    GNUNET_JSON_pack_allow_null (
-      GNUNET_JSON_pack_string ("logo",
-                               settings->logo)));
-  GNUNET_assert (NULL != jmerchant);
+
   {
-    json_t *loca;
+    json_t *jm;
 
-    /* Handle merchant address */
-    loca = settings->address;
-    if (NULL != loca)
+    jm = GNUNET_JSON_PACK (
+      GNUNET_JSON_pack_string ("name",
+                               settings->name),
+      GNUNET_JSON_pack_allow_null (
+        GNUNET_JSON_pack_string ("website",
+                                 settings->website)),
+      GNUNET_JSON_pack_allow_null (
+        GNUNET_JSON_pack_string ("email",
+                                 settings->email)),
+      GNUNET_JSON_pack_allow_null (
+        GNUNET_JSON_pack_string ("logo",
+                                 settings->logo)));
+    GNUNET_assert (NULL != jm);
     {
-      loca = json_deep_copy (loca);
-      GNUNET_assert (0 ==
-                     json_object_set_new (jmerchant,
-                                          "address",
-                                          loca));
-    }
-  }
-  {
-    json_t *locj;
+      json_t *loca;
 
-    /* Handle merchant jurisdiction */
-    locj = settings->jurisdiction;
-    if (NULL != locj)
+      /* Handle merchant address */
+      loca = settings->address;
+      if (NULL != loca)
+      {
+        loca = json_deep_copy (loca);
+        GNUNET_assert (0 ==
+                       json_object_set_new (jm,
+                                            "address",
+                                            loca));
+      }
+    }
     {
-      locj = json_deep_copy (locj);
-      GNUNET_assert (0 ==
-                     json_object_set_new (jmerchant,
-                                          "jurisdiction",
-                                          locj));
+      json_t *locj;
+
+      /* Handle merchant jurisdiction */
+      locj = settings->jurisdiction;
+      if (NULL != locj)
+      {
+        locj = json_deep_copy (locj);
+        GNUNET_assert (0 ==
+                       json_object_set_new (jm,
+                                            "jurisdiction",
+                                            locj));
+      }
     }
+    GNUNET_assert (0 ==
+                   json_object_set_new (order,
+                                        "merchant",
+                                        jm));
   }
-  GNUNET_assert (0 ==
-                 json_object_set_new (order,
-                                      "merchant",
-                                      jmerchant));
 
   /* add fields to the contract that the backend should provide */
   GNUNET_assert (0 ==
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index d7e35897..830a3182 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -824,13 +824,12 @@ postgres_insert_account (
   const struct TALER_MERCHANTDB_AccountDetails *account_details)
 {
   struct PostgresClosure *pg = cls;
-  uint8_t active = account_details->active;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_string (id),
     GNUNET_PQ_query_param_auto_from_type (&account_details->h_wire),
     GNUNET_PQ_query_param_auto_from_type (&account_details->salt),
     GNUNET_PQ_query_param_string (account_details->payto_uri),
-    GNUNET_PQ_query_param_auto_from_type (&active),
+    GNUNET_PQ_query_param_bool (account_details->active),
     GNUNET_PQ_query_param_end
   };
 
@@ -2088,6 +2087,7 @@ postgres_lookup_contract_terms (void *cls,
  * @param instance_id instance's identifier
  * @param order_id order_id used to store
  * @param contract_terms contract terms to store
+ * @param[out] order_serial set to the serial of the order
  * @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a 
contract_terms
  *          is malformed
  */
@@ -2095,7 +2095,8 @@ static enum GNUNET_DB_QueryStatus
 postgres_insert_contract_terms (void *cls,
                                 const char *instance_id,
                                 const char *order_id,
-                                json_t *contract_terms)
+                                json_t *contract_terms,
+                                uint64_t *order_serial)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_TIME_Timestamp pay_deadline;
@@ -2148,10 +2149,16 @@ postgres_insert_contract_terms (void *cls,
       : GNUNET_PQ_query_param_string (fulfillment_url),
       GNUNET_PQ_query_param_end
     };
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint64 ("order_serial",
+                                    order_serial),
+      GNUNET_PQ_result_spec_end
+    };
 
-    return GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                               "insert_contract_terms",
-                                               params);
+    return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                     "insert_contract_terms",
+                                                     params,
+                                                     rs);
   }
 }
 
@@ -8105,7 +8112,8 @@ postgres_connect (void *cls)
                             "   AND merchant_serial="
                             "     (SELECT merchant_serial"
                             "        FROM merchant_instances"
-                            "        WHERE merchant_id=$1)",
+                            "        WHERE merchant_id=$1)"
+                            " RETURNING order_serial",
                             7),
     /* for postgres_update_contract_terms() */
     GNUNET_PQ_make_prepare ("update_contract_terms",
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index de27af31..e5eb8890 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -1643,11 +1643,14 @@ test_insert_contract_terms (const struct InstanceData 
*instance,
                             const struct OrderData *order,
                             enum GNUNET_DB_QueryStatus expected_result)
 {
+  uint64_t os;
+
   TEST_COND_RET_ON_FAIL (expected_result ==
                          plugin->insert_contract_terms (plugin->cls,
                                                         instance->instance.id,
                                                         order->id,
-                                                        order->contract),
+                                                        order->contract,
+                                                        &os),
                          "Insert contract terms failed\n");
   return 0;
 }
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 79d679e9..3a329096 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -1382,6 +1382,7 @@ struct TALER_MERCHANTDB_Plugin
    * @param instance_id instance's identifier
    * @param order_id order_id used to store
    * @param claim_token the token belonging to the order
+   * @param[out] order_serial set to the serial of the order
    * @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a 
contract_terms
    *          is malformed
    */
@@ -1389,7 +1390,8 @@ struct TALER_MERCHANTDB_Plugin
   (*insert_contract_terms)(void *cls,
                            const char *instance_id,
                            const char *order_id,
-                           json_t *contract_terms);
+                           json_t *contract_terms,
+                           uint64_t *order_serial);
 
 
   /**
diff --git a/src/lib/merchant_api_post_order_claim.c 
b/src/lib/merchant_api_post_order_claim.c
index 0a70c1b0..66e58c2a 100644
--- a/src/lib/merchant_api_post_order_claim.c
+++ b/src/lib/merchant_api_post_order_claim.c
@@ -103,6 +103,10 @@ handle_post_order_claim_finished (void *cls,
   };
 
   och->job = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "Order claimed with status %u\n",
+              (unsigned int) response_code);
+
   if (MHD_HTTP_OK != response_code)
   {
     hr.ec = TALER_JSON_get_error_code (json);
diff --git a/src/testing/testing_api_cmd_post_orders.c 
b/src/testing/testing_api_cmd_post_orders.c
index b3f15fc8..b818bd8c 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -205,7 +205,13 @@ orders_claim_cb (void *cls,
 
   ps->och = NULL;
   if (ps->http_status != hr->http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Expected status %u, got %u\n",
+                ps->http_status,
+                hr->http_status);
     TALER_TESTING_FAIL (ps->is);
+  }
 
   ps->contract_terms = json_deep_copy (contract_terms);
   ps->h_contract_terms = *hash;

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