-fix reserve history, include in tests
This commit is contained in:
parent
ab4aa4dcfd
commit
d55b093de8
@ -820,7 +820,7 @@ TEH_RESPONSE_compile_reserve_history (
|
|||||||
&history->reserve_sig),
|
&history->reserve_sig),
|
||||||
GNUNET_JSON_pack_timestamp ("request_timestamp",
|
GNUNET_JSON_pack_timestamp ("request_timestamp",
|
||||||
history->request_timestamp),
|
history->request_timestamp),
|
||||||
TALER_JSON_pack_amount ("history_fee",
|
TALER_JSON_pack_amount ("amount",
|
||||||
&history->history_fee))))
|
&history->history_fee))))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -6315,9 +6315,9 @@ add_history_requests (void *cls,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GNUNET_assert (0 <=
|
GNUNET_assert (0 <=
|
||||||
TALER_amount_subtract (&rhc->balance_out,
|
TALER_amount_add (&rhc->balance_out,
|
||||||
&rhc->balance_out,
|
&rhc->balance_out,
|
||||||
&history->history_fee));
|
&history->history_fee));
|
||||||
history->reserve_pub = *rhc->reserve_pub;
|
history->reserve_pub = *rhc->reserve_pub;
|
||||||
tail = append_rh (rhc);
|
tail = append_rh (rhc);
|
||||||
tail->type = TALER_EXCHANGEDB_RO_HISTORY_REQUEST;
|
tail->type = TALER_EXCHANGEDB_RO_HISTORY_REQUEST;
|
||||||
|
@ -1814,16 +1814,6 @@ struct TALER_EXCHANGE_ReserveHistory
|
|||||||
*/
|
*/
|
||||||
unsigned int history_len;
|
unsigned int history_len;
|
||||||
|
|
||||||
/**
|
|
||||||
* KYC passed?
|
|
||||||
*/
|
|
||||||
bool kyc_ok;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* KYC required to withdraw?
|
|
||||||
*/
|
|
||||||
bool kyc_required;
|
|
||||||
|
|
||||||
} ok;
|
} ok;
|
||||||
|
|
||||||
} details;
|
} details;
|
||||||
|
@ -476,8 +476,6 @@ parse_history (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
|
|||||||
struct GNUNET_JSON_Specification history_spec[] = {
|
struct GNUNET_JSON_Specification history_spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
|
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
|
||||||
&rh->details.history_details.reserve_sig),
|
&rh->details.history_details.reserve_sig),
|
||||||
TALER_JSON_spec_amount_any ("history_fee",
|
|
||||||
&rh->amount),
|
|
||||||
GNUNET_JSON_spec_timestamp ("request_timestamp",
|
GNUNET_JSON_spec_timestamp ("request_timestamp",
|
||||||
&rh->details.history_details.request_timestamp),
|
&rh->details.history_details.request_timestamp),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
@ -578,6 +576,9 @@ TALER_EXCHANGE_parse_reserve_history (
|
|||||||
NULL, NULL))
|
NULL, NULL))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
|
json_dumpf (transaction,
|
||||||
|
stderr,
|
||||||
|
JSON_INDENT (2));
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
rh->amount = amount;
|
rh->amount = amount;
|
||||||
|
@ -110,10 +110,6 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,
|
|||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
TALER_JSON_spec_amount_any ("balance",
|
TALER_JSON_spec_amount_any ("balance",
|
||||||
&rs.details.ok.balance),
|
&rs.details.ok.balance),
|
||||||
GNUNET_JSON_spec_bool ("kyc_passed",
|
|
||||||
&rs.details.ok.kyc_ok),
|
|
||||||
GNUNET_JSON_spec_bool ("kyc_required",
|
|
||||||
&rs.details.ok.kyc_required),
|
|
||||||
GNUNET_JSON_spec_json ("history",
|
GNUNET_JSON_spec_json ("history",
|
||||||
&history),
|
&history),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
@ -197,6 +193,7 @@ handle_reserves_history_finished (void *cls,
|
|||||||
handle_reserves_history_ok (rsh,
|
handle_reserves_history_ok (rsh,
|
||||||
j))
|
j))
|
||||||
{
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
rs.hr.http_status = 0;
|
rs.hr.http_status = 0;
|
||||||
rs.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
|
rs.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
|
||||||
}
|
}
|
||||||
@ -221,6 +218,11 @@ handle_reserves_history_finished (void *cls,
|
|||||||
rs.hr.ec = TALER_JSON_get_error_code (j);
|
rs.hr.ec = TALER_JSON_get_error_code (j);
|
||||||
rs.hr.hint = TALER_JSON_get_error_hint (j);
|
rs.hr.hint = TALER_JSON_get_error_hint (j);
|
||||||
break;
|
break;
|
||||||
|
case MHD_HTTP_CONFLICT:
|
||||||
|
/* Insufficient balance to inquire for reserve history */
|
||||||
|
rs.hr.ec = TALER_JSON_get_error_code (j);
|
||||||
|
rs.hr.hint = TALER_JSON_get_error_hint (j);
|
||||||
|
break;
|
||||||
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
||||||
/* Server had an internal issue; we should retry, but this API
|
/* Server had an internal issue; we should retry, but this API
|
||||||
leaves this to the application */
|
leaves this to the application */
|
||||||
@ -306,10 +308,22 @@ TALER_EXCHANGE_reserves_history (
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
keys = TALER_EXCHANGE_get_keys (exchange);
|
keys = TALER_EXCHANGE_get_keys (exchange);
|
||||||
GNUNET_assert (NULL != keys);
|
if (NULL == keys)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
GNUNET_free (rsh->url);
|
||||||
|
GNUNET_free (rsh);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
gf = TALER_EXCHANGE_get_global_fee (keys,
|
gf = TALER_EXCHANGE_get_global_fee (keys,
|
||||||
rsh->ts);
|
rsh->ts);
|
||||||
GNUNET_assert (NULL != gf);
|
if (NULL == gf)
|
||||||
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
|
GNUNET_free (rsh->url);
|
||||||
|
GNUNET_free (rsh);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
TALER_wallet_reserve_history_sign (rsh->ts,
|
TALER_wallet_reserve_history_sign (rsh->ts,
|
||||||
&gf->fees.history,
|
&gf->fees.history,
|
||||||
reserve_priv,
|
reserve_priv,
|
||||||
@ -336,10 +350,11 @@ TALER_EXCHANGE_reserves_history (
|
|||||||
json_decref (history_obj);
|
json_decref (history_obj);
|
||||||
}
|
}
|
||||||
ctx = TEAH_handle_to_context (exchange);
|
ctx = TEAH_handle_to_context (exchange);
|
||||||
rsh->job = GNUNET_CURL_job_add (ctx,
|
rsh->job = GNUNET_CURL_job_add2 (ctx,
|
||||||
eh,
|
eh,
|
||||||
&handle_reserves_history_finished,
|
rsh->post_ctx.headers,
|
||||||
rsh);
|
&handle_reserves_history_finished,
|
||||||
|
rsh);
|
||||||
return rsh;
|
return rsh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,8 +565,8 @@ run (void *cls,
|
|||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
CMD_EXEC_AGGREGATOR ("aggregation-attempt"),
|
CMD_EXEC_AGGREGATOR ("aggregation-attempt"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
("far-future-aggregation-b"),
|
"far-future-aggregation-b"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
@ -1136,14 +1136,14 @@ run (void *cls,
|
|||||||
* Move money to the exchange's bank account.
|
* Move money to the exchange's bank account.
|
||||||
*/
|
*/
|
||||||
CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1",
|
CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1",
|
||||||
"EUR:6.02"),
|
"EUR:6.03"),
|
||||||
TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1",
|
TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1",
|
||||||
"create-batch-reserve-1",
|
"create-batch-reserve-1",
|
||||||
"EUR:6.02",
|
"EUR:6.03",
|
||||||
GNUNET_TIME_UNIT_MINUTES,
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1",
|
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1",
|
||||||
"EUR:6.02",
|
"EUR:6.03",
|
||||||
bc.user42_payto,
|
bc.user42_payto,
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
"create-batch-reserve-1"),
|
"create-batch-reserve-1"),
|
||||||
@ -1166,11 +1166,19 @@ run (void *cls,
|
|||||||
"EUR:1",
|
"EUR:1",
|
||||||
NULL),
|
NULL),
|
||||||
/**
|
/**
|
||||||
* Check the reserve is depleted.
|
* Check the reserve is (almost) depleted.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_status ("status-batch-1",
|
TALER_TESTING_cmd_status ("status-batch-1",
|
||||||
"create-batch-reserve-1",
|
"create-batch-reserve-1",
|
||||||
"EUR:0",
|
"EUR:0.01",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
TALER_TESTING_cmd_reserve_history ("history-batch-1",
|
||||||
|
"create-batch-reserve-1",
|
||||||
|
"EUR:0",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
TALER_TESTING_cmd_status ("status-batch-2",
|
||||||
|
"create-batch-reserve-1",
|
||||||
|
"EUR:0.0",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
/**
|
/**
|
||||||
* Spend the coins.
|
* Spend the coins.
|
||||||
@ -1240,6 +1248,17 @@ run (void *cls,
|
|||||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||||
MHD_HTTP_NO_CONTENT,
|
MHD_HTTP_NO_CONTENT,
|
||||||
false),
|
false),
|
||||||
|
TALER_TESTING_cmd_exec_offline_sign_global_fees (
|
||||||
|
"offline-sign-global-fees",
|
||||||
|
config_file,
|
||||||
|
"EUR:0.01",
|
||||||
|
"EUR:0.01",
|
||||||
|
"EUR:0.01",
|
||||||
|
"EUR:0.01",
|
||||||
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
|
GNUNET_TIME_UNIT_DAYS,
|
||||||
|
1),
|
||||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||||
config_file),
|
config_file),
|
||||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||||
|
@ -429,6 +429,8 @@ batch_withdraw_traits (void *cls,
|
|||||||
TALER_TESTING_trait_end ()
|
TALER_TESTING_trait_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (index >= ws->num_coins)
|
||||||
|
return GNUNET_NO;
|
||||||
return TALER_TESTING_get_trait ((ws->expected_response_code == MHD_HTTP_OK)
|
return TALER_TESTING_get_trait ((ws->expected_response_code == MHD_HTTP_OK)
|
||||||
? &traits[0] /* we have reserve history */
|
? &traits[0] /* we have reserve history */
|
||||||
: &traits[1], /* skip reserve history */
|
: &traits[1], /* skip reserve history */
|
||||||
|
@ -114,8 +114,6 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
|||||||
{
|
{
|
||||||
struct TALER_TESTING_Command *step = &(*bcmd)[i];
|
struct TALER_TESTING_Command *step = &(*bcmd)[i];
|
||||||
|
|
||||||
if (step == cur)
|
|
||||||
break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
analyze_command (reserve_pub,
|
analyze_command (reserve_pub,
|
||||||
step,
|
step,
|
||||||
@ -128,10 +126,12 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
|||||||
step->label);
|
step->label);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
if (step == cur)
|
||||||
|
break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */
|
||||||
}
|
}
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const struct TALER_ReservePublicKeyP *rp;
|
const struct TALER_ReservePublicKeyP *rp;
|
||||||
|
|
||||||
@ -146,6 +146,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
|||||||
for (unsigned int j = 0; true; j++)
|
for (unsigned int j = 0; true; j++)
|
||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
|
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
|
||||||
|
bool matched = false;
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_reserve_history (cmd,
|
TALER_TESTING_get_trait_reserve_history (cmd,
|
||||||
@ -168,14 +169,18 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
|||||||
&history[i]))
|
&history[i]))
|
||||||
{
|
{
|
||||||
found[i] = true;
|
found[i] = true;
|
||||||
return GNUNET_OK;
|
matched = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
if (! matched)
|
||||||
"Command `%s' reserve history entry #%u not found\n",
|
{
|
||||||
cmd->label,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
j);
|
"Command `%s' reserve history entry #%u not found\n",
|
||||||
return GNUNET_SYSERR;
|
cmd->label,
|
||||||
|
j);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,9 +242,13 @@ reserve_history_cb (void *cls,
|
|||||||
if (0 != TALER_amount_cmp (&eb,
|
if (0 != TALER_amount_cmp (&eb,
|
||||||
&rs->details.ok.balance))
|
&rs->details.ok.balance))
|
||||||
{
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected amount in reserve: %s\n",
|
"Unexpected amount in reserve: %s\n",
|
||||||
TALER_amount_to_string (&rs->details.ok.balance));
|
TALER_amount_to_string (&rs->details.ok.balance));
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Expected balance of: %s\n",
|
||||||
|
TALER_amount_to_string (&eb));
|
||||||
TALER_TESTING_interpreter_fail (ss->is);
|
TALER_TESTING_interpreter_fail (ss->is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -351,6 +360,7 @@ history_traits (void *cls,
|
|||||||
/* history entry MUST be first due to response code logic below! */
|
/* history entry MUST be first due to response code logic below! */
|
||||||
TALER_TESTING_make_trait_reserve_history (0,
|
TALER_TESTING_make_trait_reserve_history (0,
|
||||||
&hs->reserve_history),
|
&hs->reserve_history),
|
||||||
|
TALER_TESTING_make_trait_reserve_pub (&hs->reserve_pub),
|
||||||
TALER_TESTING_trait_end ()
|
TALER_TESTING_trait_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -138,6 +138,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
|||||||
for (unsigned int j = 0; true; j++)
|
for (unsigned int j = 0; true; j++)
|
||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
|
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
|
||||||
|
bool matched = false;
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_reserve_history (cmd,
|
TALER_TESTING_get_trait_reserve_history (cmd,
|
||||||
@ -159,14 +160,18 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
|||||||
&history[i]))
|
&history[i]))
|
||||||
{
|
{
|
||||||
found[i] = true;
|
found[i] = true;
|
||||||
return GNUNET_OK;
|
matched = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
if (! matched)
|
||||||
"Command `%s' reserve history entry #%u not found\n",
|
{
|
||||||
cmd->label,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
j);
|
"Command `%s' reserve history entry #%u not found\n",
|
||||||
return GNUNET_SYSERR;
|
cmd->label,
|
||||||
|
j);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,9 +218,13 @@ reserve_status_cb (void *cls,
|
|||||||
if (0 != TALER_amount_cmp (&eb,
|
if (0 != TALER_amount_cmp (&eb,
|
||||||
&rs->details.ok.balance))
|
&rs->details.ok.balance))
|
||||||
{
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected amount in reserve: %s\n",
|
"Unexpected amount in reserve: %s\n",
|
||||||
TALER_amount_to_string (&rs->details.ok.balance));
|
TALER_amount_to_string (&rs->details.ok.balance));
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Expected balance of: %s\n",
|
||||||
|
TALER_amount_to_string (&eb));
|
||||||
TALER_TESTING_interpreter_fail (ss->is);
|
TALER_TESTING_interpreter_fail (ss->is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,7 @@ TALER_TESTING_exchange_db_reset (const char *config_filename)
|
|||||||
"taler-exchange-dbinit",
|
"taler-exchange-dbinit",
|
||||||
"taler-exchange-dbinit",
|
"taler-exchange-dbinit",
|
||||||
"-c", config_filename,
|
"-c", config_filename,
|
||||||
|
"-L", "WARNING",
|
||||||
"-r",
|
"-r",
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == proc)
|
if (NULL == proc)
|
||||||
|
@ -668,7 +668,7 @@ TALER_wallet_reserve_history_verify (
|
|||||||
TALER_amount_hton (&rhr.history_fee,
|
TALER_amount_hton (&rhr.history_fee,
|
||||||
history_fee);
|
history_fee);
|
||||||
return GNUNET_CRYPTO_eddsa_verify (
|
return GNUNET_CRYPTO_eddsa_verify (
|
||||||
TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW,
|
TALER_SIGNATURE_WALLET_RESERVE_HISTORY,
|
||||||
&rhr,
|
&rhr,
|
||||||
&reserve_sig->eddsa_signature,
|
&reserve_sig->eddsa_signature,
|
||||||
&reserve_pub->eddsa_pub);
|
&reserve_pub->eddsa_pub);
|
||||||
|
Loading…
Reference in New Issue
Block a user