[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: test for increasing refunds mult
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: test for increasing refunds multiple times |
Date: |
Thu, 13 Aug 2020 09:50:28 +0200 |
This is an automated email from the git hooks/post-receive script.
jonathan-buchanan pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 452f20d test for increasing refunds multiple times
452f20d is described below
commit 452f20d71ef5c659c269389a4156f462521737ed
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Thu Aug 13 03:50:15 2020 -0400
test for increasing refunds multiple times
---
src/testing/test_merchant_api.c | 22 +++++++-
src/testing/testing_api_cmd_merchant_get_order.c | 12 +++-
src/testing/testing_api_cmd_wallet_get_order.c | 71 ++++++++++++++----------
3 files changed, 71 insertions(+), 34 deletions(-)
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index ead0ba7..0e99fb4 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -618,6 +618,7 @@ run (void *cls,
const char *order_1r_refunds[] = {
"refund-increase-1r",
+ "refund-increase-1r-2",
NULL
};
struct TALER_TESTING_Command refund[] = {
@@ -683,6 +684,21 @@ run (void *cls,
MHD_HTTP_OK,
"refund-increase-1r",
NULL),
+ TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r-2",
+ merchant_url,
+ "refund test 2",
+ "1r", /* order ID */
+ "EUR:1.0",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-2",
+ merchant_url,
+ "create-proposal-1r",
+ true,
+ true,
+ MHD_HTTP_OK,
+ "refund-increase-1r",
+ "refund-increase-1r-2",
+ NULL),
TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1r",
merchant_url,
"create-proposal-1r",
@@ -690,6 +706,7 @@ run (void *cls,
true,
MHD_HTTP_OK,
"refund-increase-1r",
+ "refund-increase-1r-2",
NULL),
TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1r-2",
merchant_url,
@@ -785,8 +802,9 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-paid-unincreased-refund",
EXCHANGE_URL,
- "EUR:9.88", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r'
- and MINUS 0.1 PLUS 0.01 (deposit fee) from
'refund-increase-1r' */
+ "EUR:8.98", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r'
+ and MINUS 0.1 MINUS 0.9 PLUS 0.01 (deposit fee) from
+ 'refund-increase-1r' and 'refund-increase-1r-2' */
exchange_payto,
merchant_payto),
/* Actually try to pick up the refund from the "unincreased proposal". */
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c
b/src/testing/testing_api_cmd_merchant_get_order.c
index 1fed93a..87afb01 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -172,6 +172,7 @@ merchant_get_order_cb (
if (gos->paid)
{
const struct TALER_TESTING_Command *order_cmd;
+ struct TALER_Amount refunded_total;
order_cmd = TALER_TESTING_interpreter_lookup_command (
gos->is,
@@ -371,6 +372,10 @@ merchant_get_order_cb (
TALER_TESTING_interpreter_fail (gos->is);
return;
}
+ if (0 < gos->refunds_length)
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero
(osr->details.paid.refund_amount.currency,
+ &refunded_total));
for (unsigned int i = 0; i < gos->refunds_length; ++i)
{
const struct TALER_TESTING_Command *refund_cmd;
@@ -397,11 +402,14 @@ merchant_get_order_cb (
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (expected_amount_str,
&expected_amount));
+ GNUNET_assert (0 <= TALER_amount_add (&refunded_total,
+ &refunded_total,
+ amount_found));
if ((GNUNET_OK !=
TALER_amount_cmp_currency (&expected_amount,
- amount_found)) ||
+ &refunded_total)) ||
(0 != TALER_amount_cmp (&expected_amount,
- amount_found)))
+ &refunded_total)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Refund amounts do not match\n");
diff --git a/src/testing/testing_api_cmd_wallet_get_order.c
b/src/testing/testing_api_cmd_wallet_get_order.c
index 3ebeda4..b4a4ce7 100644
--- a/src/testing/testing_api_cmd_wallet_get_order.c
+++ b/src/testing/testing_api_cmd_wallet_get_order.c
@@ -155,39 +155,50 @@ wallet_get_order_cb (
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- for (unsigned int i = 0; i < num_refunds; ++i)
{
- const struct TALER_TESTING_Command *refund_cmd;
- const char *expected_amount_str;
- struct TALER_Amount expected_amount;
+ struct TALER_Amount refunded_total;
+ if (num_refunds > 0)
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (refund_amount->currency,
+ &refunded_total));
+ for (unsigned int i = 0; i < num_refunds; ++i)
+ {
+ const struct TALER_TESTING_Command *refund_cmd;
+ const char *expected_amount_str;
+ struct TALER_Amount expected_amount;
- refund_cmd = TALER_TESTING_interpreter_lookup_command (
- gos->is,
- gos->refunds[i]);
+ refund_cmd = TALER_TESTING_interpreter_lookup_command (
+ gos->is,
+ gos->refunds[i]);
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_string (refund_cmd,
- 0,
- &expected_amount_str))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not fetch refund amount\n");
- TALER_TESTING_interpreter_fail (gos->is);
- return;
- }
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (expected_amount_str,
- &expected_amount));
- if ((GNUNET_OK !=
- TALER_amount_cmp_currency (&expected_amount,
- &refunds[i].refund_amount)) ||
- (0 != TALER_amount_cmp (&expected_amount,
- &refunds[i].refund_amount)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Refund amounts do not match\n");
- TALER_TESTING_interpreter_fail (gos->is);
- return;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_string (refund_cmd,
+ 0,
+ &expected_amount_str))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch refund amount\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (expected_amount_str,
+ &expected_amount));
+ /* The most recent refunds are returned first */
+ GNUNET_assert (0 <= TALER_amount_add (&refunded_total,
+ &refunded_total,
+ &refunds[num_refunds - 1 -
i].refund_amount));
+ if ((GNUNET_OK !=
+ TALER_amount_cmp_currency (&expected_amount,
+ &refunded_total)) ||
+ (0 != TALER_amount_cmp (&expected_amount,
+ &refunded_total)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Refund amounts do not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
}
}
if (!paid_b)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: test for increasing refunds multiple times,
gnunet <=