gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated: refund fee columnt


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: refund fee columnt into refund table, breaks db tests
Date: Tue, 20 Jun 2017 16:44:14 +0200

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

marcello pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new b80c3d7  refund fee columnt into refund table, breaks db tests
b80c3d7 is described below

commit b80c3d79e4a1638f5189b7fe549b814f2ea0b5f4
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Jun 20 16:44:09 2017 +0200

    refund fee columnt into refund table, breaks db tests
---
 src/backenddb/plugin_merchantdb_postgres.c | 16 +++++++++++--
 src/lib/merchant_api_refund.c              | 21 +++++++++++++++++
 src/lib/test_merchant_api.c                | 37 +++++++++++++++++++++++++++---
 3 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index dd45163..06fc40c 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -245,6 +245,9 @@ postgres_initialize (void *cls)
                             ",refund_amount_val INT8 NOT NULL"
                             ",refund_amount_frac INT4 NOT NULL"
                             ",refund_amount_curr VARCHAR(" 
TALER_CURRENCY_LEN_STR ") NOT NULL"
+                            ",refund_fee_val INT8 NOT NULL"
+                            ",refund_fee_frac INT4 NOT NULL"
+                            ",refund_fee_curr VARCHAR(" TALER_CURRENCY_LEN_STR 
") NOT NULL"
                             ");"),
     GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_transactions 
("
                             " h_contract_terms BYTEA NOT NULL"
@@ -1707,6 +1710,9 @@ postgres_get_refunds_from_contract_terms_hash (void *cls,
                                     &rtransaction_id),
       TALER_PQ_result_spec_amount ("refund_amount",
                                    &refund_amount),
+      /**
+       * BUGGY: this column is not in that table.
+       */
       TALER_PQ_result_spec_amount ("refund_fee",
                                    &refund_fee),
       GNUNET_PQ_result_spec_string ("reason",
@@ -1839,6 +1845,7 @@ struct InsertRefundContext
  * @param coin_pub public key of the coin giving the (part of) refund
  * @param reason human readable explaination behind the refund
  * @param refund how much this coin is refunding
+ * @param refund_fee refund fee for this coin
  */
 enum GNUNET_DB_QueryStatus
 insert_refund (void *cls,
@@ -1846,7 +1853,8 @@ insert_refund (void *cls,
                const struct GNUNET_HashCode *h_contract_terms,
                const struct TALER_CoinSpendPublicKeyP *coin_pub,
                const char *reason,
-               const struct TALER_Amount *refund)
+               const struct TALER_Amount *refund,
+               const struct TALER_Amount *refund_fee)
 {
   struct PostgresClosure *pg = cls;
   
@@ -1891,6 +1899,7 @@ process_deposits_cb (void *cls,
   {
     struct TALER_CoinSpendPublicKeyP coin_pub;
     struct TALER_Amount amount_with_fee;
+    struct TALER_Amount refund_fee;
     struct FindRefundContext ictx;
     enum GNUNET_DB_QueryStatus ires;
     struct GNUNET_PQ_QueryParam params[] = {
@@ -1902,6 +1911,8 @@ process_deposits_cb (void *cls,
                                             &coin_pub),
       TALER_PQ_result_spec_amount ("amount_with_fee",
                                    &amount_with_fee),
+      TALER_PQ_result_spec_amount ("refund_fee",
+                                   &refund_fee),
       GNUNET_PQ_result_spec_end
     };
 
@@ -2025,7 +2036,8 @@ process_deposits_cb (void *cls,
                            ctx->h_contract_terms,
                            &coin_pub,
                            ctx->reason,
-                           small))
+                           small,
+                           &refund_fee))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                       "Could not commit refund worth %s for coin '%s'"
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
index 692cab7..7c88f5b 100644
--- a/src/lib/merchant_api_refund.c
+++ b/src/lib/merchant_api_refund.c
@@ -234,6 +234,26 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context 
*ctx,
   return rio;
 }
 
+
+/**
+ * Cancel a /refund lookup operation
+ *
+ * @param 
+ */
+void
+TALER_MERCHANT_refund_lookup_cancel (struct 
TALER_MERCHANT_RefundLookupOperation *rlo)
+{
+  if (NULL != rlo->job)
+  {
+    GNUNET_CURL_job_cancel (rlo->job);
+    rlo->job = NULL;
+  }
+  
+  GNUNET_free (rlo->url);
+  GNUNET_free (rlo);
+}
+
+
 /**
  * Process GET /refund response
  */
@@ -260,6 +280,7 @@ handle_refund_lookup_finished (void *cls,
              MHD_HTTP_OK,
              TALER_EC_NONE,
              json);
+    TALER_MERCHANT_refund_lookup_cancel (rlo);
     break;
   default:
     /**
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 99f278a..10e8456 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1176,6 +1176,7 @@ refund_lookup_cb (void *cls,
                   const json_t *obj)
 {
   struct InterpreterState *is = cls;
+  struct Command *cmd = &is->commands[is->ip];
 
   if (MHD_HTTP_OK != http_status)
   {
@@ -1184,6 +1185,10 @@ refund_lookup_cb (void *cls,
     fail (is);
     return;
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Ok /refund lookup\n");
+  cmd->details.refund_lookup.rlo = NULL;
+  next_command (is);
 }
 
 
@@ -1591,13 +1596,17 @@ cleanup_state (struct InterpreterState *is)
     case OC_REFUND_INCREASE:
       if (NULL != cmd->details.refund_increase.rio)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "Cleaning up /refund (increase)\n");
         TALER_MERCHANT_refund_increase_cancel 
(cmd->details.refund_increase.rio);
         cmd->details.refund_increase.rio = NULL;
       }
       break;
 
+    case OC_REFUND_LOOKUP:
+      if (NULL != cmd->details.refund_lookup.rlo)
+      {
+        TALER_MERCHANT_refund_lookup_cancel (cmd->details.refund_lookup.rlo); 
+        cmd->details.refund_lookup.rlo = NULL;
+      }
     default:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   "Shutdown: unknown instruction %d at %u (%s)\n",
@@ -2162,6 +2171,24 @@ interpreter_run (void *cls)
     }
     break;
   }
+  case OC_REFUND_LOOKUP:
+  {
+    if (NULL ==
+        (cmd->details.refund_lookup.rlo =
+           TALER_MERCHANT_refund_lookup (ctx,
+                                         MERCHANT_URI,
+                                         cmd->details.refund_lookup.order_id,
+                                         instance,
+                                         refund_lookup_cb,
+                                         is)))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Could not issue a /refund lookup request\n");
+      fail (is);
+      return;
+    }
+    break;
+  }
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unknown instruction %d at %u (%s)\n",
@@ -2528,11 +2555,15 @@ run (void *cls)
       .details.history.nrows = 10
     },
     { .oc = OC_REFUND_INCREASE,
-      .label = "increase-1",
+      .label = "refund-increase-1",
       .details.refund_increase.refund_amount = "EUR:0.1",
       .details.refund_increase.reason = "refund test",
       .details.refund_increase.order_id = "1"    
     },
+    { .oc = OC_REFUND_LOOKUP,
+      .label = "refund-lookup-1",
+      .details.refund_lookup.order_id = "1"
+    },
     /* end of testcase */
     { .oc = OC_END }
   };

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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