Ask to withdraw on a expired reserve.

This commit is contained in:
Marcello Stanisci 2018-05-18 16:54:36 +02:00
parent e746e0bbbc
commit 5019bd6914
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
6 changed files with 60 additions and 15 deletions

View File

@ -333,7 +333,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
struct TALER_ReserveCloseConfirmationPS rcc;
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_JSON_Specification closing_spec[] = {
GNUNET_JSON_spec_json ("receiver_account_details",
GNUNET_JSON_spec_string ("receiver_account_details",
&rhistory[off].details.close_details.receiver_account_details),
GNUNET_JSON_spec_fixed_auto ("wtid",
&rhistory[off].details.close_details.wtid),
@ -360,13 +360,9 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
}
TALER_amount_hton (&rcc.closing_amount,
&amount);
if (GNUNET_OK !=
TALER_JSON_wire_signature_hash (rhistory[off].details.close_details.receiver_account_details,
&rcc.h_wire))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
GNUNET_CRYPTO_hash (rhistory[off].details.close_details.receiver_account_details,
strlen (rhistory[off].details.close_details.receiver_account_details) + 1,
&rcc.h_wire);
rcc.wtid = rhistory[off].details.close_details.wtid;
rcc.purpose.size = htonl (sizeof (rcc));
rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED);
@ -377,7 +373,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
key_state = TALER_EXCHANGE_get_keys (exchange);
if (GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (key_state,
&rhistory[off].details.payback_details.exchange_pub))
&rhistory[off].details.close_details.exchange_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -385,8 +381,8 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED,
&rcc.purpose,
&rhistory[off].details.payback_details.exchange_sig.eddsa_signature,
&rhistory[off].details.payback_details.exchange_pub.eddsa_pub))
&rhistory[off].details.close_details.exchange_sig.eddsa_signature,
&rhistory[off].details.close_details.exchange_pub.eddsa_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -447,8 +443,7 @@ free_rhistory (struct TALER_EXCHANGE_ReserveHistory *rhistory,
case TALER_EXCHANGE_RTT_PAYBACK:
break;
case TALER_EXCHANGE_RTT_CLOSE:
if (NULL != rhistory[i].details.close_details.receiver_account_details)
json_decref (rhistory[i].details.close_details.receiver_account_details);
// should we free "receiver_account_details" ?
break;
}
}

View File

@ -0,0 +1,4 @@
@INLINE@ test_exchange_api.conf
[exchangedb]
IDLE_RESERVE_EXPIRATION_TIME = 0 s

View File

@ -42,6 +42,8 @@
*/
#define CONFIG_FILE "test_exchange_api.conf"
#define CONFIG_FILE_EXPIRE_RESERVE_NOW "test_exchange_api_expire_reserve_now.conf"
/**
* Is the configuration file is set to include wire format 'ebics'?
* Requires that EBICS /history function is implemented, which it
@ -638,6 +640,47 @@ run (void *cls,
"EUR:3.99",
MHD_HTTP_OK),
/**
* These commands should close the reserve because
* the aggregator is given a config file that ovverrides
* the reserve expiration time (making it now-ish)
*/
CMD_TRANSFER_TO_EXCHANGE
("short-lived-reserve",
"EUR:5.01"),
TALER_TESTING_cmd_exec_wirewatch
("short-lived-aggregation",
CONFIG_FILE_EXPIRE_RESERVE_NOW),
TALER_TESTING_cmd_exec_aggregator
("close-reserves",
CONFIG_FILE_EXPIRE_RESERVE_NOW),
TALER_TESTING_cmd_withdraw_amount
("expired-withdraw",
is->exchange,
"short-lived-reserve",
"EUR:1",
MHD_HTTP_FORBIDDEN),
/* Should also test a "insufficient funds" error
* after payback happened. */
TALER_TESTING_cmd_check_bank_transfer
("check_bank_short-lived_transfer",
exchange_url,
"EUR:5.01",
42,
2),
TALER_TESTING_cmd_check_bank_transfer
("check_bank_short-lived_reimburse",
exchange_url,
"EUR:5",
2,
42),
/**
* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
* config, then withdraw two coin, partially spend one, and

View File

@ -1133,6 +1133,7 @@ expired_reserve_cb (void *cls,
&wtid,
left,
closing_fee);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Closing reserve %s over %s (%d, %d)\n",
TALER_B2S (reserve_pub),

View File

@ -835,6 +835,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
break;
case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
{
struct TALER_ReserveCloseConfirmationPS rcc;
struct TALER_ExchangePublicKeyP pub;
struct TALER_ExchangeSignatureP sig;
@ -880,7 +881,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
}
GNUNET_assert (0 ==
json_array_append_new (json_history,
json_pack ("{s:s, s:O, s:o, s:o, s:o, s:o, s:o, s:o}",
json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}",
"type", "CLOSING",
"receiver_account_details", pos->details.closing->receiver_account_details,
"wtid", GNUNET_JSON_from_data_auto (&pos->details.closing->wtid),
@ -893,6 +894,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
break;
}
}
if (0 == (1 & ret))
{
GNUNET_break (0);

View File

@ -912,7 +912,7 @@ struct TALER_EXCHANGE_ReserveHistory
/**
* Receiver account information for the outgoing wire transfer.
*/
json_t *receiver_account_details;
const char *receiver_account_details;
/**
* Wire transfer details for the outgoing wire transfer.