work on more testing for recoup-refresh
This commit is contained in:
parent
f708e4d64c
commit
af0a2c32a3
@ -42,13 +42,13 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
struct TALER_Amount refunded;
|
struct TALER_Amount refunded;
|
||||||
struct TALER_Amount deposit_fee;
|
struct TALER_Amount deposit_fee;
|
||||||
bool have_refund;
|
bool have_refund;
|
||||||
bool have_deposit_or_melt;
|
bool have_deposit_or_melt_or_recoup;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_amount_get_zero (spent.currency,
|
TALER_amount_get_zero (spent.currency,
|
||||||
&refunded));
|
&refunded));
|
||||||
have_refund = false;
|
have_refund = false;
|
||||||
have_deposit_or_melt = false;
|
have_deposit_or_melt_or_recoup = false;
|
||||||
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
|
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
|
||||||
NULL != pos;
|
NULL != pos;
|
||||||
pos = pos->next)
|
pos = pos->next)
|
||||||
@ -57,7 +57,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
{
|
{
|
||||||
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
||||||
/* spent += pos->amount_with_fee */
|
/* spent += pos->amount_with_fee */
|
||||||
have_deposit_or_melt = true;
|
have_deposit_or_melt_or_recoup = true;
|
||||||
if (0 >
|
if (0 >
|
||||||
TALER_amount_add (&spent,
|
TALER_amount_add (&spent,
|
||||||
&spent,
|
&spent,
|
||||||
@ -70,7 +70,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
break;
|
break;
|
||||||
case TALER_EXCHANGEDB_TT_MELT:
|
case TALER_EXCHANGEDB_TT_MELT:
|
||||||
/* spent += pos->amount_with_fee */
|
/* spent += pos->amount_with_fee */
|
||||||
have_deposit_or_melt = true;
|
have_deposit_or_melt_or_recoup = true;
|
||||||
if (0 >
|
if (0 >
|
||||||
TALER_amount_add (&spent,
|
TALER_amount_add (&spent,
|
||||||
&spent,
|
&spent,
|
||||||
@ -112,6 +112,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TALER_EXCHANGEDB_TT_RECOUP:
|
case TALER_EXCHANGEDB_TT_RECOUP:
|
||||||
|
have_deposit_or_melt_or_recoup = true;
|
||||||
/* spent += pos->value */
|
/* spent += pos->value */
|
||||||
if (0 >
|
if (0 >
|
||||||
TALER_amount_add (&spent,
|
TALER_amount_add (&spent,
|
||||||
@ -156,7 +157,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_break (have_deposit_or_melt);
|
GNUNET_break (have_deposit_or_melt_or_recoup);
|
||||||
*ret = spent;
|
*ret = spent;
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
@ -623,10 +623,10 @@ run (void *cls,
|
|||||||
* config.
|
* config.
|
||||||
*/
|
*/
|
||||||
CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-1",
|
CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-1",
|
||||||
"EUR:5.01"),
|
"EUR:15.02"),
|
||||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||||
"recoup-create-reserve-1-check",
|
"recoup-create-reserve-1-check",
|
||||||
"EUR:5.01",
|
"EUR:15.02",
|
||||||
bc.user42_payto,
|
bc.user42_payto,
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
"recoup-create-reserve-1"),
|
"recoup-create-reserve-1"),
|
||||||
@ -639,12 +639,26 @@ run (void *cls,
|
|||||||
"recoup-create-reserve-1",
|
"recoup-create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
/* Make coin invalid */
|
/* Withdraw a 10 EUR coin, at fee of 1 ct */
|
||||||
|
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1b",
|
||||||
|
"recoup-create-reserve-1",
|
||||||
|
"EUR:10",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
/* melt 10 EUR coin to get 5 EUR refreshed coin */
|
||||||
|
TALER_TESTING_cmd_melt ("recoup-melt-coin-1b",
|
||||||
|
"recoup-withdraw-coin-1b",
|
||||||
|
MHD_HTTP_OK,
|
||||||
|
"EUR:5",
|
||||||
|
NULL),
|
||||||
|
TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1b",
|
||||||
|
"recoup-melt-coin-1b",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
/* Revoke both 5 EUR coins */
|
||||||
TALER_TESTING_cmd_revoke ("revoke-0-EUR:5",
|
TALER_TESTING_cmd_revoke ("revoke-0-EUR:5",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"recoup-withdraw-coin-1",
|
"recoup-withdraw-coin-1",
|
||||||
CONFIG_FILE),
|
CONFIG_FILE),
|
||||||
/* Refund coin to bank account */
|
/* Recoup coin to reserve */
|
||||||
TALER_TESTING_cmd_recoup ("recoup-1",
|
TALER_TESTING_cmd_recoup ("recoup-1",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"recoup-withdraw-coin-1",
|
"recoup-withdraw-coin-1",
|
||||||
@ -655,6 +669,34 @@ run (void *cls,
|
|||||||
"recoup-create-reserve-1",
|
"recoup-create-reserve-1",
|
||||||
"EUR:5.0",
|
"EUR:5.0",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
|
/* Recoup-refresh coin to 10 EUR coin */
|
||||||
|
TALER_TESTING_cmd_recoup ("recoup-1b",
|
||||||
|
MHD_HTTP_OK,
|
||||||
|
"recoup-reveal-coin-1b",
|
||||||
|
"recoup-melt-coin-1b",
|
||||||
|
"EUR:5"),
|
||||||
|
#if FIXME
|
||||||
|
/* "over-spend" 10 EUR recoup-refreshed coin */
|
||||||
|
TALER_TESTING_cmd_deposit ("recoup-refresh-deposit-failing",
|
||||||
|
"recoup-withdraw-coin-1b",
|
||||||
|
0,
|
||||||
|
bc.user42_payto,
|
||||||
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||||
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
|
"EUR:11.5",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
// FIXME: yes, we expect 'CONFLICT', but the
|
||||||
|
// coin history we get is totally wrong!
|
||||||
|
/* "spend" 10 EUR recoup-refreshed coin */
|
||||||
|
TALER_TESTING_cmd_deposit ("recoup-refresh-deposit-ok",
|
||||||
|
"recoup-withdraw-coin-1b",
|
||||||
|
0,
|
||||||
|
bc.user42_payto,
|
||||||
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||||
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
|
"EUR:9.5", /* FIXME: pick 'right' amount! */
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
#endif
|
||||||
/* Re-withdraw from this reserve */
|
/* Re-withdraw from this reserve */
|
||||||
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2",
|
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2",
|
||||||
"recoup-create-reserve-1",
|
"recoup-create-reserve-1",
|
||||||
|
Loading…
Reference in New Issue
Block a user