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 refund test and


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: fix refund test and logic: if refund is smaller than refund that was previously awarded, that's not a hard error but simply 'no change required'
Date: Thu, 31 Aug 2017 14:17:16 +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 7d50fee  fix refund test and logic: if refund is smaller than refund 
that was previously awarded, that's not a hard error but simply 'no change 
required'
7d50fee is described below

commit 7d50fee1384e44b007e8c00dd610eef2cedf1866
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Aug 31 14:17:18 2017 +0200

    fix refund test and logic: if refund is smaller than refund that was 
previously awarded, that's not a hard error but simply 'no change required'
---
 src/backenddb/plugin_merchantdb_postgres.c | 12 +++++++++---
 src/backenddb/test_merchantdb.c            | 12 ++++++------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 76d4efe..cb47519 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2200,14 +2200,16 @@ process_deposits_for_refund_cb (void *cls,
               TALER_amount2s (&current_refund));
 
   /* stop immediately if we are done */
-  if (0 == TALER_amount_cmp (ctx->refund,
+  if (0 >= TALER_amount_cmp (ctx->refund,
                              &current_refund))
+  {
+    ctx->qs = GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
     return;
-
+  }
 
   /* Phase 2:  Try to increase current refund until it matches desired refund 
*/
 
-  for (unsigned int i=0; i<num_results; i++)
+  for (unsigned int i=0;i<num_results; i++)
   {
     const struct TALER_Amount *increment;
     struct TALER_Amount left;
@@ -2345,6 +2347,10 @@ postgres_increase_refund_for_contract (void *cls,
     GNUNET_PQ_query_param_end
   };
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Asked to refund %s on contract %s\n",
+              TALER_amount2s (refund),
+              GNUNET_h2s (h_contract_terms));
   if (GNUNET_OK !=
       postgres_start (cls))
   {
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 212359d..683ebdd 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -592,7 +592,7 @@ run (void *cls)
                  json_object_set_new (contract_terms,
                                       "order",
                                       json_string ("1")));
-  
+
   contract_terms_future = json_object ();
   GNUNET_assert (0 ==
                  json_object_set_new (contract_terms_future,
@@ -759,7 +759,7 @@ run (void *cls)
                                                 &merchant_pub,
                                                 &refund_amount,
                                                 "same refund amount as "
-                                                "the previous one, should 
fail"));
+                                                "the previous one, should 
succeed without changes (0)"));
 
   /*Should fail as this refund a lesser amount respect to the previous one*/
   FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
@@ -767,7 +767,7 @@ run (void *cls)
                                                 &h_contract_terms,
                                                 &merchant_pub,
                                                 &little_refund_amount,
-                                                "make refund testing fail"));
+                                                "lower refund amount as the 
previous one, should succeed without changes (0)"));
   FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->increase_refund_for_contract (plugin->cls,
                                                 &h_contract_terms,
@@ -775,17 +775,17 @@ run (void *cls)
                                                 &right_second_refund_amount,
                                                 "right refund increase"));
 
-  FAILIF (GNUNET_DB_STATUS_HARD_ERROR != 
+  FAILIF (GNUNET_DB_STATUS_HARD_ERROR !=
           plugin->increase_refund_for_contract (plugin->cls,
                                                 &h_contract_terms,
                                                 &merchant_pub,
                                                 &too_big_refund_amount,
                                                 "make refund testing fail due"
                                                 " to too big refund amount"));
-  
+
   FAILIF (GNUNET_OK !=
          test_wire_fee ());
-  
+
   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]