summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_wallet_get_order.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_wallet_get_order.c')
-rw-r--r--src/testing/testing_api_cmd_wallet_get_order.c71
1 files changed, 41 insertions, 30 deletions
diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c
index 3ebeda4e..b4a4ce71 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)