diff options
Diffstat (limited to 'src/exchange-lib')
-rw-r--r-- | src/exchange-lib/exchange_api_reserve.c | 21 | ||||
-rw-r--r-- | src/exchange-lib/test_exchange_api_expire_reserve_now.conf | 4 | ||||
-rw-r--r-- | src/exchange-lib/test_exchange_api_new.c | 43 |
3 files changed, 55 insertions, 13 deletions
diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c index 86a83fdb..e6da8cfd 100644 --- a/src/exchange-lib/exchange_api_reserve.c +++ b/src/exchange-lib/exchange_api_reserve.c @@ -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; } } diff --git a/src/exchange-lib/test_exchange_api_expire_reserve_now.conf b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf new file mode 100644 index 00000000..05bca956 --- /dev/null +++ b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf @@ -0,0 +1,4 @@ +@INLINE@ test_exchange_api.conf + +[exchangedb] +IDLE_RESERVE_EXPIRATION_TIME = 0 s diff --git a/src/exchange-lib/test_exchange_api_new.c b/src/exchange-lib/test_exchange_api_new.c index 0e480000..75f5fe6a 100644 --- a/src/exchange-lib/test_exchange_api_new.c +++ b/src/exchange-lib/test_exchange_api_new.c @@ -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 @@ -639,6 +641,47 @@ run (void *cls, 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 * then have the rest paid back. Check deposit of other coin |