[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] branch master updated: - only commit refun
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] branch master updated: - only commit refund if amount refunded per coin is > zero - add valid second refund increasing |
Date: |
Tue, 13 Jun 2017 20:51:30 +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 bd79ca8 - only commit refund if amount refunded per coin is > zero -
add valid second refund increasing
bd79ca8 is described below
commit bd79ca83a26aec30d5b5e60ef573b56d5f8c8645
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Jun 13 20:50:26 2017 +0200
- only commit refund if amount refunded per coin is > zero
- add valid second refund increasing
---
src/backenddb/plugin_merchantdb_postgres.c | 46 ++++++++++++++++++------------
src/backenddb/test_merchantdb.c | 19 +++++++++++-
2 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index 371cc4b..dee509c 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2002,22 +2002,24 @@ process_deposits_cb (void *cls,
/*Always commit the smallest as refund*/
- if (1 != insert_refund (ctx->pg,
- ctx->h_contract_terms,
- &coin_pub,
- ctx->reason,
- small))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not commit refund worth %s for coin '%s'"
- ", as of contract/reason: %s/%s\n",
- TALER_amount_to_string (small),
- TALER_B2S (&coin_pub),
- GNUNET_h2s (ctx->h_contract_terms),
- ctx->reason);
- ctx->err = GNUNET_SYSERR;
- return;
- }
+ if ( (0 != small->value) || (0 != small->fraction) )
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ insert_refund (ctx->pg,
+ ctx->h_contract_terms,
+ &coin_pub,
+ ctx->reason,
+ small))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not commit refund worth %s for coin '%s'"
+ ", as of contract/reason: %s/%s\n",
+ TALER_amount_to_string (small),
+ TALER_B2S (&coin_pub),
+ GNUNET_h2s (ctx->h_contract_terms),
+ ctx->reason);
+ ctx->err = GNUNET_SYSERR;
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Detracting %s as refund, from coin %s\n",
@@ -2029,15 +2031,21 @@ process_deposits_cb (void *cls,
if ( (0 == ctx->refund->value) &&
(0 == ctx->refund->fraction) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "All refund amount has been allocated\n");
break;
+ }
}
- if (-1 == TALER_amount_cmp (&attempted_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",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Attempted refund lesser than the previous"
+ "awarded one. %s vs %s\n",
TALER_amount_to_string (&attempted_refund),
TALER_amount_to_string (&previous_refund));
ctx->err = GNUNET_NO;
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index e07d804..d1ddaa4 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -128,6 +128,13 @@ static struct TALER_Amount refund_amount;
*/
static struct TALER_Amount little_refund_amount;
+
+/**
+ * Amount to be refunded in a call which is subsequent
+ * to the good one, expected to succeed.
+ */
+static struct TALER_Amount right_second_refund_amount;
+
/**
* Public key of the coin. Set to some random value.
*/
@@ -387,7 +394,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 ":10",
+ TALER_string_to_amount (CURRENCY ":2",
&amount_with_fee));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010",
@@ -401,6 +408,9 @@ run (void *cls)
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1",
&little_refund_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":4",
+ &right_second_refund_amount));
RND_BLK (&coin_pub);
deposit_proof = json_object ();
GNUNET_assert (0 ==
@@ -563,6 +573,13 @@ run (void *cls)
&merchant_pub,
&little_refund_amount,
"make refund testing fail"));
+ FAILIF (GNUNET_OK !=
+ plugin->increase_refund_for_contract (plugin->cls,
+ &h_contract_terms,
+ &merchant_pub,
+ &right_second_refund_amount,
+ "make refund testing fail"));
+
if (-1 == result)
result = 0;
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant] branch master updated: - only commit refund if amount refunded per coin is > zero - add valid second refund increasing,
gnunet <=