aboutsummaryrefslogtreecommitdiff
path: root/src/mint-lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-09 12:11:01 +0200
committerChristian Grothoff <christian@grothoff.org>2015-07-09 12:11:01 +0200
commitfdbedcd4574a991ad8dfb808039aba8fc60e5732 (patch)
tree9eca3e9c63f213e8db0d587de515c7abcdfd8180 /src/mint-lib
parent443b0db2c7eec47d88796a7573fe0e991094d2d0 (diff)
finish checks for /withdraw/status
Diffstat (limited to 'src/mint-lib')
-rw-r--r--src/mint-lib/test_mint_api.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index 615a232f4..15e18d90d 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -23,7 +23,6 @@
* TODO:
* - enhance interpreter to allow for testing of failure conditions
* (i.e. double-spending, insufficient funds on withdraw)
- * - add checks for /withdraw/status
*/
#include "platform.h"
#include "taler_util.h"
@@ -160,6 +159,11 @@ struct Command
*/
struct TALER_MINT_WithdrawStatusHandle *wsh;
+ /**
+ * Expected reserve balance.
+ */
+ const char *expected_balance;
+
} withdraw_status;
struct
@@ -441,6 +445,7 @@ compare_withdraw_sign_history (const struct TALER_MINT_ReserveHistory *h,
const struct Command *cmd)
{
struct TALER_Amount amount;
+ struct TALER_Amount amount_with_fee;
if (TALER_MINT_RTT_WITHDRAWAL != h->type)
{
@@ -450,13 +455,15 @@ compare_withdraw_sign_history (const struct TALER_MINT_ReserveHistory *h,
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (cmd->details.withdraw_sign.amount,
&amount));
- // FIXME: should fail (amount with vs. amount without fee!)
- if (0 != TALER_amount_cmp (&amount,
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_add (&amount_with_fee,
+ &amount,
+ &cmd->details.withdraw_sign.pk->fee_withdraw));
+ if (0 != TALER_amount_cmp (&amount_with_fee,
&h->amount))
{
GNUNET_break_op (0);
- return GNUNET_OK; /* FIXME: returning OK for now, as the above
- fails due to fee/no-fee mismatch */
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
}
@@ -486,6 +493,7 @@ withdraw_status_cb (void *cls,
struct Command *rel;
unsigned int i;
unsigned int j;
+ struct TALER_Amount amount;
cmd->details.withdraw_status.wsh = NULL;
if (MHD_HTTP_OK != http_status)
@@ -546,8 +554,19 @@ withdraw_status_cb (void *cls,
fail (is);
return;
}
- /* FIXME: check the amount... */
-
+ if (NULL != cmd->details.withdraw_status.expected_balance)
+ {
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (cmd->details.withdraw_status.expected_balance,
+ &amount));
+ if (0 != TALER_amount_cmp (&amount,
+ balance))
+ {
+ GNUNET_break (0);
+ fail (is);
+ return;
+ }
+ }
is->ip++;
is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
is);
@@ -1191,7 +1210,8 @@ run (void *cls,
.details.withdraw_sign.amount = "EUR:5" },
{ .oc = OC_WITHDRAW_STATUS,
.label = "withdraw-status-1",
- .details.withdraw_status.reserve_reference = "create-reserve-1" },
+ .details.withdraw_status.reserve_reference = "create-reserve-1",
+ .details.withdraw_status.expected_balance = "EUR:0" },
{ .oc = OC_DEPOSIT,
.label = "deposit-simple",
.details.deposit.amount = "EUR:5",