summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c6
-rw-r--r--src/backenddb/test_merchantdb.c29
2 files changed, 30 insertions, 5 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 11cd21d3..ed7a74e2 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -120,6 +120,7 @@ postgres_drop_tables (void *cls)
GNUNET_PQ_make_try_execute ("DROP TABLE merchant_transactions;"),
GNUNET_PQ_make_try_execute ("DROP TABLE merchant_proofs;"),
GNUNET_PQ_make_try_execute ("DROP TABLE merchant_contract_terms;"),
+ GNUNET_PQ_make_try_execute ("DROP TABLE merchant_refunds;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
@@ -1993,7 +1994,6 @@ process_deposits_cb (void *cls,
/*Always commit the smallest as refund*/
- /*Empirically, INSERT returns 1 result*/
if (1 != insert_refund (ctx->pg,
ctx->h_contract_terms,
&coin_pub,
@@ -2023,6 +2023,10 @@ process_deposits_cb (void *cls,
if (-1 == TALER_amount_cmp (ctx->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 (&previous_refund));
ctx->err = GNUNET_NO;
return;
}
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index efd2d145..fbc1678f 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -84,7 +84,7 @@ struct GNUNET_HashCode h_contract_terms;
/**
* Proposal's hash.
*/
-struct GNUNET_HashCode h_contract_terms2;
+struct GNUNET_HashCode h_contract_terms;
/**
* Time of the transaction.
@@ -122,6 +122,13 @@ static struct TALER_Amount refund_fee;
static struct TALER_Amount refund_amount;
/**
+ * Amount to be refunded. Used to trigger error about
+ * subsequest refund amount being lesser than the previous
+ * ones.
+ */
+static struct TALER_Amount little_refund_amount;
+
+/**
* Public key of the coin. Set to some random value.
*/
static struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -351,8 +358,11 @@ run (void *cls)
result = 77;
return;
}
+
if (GNUNET_OK != plugin->drop_tables (plugin->cls))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Dropping tables failed\n");
result = 77;
return;
}
@@ -386,8 +396,11 @@ run (void *cls)
TALER_string_to_amount (CURRENCY ":0.000010",
&refund_fee));
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1",
+ TALER_string_to_amount (CURRENCY ":2",
&refund_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":1",
+ &little_refund_amount));
RND_BLK (&coin_pub);
deposit_proof = json_object ();
GNUNET_assert (0 ==
@@ -403,7 +416,7 @@ run (void *cls)
contract_terms = json_object ();
TALER_JSON_hash (contract_terms,
- &h_contract_terms2);
+ &h_contract_terms);
FAILIF (GNUNET_OK !=
plugin->insert_contract_terms (plugin->cls,
@@ -430,7 +443,7 @@ run (void *cls)
FAILIF (GNUNET_OK !=
plugin->find_contract_terms_from_hash (plugin->cls,
&out,
- &h_contract_terms2,
+ &h_contract_terms,
&merchant_pub));
FAILIF (1 !=
plugin->find_contract_terms_by_date_and_range (plugin->cls,
@@ -542,6 +555,14 @@ run (void *cls)
&merchant_pub,
&refund_amount,
"refund testing"));
+
+ /*Should fail as this refund a lesser amount respect to the previous one*/
+ FAILIF (GNUNET_NO !=
+ plugin->increase_refund_for_contract (plugin->cls,
+ &h_contract_terms,
+ &merchant_pub,
+ &little_refund_amount,
+ "refund testing"));
if (-1 == result)
result = 0;