gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 02/05: misc bugfixes in taler-merchant-exchange


From: gnunet
Subject: [taler-merchant] 02/05: misc bugfixes in taler-merchant-exchange
Date: Thu, 04 May 2023 10:50:37 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit 5f4f6262b4e3b1a1b6a88d5dd12c588084e703ad
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu May 4 00:01:23 2023 +0200

    misc bugfixes in taler-merchant-exchange
---
 src/backend/taler-merchant-exchange.c            | 51 +++++++++++++++++++++++-
 src/backenddb/pg_select_open_transfers.c         | 10 +++--
 src/testing/test_merchant_api.c                  |  2 +
 src/testing/test_merchant_api.conf               |  2 +-
 src/testing/testing_api_cmd_merchant_get_order.c |  6 ++-
 5 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-exchange.c 
b/src/backend/taler-merchant-exchange.c
index ff480ca9..74e9dce0 100644
--- a/src/backend/taler-merchant-exchange.c
+++ b/src/backend/taler-merchant-exchange.c
@@ -166,7 +166,7 @@ struct Inquiry
   /**
    * When did the transfer happen?
    */
-  struct GNUNET_TIME_Absolute execution_time;
+  struct GNUNET_TIME_Timestamp execution_time;
 
   /**
    * Argument for the /wire/transfers request.
@@ -477,6 +477,16 @@ end_inquiry (struct Inquiry *w)
     task = GNUNET_SCHEDULER_add_now (&find_work,
                                      NULL);
   }
+  if ( (NULL == task) &&
+       (! at_limit) &&
+       (0 == active_inquiries) &&
+       (test_mode) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "No more open inquiries and in test mode. Existing.\n");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
 }
 
 
@@ -503,6 +513,11 @@ shutdown_task (void *cls)
     }
     GNUNET_free (e->exchange_url);
     TALER_EXCHANGE_disconnect (e->conn);
+    if (NULL != e->retry_task)
+    {
+      GNUNET_SCHEDULER_cancel (e->retry_task);
+      e->retry_task = NULL;
+    }
     GNUNET_CONTAINER_DLL_remove (e_head,
                                  e_tail,
                                  e);
@@ -724,6 +739,7 @@ wire_transfer_cb (void *cls,
   {
   case MHD_HTTP_OK:
     td = &tgr->details.ok.td;
+    w->execution_time = td->execution_time;
     e->transfer_delay = GNUNET_TIME_UNIT_ZERO;
     break;
   case MHD_HTTP_BAD_REQUEST:
@@ -733,6 +749,7 @@ wire_transfer_cb (void *cls,
                                
TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_HARD_FAILURE,
                                true,
                                false);
+    end_inquiry (w);
     return;
   case MHD_HTTP_NOT_FOUND:
     update_transaction_status (w,
@@ -740,6 +757,7 @@ wire_transfer_cb (void *cls,
                                
TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_FATAL_NOT_FOUND,
                                true,
                                false);
+    end_inquiry (w);
     return;
   case MHD_HTTP_INTERNAL_SERVER_ERROR:
   case MHD_HTTP_BAD_GATEWAY:
@@ -751,6 +769,7 @@ wire_transfer_cb (void *cls,
                                
TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE,
                                false,
                                false);
+    end_inquiry (w);
     return;
   default:
     e->transfer_delay = GNUNET_TIME_STD_BACKOFF (e->transfer_delay);
@@ -763,6 +782,7 @@ wire_transfer_cb (void *cls,
                                
TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE,
                                false,
                                false);
+    end_inquiry (w);
     return;
   }
   db_plugin->preflight (db_plugin->cls);
@@ -847,7 +867,7 @@ wire_transfer_cb (void *cls,
         /* #check_transfer() failed, report conflict! */
         GNUNET_break_op (0);
         GNUNET_assert (TALER_EC_NONE != ctc.ec);
-        return;
+        break;
       case GNUNET_OK:
         break;
       }
@@ -863,6 +883,7 @@ wire_transfer_cb (void *cls,
         ctc.ec,
         ctc.failure,
         false);
+      end_inquiry (w);
       return;
     }
   }
@@ -878,6 +899,7 @@ wire_transfer_cb (void *cls,
                                
TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE,
                                true,
                                false);
+    end_inquiry (w);
     return;
   }
 
@@ -891,6 +913,7 @@ wire_transfer_cb (void *cls,
                                
TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_CONFLICTING_TRANSFERS,
                                true,
                                false);
+    end_inquiry (w);
     return;
   }
   /* set transaction to successful */
@@ -899,6 +922,7 @@ wire_transfer_cb (void *cls,
                              TALER_EC_NONE,
                              false,
                              true);
+  end_inquiry (w);
 }
 
 
@@ -913,6 +937,7 @@ exchange_request (void *cls)
   struct Inquiry *w = cls;
   struct Exchange *e = w->exchange;
 
+  w->task = NULL;
   GNUNET_assert (e->ready);
   w->wdh = TALER_EXCHANGE_transfers_get (e->conn,
                                          &w->wtid,
@@ -929,6 +954,7 @@ exchange_request (void *cls)
                                
TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE,
                                false,
                                false);
+    end_inquiry (w);
     return;
   }
   /* Wait at least 1m for the network transfer */
@@ -969,7 +995,27 @@ start_inquiry (
   struct Inquiry *w;
 
   (void) cls;
+  if (GNUNET_TIME_absolute_is_future (next_attempt))
+  {
+    if (NULL == task)
+      task = GNUNET_SCHEDULER_add_at (next_attempt,
+                                      &find_work,
+                                      NULL);
+    return;
+  }
   e = find_exchange (exchange_url);
+  for (w = e->w_head; NULL != w; w = w->next)
+  {
+    if (0 == GNUNET_memcmp (&w->wtid,
+                            wtid))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Already processing inquiry. Aborting ongoing inquiry\n");
+      end_inquiry (w);
+      break;
+    }
+  }
+
   active_inquiries++;
   w = GNUNET_new (struct Inquiry);
   w->payto_uri = GNUNET_strdup (payto_uri);
@@ -1011,6 +1057,7 @@ find_work (void *cls)
     at_limit = true;
     return;
   }
+  at_limit = false;
   qs = db_plugin->select_open_transfers (db_plugin->cls,
                                          limit,
                                          &start_inquiry,
diff --git a/src/backenddb/pg_select_open_transfers.c 
b/src/backenddb/pg_select_open_transfers.c
index 7113c446..5b2407e3 100644
--- a/src/backenddb/pg_select_open_transfers.c
+++ b/src/backenddb/pg_select_open_transfers.c
@@ -140,19 +140,21 @@ TMH_PG_select_open_transfers (void *cls,
            "select_open_transfers",
            "SELECT"
            " credit_serial"
+           ",merchant_id AS instance_id"
            ",exchange_url"
+           ",payto_uri"
            ",wtid"
            ",credit_amount_val"
            ",credit_amount_frac"
-           ",payto_uri"
+           ",ready_time AS next_attempt"
            " FROM merchant_transfers"
-           " JOIN merchant_instances"
-           "   USING (merchant_id)"
            " JOIN merchant_accounts"
            "   USING (account_serial)"
+           " JOIN merchant_instances"
+           "   USING (merchant_serial)"
            " WHERE confirmed AND"
            "       NOT (failed OR verified)"
-           " ORDER BY next_attempt INC"
+           " ORDER BY ready_time ASC"
            " LIMIT $1;");
 
   qs = GNUNET_PQ_eval_prepared_multi_select (
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 89bce513..391164c2 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -497,6 +497,7 @@ run (void *cls,
                                               NULL),
     TALER_TESTING_cmd_run_tme ("run taler-merchant-exchange-1",
                                config_file),
+#if 0
     TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad",
                                                merchant_url,
                                                PAYTO_I1,
@@ -518,6 +519,7 @@ run (void *cls,
                                                 merchant_url,
                                                 "post-transfer-bad",
                                                 MHD_HTTP_NO_CONTENT),
+#endif
     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2",
                                            merchant_url,
                                            "create-proposal-1",
diff --git a/src/testing/test_merchant_api.conf 
b/src/testing/test_merchant_api.conf
index f270d670..c0da1267 100644
--- a/src/testing/test_merchant_api.conf
+++ b/src/testing/test_merchant_api.conf
@@ -22,7 +22,7 @@ AML_THRESHOLD = EUR:1000000
 
 [taler-helper-crypto-rsa]
 # Reduce from 1 year to speed up test
-LOOKAHEAD_SIGN = 24 days
+LOOKAHEAD_SIGN = 10 days
 
 [taler-helper-crypto-eddsa]
 # Reduce from 1 year to speed up test
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c 
b/src/testing/testing_api_cmd_merchant_get_order.c
index 467b6d61..ce472a61 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -333,7 +333,11 @@ merchant_get_order_cb (
                                       transfer_fee))
             {
               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                          "Could not total wire transfer\n");
+                          "Could not compute total wire transfer amount: %s\n",
+                          TALER_amount2s (transfer_amount));
+              GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                          "Could not compute total wire transfer amount: %s\n",
+                          TALER_amount2s (transfer_fee));
               TALER_TESTING_interpreter_fail (gos->is);
               return;
             }

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