summaryrefslogtreecommitdiff
path: root/src/backenddb/test_merchantdb.c
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-13 21:05:32 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-13 21:06:06 +0200
commitf432e22ff0e34ae0573cee58b783adbfbc54d1ec (patch)
tree95e88d564b94ad6c2ff5cbc8eeaf50e0cc70dd16 /src/backenddb/test_merchantdb.c
parentbd79ca83a26aec30d5b5e60ef573b56d5f8c8645 (diff)
downloadmerchant-f432e22ff0e34ae0573cee58b783adbfbc54d1ec.tar.gz
merchant-f432e22ff0e34ae0573cee58b783adbfbc54d1ec.tar.bz2
merchant-f432e22ff0e34ae0573cee58b783adbfbc54d1ec.zip
Add error when coins are not sufficient to pay a refund
back.
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r--src/backenddb/test_merchantdb.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index d1ddaa46..0c9b455e 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -136,6 +136,12 @@ static struct TALER_Amount little_refund_amount;
static struct TALER_Amount right_second_refund_amount;
/**
+ * Refund amount meant to raise an error because the
+ * contract's coins aren't enough to pay it back
+ */
+static struct TALER_Amount too_big_refund_amount;
+
+/**
* Public key of the coin. Set to some random value.
*/
static struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -394,7 +400,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 ":2",
+ TALER_string_to_amount (CURRENCY ":5",
&amount_with_fee));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010",
@@ -409,8 +415,11 @@ run (void *cls)
TALER_string_to_amount (CURRENCY ":1",
&little_refund_amount));
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":4",
+ TALER_string_to_amount (CURRENCY ":3",
&right_second_refund_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":30",
+ &too_big_refund_amount));
RND_BLK (&coin_pub);
deposit_proof = json_object ();
GNUNET_assert (0 ==
@@ -578,7 +587,15 @@ run (void *cls)
&h_contract_terms,
&merchant_pub,
&right_second_refund_amount,
- "make refund testing fail"));
+ "right refund increase"));
+
+ FAILIF (GNUNET_NO !=
+ 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"));
if (-1 == result)
result = 0;