summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-09 23:27:16 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-09 23:27:16 +0200
commitaf0a2c32a3592b3fe0a756ada1bf377c144a855b (patch)
tree6e54b4971b1ad421f11a9de4b686068ebbf19499
parentf708e4d64cd72775a640182d308a7549fb3006d9 (diff)
downloadexchange-af0a2c32a3592b3fe0a756ada1bf377c144a855b.tar.gz
exchange-af0a2c32a3592b3fe0a756ada1bf377c144a855b.tar.bz2
exchange-af0a2c32a3592b3fe0a756ada1bf377c144a855b.zip
work on more testing for recoup-refresh
-rw-r--r--src/exchangedb/exchangedb_transactions.c11
-rw-r--r--src/testing/test_exchange_api.c50
2 files changed, 52 insertions, 9 deletions
diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c
index c1723958f..11ed3ac77 100644
--- a/src/exchangedb/exchangedb_transactions.c
+++ b/src/exchangedb/exchangedb_transactions.c
@@ -42,13 +42,13 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
struct TALER_Amount refunded;
struct TALER_Amount deposit_fee;
bool have_refund;
- bool have_deposit_or_melt;
+ bool have_deposit_or_melt_or_recoup;
GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (spent.currency,
&refunded));
have_refund = false;
- have_deposit_or_melt = false;
+ have_deposit_or_melt_or_recoup = false;
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
NULL != pos;
pos = pos->next)
@@ -57,7 +57,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
{
case TALER_EXCHANGEDB_TT_DEPOSIT:
/* spent += pos->amount_with_fee */
- have_deposit_or_melt = true;
+ have_deposit_or_melt_or_recoup = true;
if (0 >
TALER_amount_add (&spent,
&spent,
@@ -70,7 +70,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
break;
case TALER_EXCHANGEDB_TT_MELT:
/* spent += pos->amount_with_fee */
- have_deposit_or_melt = true;
+ have_deposit_or_melt_or_recoup = true;
if (0 >
TALER_amount_add (&spent,
&spent,
@@ -112,6 +112,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
}
break;
case TALER_EXCHANGEDB_TT_RECOUP:
+ have_deposit_or_melt_or_recoup = true;
/* spent += pos->value */
if (0 >
TALER_amount_add (&spent,
@@ -156,7 +157,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
GNUNET_break (0);
return GNUNET_SYSERR;
}
- GNUNET_break (have_deposit_or_melt);
+ GNUNET_break (have_deposit_or_melt_or_recoup);
*ret = spent;
return GNUNET_OK;
}
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c
index eb6a2b1bb..7912041da 100644
--- a/src/testing/test_exchange_api.c
+++ b/src/testing/test_exchange_api.c
@@ -623,10 +623,10 @@ run (void *cls,
* config.
*/
CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-1",
- "EUR:5.01"),
+ "EUR:15.02"),
TALER_TESTING_cmd_check_bank_admin_transfer (
"recoup-create-reserve-1-check",
- "EUR:5.01",
+ "EUR:15.02",
bc.user42_payto,
bc.exchange_payto,
"recoup-create-reserve-1"),
@@ -639,12 +639,26 @@ run (void *cls,
"recoup-create-reserve-1",
"EUR:5",
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",
MHD_HTTP_OK,
"recoup-withdraw-coin-1",
CONFIG_FILE),
- /* Refund coin to bank account */
+ /* Recoup coin to reserve */
TALER_TESTING_cmd_recoup ("recoup-1",
MHD_HTTP_OK,
"recoup-withdraw-coin-1",
@@ -655,6 +669,34 @@ run (void *cls,
"recoup-create-reserve-1",
"EUR:5.0",
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 */
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2",
"recoup-create-reserve-1",