fix reserve_pub-via-reserve_priv FIXME
This commit is contained in:
parent
5a03bb71b5
commit
2ffabd394c
Binary file not shown.
@ -1 +1 @@
|
|||||||
EM5CX1EXCARDTQW260HE5YT55VH6BMF720K6CTJ3HP2YVAP4AQC0
|
48X6TSXXCZ0F69A3Y12FPXMM1TBS4AVJ86EQ7GN9KMDZ7M0NFFCG
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -74,14 +74,13 @@ struct StatusState
|
|||||||
* @param history detailed transaction history, NULL on error.
|
* @param history detailed transaction history, NULL on error.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
reserve_status_cb
|
reserve_status_cb (void *cls,
|
||||||
(void *cls,
|
unsigned int http_status,
|
||||||
unsigned int http_status,
|
enum TALER_ErrorCode ec,
|
||||||
enum TALER_ErrorCode ec,
|
const json_t *json,
|
||||||
const json_t *json,
|
const struct TALER_Amount *balance,
|
||||||
const struct TALER_Amount *balance,
|
unsigned int history_length,
|
||||||
unsigned int history_length,
|
const struct TALER_EXCHANGE_ReserveHistory *history)
|
||||||
const struct TALER_EXCHANGE_ReserveHistory *history)
|
|
||||||
{
|
{
|
||||||
struct StatusState *ss = cls;
|
struct StatusState *ss = cls;
|
||||||
struct TALER_Amount eb;
|
struct TALER_Amount eb;
|
||||||
@ -98,10 +97,12 @@ reserve_status_cb
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK == TALER_string_to_amount
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(ss->expected_balance, &eb));
|
TALER_string_to_amount (ss->expected_balance,
|
||||||
|
&eb));
|
||||||
|
|
||||||
if (0 != TALER_amount_cmp (&eb, balance))
|
if (0 != TALER_amount_cmp (&eb,
|
||||||
|
balance))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected amount in reserve: %s\n",
|
"Unexpected amount in reserve: %s\n",
|
||||||
@ -110,23 +111,23 @@ reserve_status_cb
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fixme: need a way to check if reserve history is consistent.
|
* FIXME: need a way to check if reserve history is consistent. Every
|
||||||
* Every command which relates to reserve 'x' should be added in
|
* command which relates to reserve 'x' should be added in a linked list of
|
||||||
* a linked list of all commands that relate to the same reserve
|
* all commands that relate to the same reserve 'x'.
|
||||||
* 'x'.
|
*
|
||||||
*
|
* API-wise, any command that relates to a reserve should offer a
|
||||||
* API-wise, any command that relates to a reserve should offer a
|
* method called e.g. "compare_with_history" that takes an element
|
||||||
* method called e.g. "compare_with_history" that takes an element
|
* of the array returned by "/reserve/status" and checks if that
|
||||||
* of the array returned by "/reserve/status" and checks if that
|
* element correspond to itself (= the command exposing the check-
|
||||||
* element correspond to itself (= the command exposing the check-
|
* method).
|
||||||
* method).
|
*
|
||||||
*
|
* IDEA: Maybe realize this via another trait, some kind of
|
||||||
* IDEA: Maybe realize this via another trait, some kind of
|
* "reserve history update trait" which returns information about
|
||||||
* "reserve history update trait" which returns information about
|
* how the command changes the history (provided only by commands
|
||||||
* how the command changes the history (provided only by commands
|
* that change reserve balances)?
|
||||||
* that change reserve balances)?
|
*///
|
||||||
*/TALER_TESTING_interpreter_next (ss->is);
|
TALER_TESTING_interpreter_next (ss->is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,16 +145,12 @@ status_run (void *cls,
|
|||||||
{
|
{
|
||||||
struct StatusState *ss = cls;
|
struct StatusState *ss = cls;
|
||||||
const struct TALER_TESTING_Command *create_reserve;
|
const struct TALER_TESTING_Command *create_reserve;
|
||||||
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
|
||||||
struct TALER_ReservePublicKeyP reserve_pub;
|
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pubp;
|
const struct TALER_ReservePublicKeyP *reserve_pubp;
|
||||||
|
|
||||||
ss->is = is;
|
ss->is = is;
|
||||||
GNUNET_assert (NULL != ss->reserve_reference);
|
|
||||||
|
|
||||||
create_reserve
|
create_reserve
|
||||||
= TALER_TESTING_interpreter_lookup_command
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
(is, ss->reserve_reference);
|
ss->reserve_reference);
|
||||||
|
|
||||||
if (NULL == create_reserve)
|
if (NULL == create_reserve)
|
||||||
{
|
{
|
||||||
@ -161,36 +158,16 @@ status_run (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (is);
|
TALER_TESTING_interpreter_fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
/* NOTE: the following line might generate a ERROR log
|
TALER_TESTING_get_trait_reserve_pub (create_reserve,
|
||||||
* statements, but it can be ignored. */
|
0,
|
||||||
/* FIXME: instead of having this logic here, any
|
&reserve_pubp))
|
||||||
command exporting a reserve_priv MUST also
|
|
||||||
export a reserve_pub, which would obsolete this
|
|
||||||
logic! */
|
|
||||||
if (GNUNET_OK ==
|
|
||||||
TALER_TESTING_get_trait_reserve_priv (create_reserve,
|
|
||||||
0,
|
|
||||||
&reserve_priv))
|
|
||||||
{
|
{
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
GNUNET_break (0);
|
||||||
&reserve_pub.eddsa_pub);
|
TALER_LOG_ERROR ("Failed to find reserve_pub for status query\n");
|
||||||
reserve_pubp = &reserve_pub;
|
TALER_TESTING_interpreter_fail (is);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_TESTING_get_trait_reserve_pub (create_reserve,
|
|
||||||
0,
|
|
||||||
&reserve_pubp))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
TALER_LOG_ERROR ("The reserve has neither a priv nor a pub.\n");
|
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ss->rsh = TALER_EXCHANGE_reserve_status (is->exchange,
|
ss->rsh = TALER_EXCHANGE_reserve_status (is->exchange,
|
||||||
reserve_pubp,
|
reserve_pubp,
|
||||||
&reserve_status_cb,
|
&reserve_status_cb,
|
||||||
@ -242,17 +219,19 @@ TALER_TESTING_cmd_status (const char *label,
|
|||||||
{
|
{
|
||||||
struct StatusState *ss;
|
struct StatusState *ss;
|
||||||
|
|
||||||
|
GNUNET_assert (NULL != reserve_reference);
|
||||||
ss = GNUNET_new (struct StatusState);
|
ss = GNUNET_new (struct StatusState);
|
||||||
ss->reserve_reference = reserve_reference;
|
ss->reserve_reference = reserve_reference;
|
||||||
ss->expected_balance = expected_balance;
|
ss->expected_balance = expected_balance;
|
||||||
ss->expected_response_code = expected_response_code;
|
ss->expected_response_code = expected_response_code;
|
||||||
|
{
|
||||||
|
struct TALER_TESTING_Command cmd = {
|
||||||
|
.cls = ss,
|
||||||
|
.label = label,
|
||||||
|
.run = &status_run,
|
||||||
|
.cleanup = &status_cleanup
|
||||||
|
};
|
||||||
|
|
||||||
struct TALER_TESTING_Command cmd = {
|
return cmd;
|
||||||
.cls = ss,
|
}
|
||||||
.label = label,
|
|
||||||
.run = &status_run,
|
|
||||||
.cleanup = &status_cleanup
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
|
||||||
}
|
}
|
||||||
|
@ -350,6 +350,7 @@ withdraw_traits (void *cls,
|
|||||||
struct WithdrawState *ws = cls;
|
struct WithdrawState *ws = cls;
|
||||||
const struct TALER_TESTING_Command *reserve_cmd;
|
const struct TALER_TESTING_Command *reserve_cmd;
|
||||||
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||||
|
|
||||||
/* We offer the reserve key where these coins were withdrawn
|
/* We offer the reserve key where these coins were withdrawn
|
||||||
* from. */
|
* from. */
|
||||||
@ -372,6 +373,15 @@ withdraw_traits (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (ws->is);
|
TALER_TESTING_interpreter_fail (ws->is);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
|
||||||
|
0,
|
||||||
|
&reserve_pub))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_TESTING_interpreter_fail (ws->is);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
if (NULL == ws->exchange_url)
|
if (NULL == ws->exchange_url)
|
||||||
ws->exchange_url
|
ws->exchange_url
|
||||||
= GNUNET_strdup (TALER_EXCHANGE_get_base_url (ws->is->exchange));
|
= GNUNET_strdup (TALER_EXCHANGE_get_base_url (ws->is->exchange));
|
||||||
@ -387,6 +397,8 @@ withdraw_traits (void *cls,
|
|||||||
&ws->sig),
|
&ws->sig),
|
||||||
TALER_TESTING_make_trait_reserve_priv (0,
|
TALER_TESTING_make_trait_reserve_priv (0,
|
||||||
reserve_priv),
|
reserve_priv),
|
||||||
|
TALER_TESTING_make_trait_reserve_pub (0,
|
||||||
|
reserve_pub),
|
||||||
TALER_TESTING_make_trait_amount_obj (0,
|
TALER_TESTING_make_trait_amount_obj (0,
|
||||||
&ws->amount),
|
&ws->amount),
|
||||||
TALER_TESTING_make_trait_url (0, ws->exchange_url),
|
TALER_TESTING_make_trait_url (0, ws->exchange_url),
|
||||||
|
Loading…
Reference in New Issue
Block a user