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: fix detection of su


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: fix detection of subsequent refunds lesser thatn previous ones.
Date: Tue, 13 Jun 2017 16:00:06 +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 d9180c8  fix detection of subsequent refunds lesser thatn previous 
ones.
d9180c8 is described below

commit d9180c81a9c76dc5fc608d82bde908531548d5dc
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Jun 13 15:59:53 2017 +0200

    fix detection of subsequent refunds lesser thatn previous ones.
---
 src/backenddb/plugin_merchantdb_postgres.c | 13 ++++++++++---
 src/backenddb/test_merchantdb.c            |  4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index ed7a74e..6c26e5d 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1864,6 +1864,7 @@ process_deposits_cb (void *cls,
   struct InsertRefundContext *ctx = cls;
   struct TALER_Amount previous_refund;
   struct TALER_Amount diff;
+  struct TALER_Amount attempted_refund = *ctx->refund;
   struct TALER_Amount *big;
   struct TALER_Amount *small;
 
@@ -1908,9 +1909,14 @@ process_deposits_cb (void *cls,
                                                  &ictx);
     if ( (GNUNET_OK != ictx.err) ||
          (GNUNET_DB_STATUS_HARD_ERROR == ires) )
+    {
+      ctx->err = GNUNET_SYSERR;
       goto rollback;
+    }
     if (GNUNET_DB_STATUS_SOFT_ERROR == ires)
+    { ctx->err = GNUNET_SYSERR;
       goto rollback; // FIXME: #5010: actually rollback + retry!
+    }
 
     /*How much coin i will give for refund: needed by merchant_refunds table*/
     if (GNUNET_SYSERR == TALER_amount_subtract (&diff, // to commit as refund
@@ -1923,6 +1929,7 @@ process_deposits_cb (void *cls,
                   TALER_B2S (&coin_pub),
                   TALER_amount_to_string (&amount_with_fee),
                   TALER_amount_to_string (&ictx.refunded_amount));
+      ctx->err = GNUNET_SYSERR;
       goto rollback;
     }
 
@@ -1941,6 +1948,7 @@ process_deposits_cb (void *cls,
                   TALER_B2S (&coin_pub),
                   TALER_amount_to_string (&previous_refund),
                   TALER_amount_to_string (&ictx.refunded_amount));
+      ctx->err = GNUNET_SYSERR;
       goto rollback;
     }
 
@@ -2020,12 +2028,12 @@ process_deposits_cb (void *cls,
 
   }
 
-  if (-1 == TALER_amount_cmp (ctx->refund, &previous_refund))
+  if (-1 == TALER_amount_cmp (&attempted_refund, &previous_refund))
   {
 
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Attempted refund lesser than the previous awarded one. %s vs 
%s\n",
-                TALER_amount_to_string (ctx->refund),
+                TALER_amount_to_string (&attempted_refund),
                 TALER_amount_to_string (&previous_refund));
     ctx->err = GNUNET_NO;
     return;  
@@ -2041,7 +2049,6 @@ process_deposits_cb (void *cls,
   return;
 
   rollback:
-    ctx->err = GNUNET_SYSERR;
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Failed transaction, doing rollback\n");
     PQclear (result);
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index fbc1678..e07d804 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -387,7 +387,7 @@ run (void *cls)
   refund_deadline = GNUNET_TIME_absolute_get();
   GNUNET_TIME_round_abs (&refund_deadline);
   GNUNET_assert (GNUNET_OK ==
-                 TALER_string_to_amount (CURRENCY ":1.000010",
+                 TALER_string_to_amount (CURRENCY ":10",
                                          &amount_with_fee));
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount (CURRENCY ":0.000010",
@@ -562,7 +562,7 @@ run (void *cls)
                                                 &h_contract_terms,
                                                 &merchant_pub,
                                                 &little_refund_amount,
-                                                "refund testing"));
+                                                "make refund testing fail"));
   if (-1 == result)
     result = 0;
 

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



reply via email to

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