-implement first draft of testing_api_cmd_reserve_get_attestable.c
This commit is contained in:
parent
165b85ddd5
commit
538ab8753c
@ -1 +1 @@
|
|||||||
Subproject commit 9dee7d6e8f967fdc58ae224e19ec03989ac35c52
|
Subproject commit d402af78f6d360841db53baa46dddae13590ec33
|
@ -86,6 +86,7 @@ libtalertesting_la_SOURCES = \
|
|||||||
testing_api_cmd_refund.c \
|
testing_api_cmd_refund.c \
|
||||||
testing_api_cmd_refresh.c \
|
testing_api_cmd_refresh.c \
|
||||||
testing_api_cmd_reserve_get.c \
|
testing_api_cmd_reserve_get.c \
|
||||||
|
testing_api_cmd_reserve_get_attestable.c \
|
||||||
testing_api_cmd_reserve_history.c \
|
testing_api_cmd_reserve_history.c \
|
||||||
testing_api_cmd_reserve_open.c \
|
testing_api_cmd_reserve_open.c \
|
||||||
testing_api_cmd_reserve_purse.c \
|
testing_api_cmd_reserve_purse.c \
|
||||||
|
@ -41,17 +41,17 @@ struct GetAttestableState
|
|||||||
/**
|
/**
|
||||||
* Handle to the "reserve get_attestable" operation.
|
* Handle to the "reserve get_attestable" operation.
|
||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_ReservesGetAttestableHandle *rsh;
|
struct TALER_EXCHANGE_ReservesGetAttestHandle *rgah;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected reserve balance.
|
* Expected attestable attributes.
|
||||||
*/
|
*/
|
||||||
const char *expected_balance;
|
const char **expected_attestables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private key of the reserve being analyzed.
|
* Length of the @e expected_attestables array.
|
||||||
*/
|
*/
|
||||||
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
unsigned int expected_attestables_length;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public key of the reserve being analyzed.
|
* Public key of the reserve being analyzed.
|
||||||
@ -78,14 +78,14 @@ struct GetAttestableState
|
|||||||
* @param rs HTTP response details
|
* @param rs HTTP response details
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
reserve_get_attestable_cb (void *cls,
|
reserve_get_attestable_cb (
|
||||||
const struct TALER_EXCHANGE_ReserveGetAttestable *rs)
|
void *cls,
|
||||||
|
const struct TALER_EXCHANGE_ReserveGetAttestResult *rs)
|
||||||
{
|
{
|
||||||
struct GetAttestableState *ss = cls;
|
struct GetAttestableState *ss = cls;
|
||||||
struct TALER_TESTING_Interpreter *is = ss->is;
|
struct TALER_TESTING_Interpreter *is = ss->is;
|
||||||
struct TALER_Amount eb;
|
|
||||||
|
|
||||||
ss->rsh = NULL;
|
ss->rgah = NULL;
|
||||||
if (ss->expected_response_code != rs->hr.http_status)
|
if (ss->expected_response_code != rs->hr.http_status)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
@ -104,6 +104,7 @@ reserve_get_attestable_cb (void *cls,
|
|||||||
TALER_TESTING_interpreter_next (is);
|
TALER_TESTING_interpreter_next (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// FIXME: check returned list matches expectations!
|
||||||
TALER_TESTING_interpreter_next (is);
|
TALER_TESTING_interpreter_next (is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,8 @@ get_attestable_run (void *cls,
|
|||||||
{
|
{
|
||||||
struct GetAttestableState *ss = cls;
|
struct GetAttestableState *ss = cls;
|
||||||
const struct TALER_TESTING_Command *create_reserve;
|
const struct TALER_TESTING_Command *create_reserve;
|
||||||
|
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||||
|
|
||||||
ss->is = is;
|
ss->is = is;
|
||||||
create_reserve
|
create_reserve
|
||||||
@ -134,21 +137,31 @@ get_attestable_run (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (is);
|
TALER_TESTING_interpreter_fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK ==
|
||||||
TALER_TESTING_get_trait_reserve_priv (create_reserve,
|
TALER_TESTING_get_trait_reserve_priv (create_reserve,
|
||||||
&ss->reserve_priv))
|
&reserve_priv))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
||||||
TALER_LOG_ERROR ("Failed to find reserve_priv for get_attestable query\n");
|
&ss->reserve_pub.eddsa_pub);
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
|
else
|
||||||
&ss->reserve_pub.eddsa_pub);
|
{
|
||||||
ss->rsh = TALER_EXCHANGE_reserves_get_attestable (is->exchange,
|
if (GNUNET_OK !=
|
||||||
ss->reserve_priv,
|
TALER_TESTING_get_trait_reserve_pub (create_reserve,
|
||||||
&reserve_get_attestable_cb,
|
&reserve_pub))
|
||||||
ss);
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_LOG_ERROR (
|
||||||
|
"Failed to find reserve_priv for get_attestable query\n");
|
||||||
|
TALER_TESTING_interpreter_fail (is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ss->reserve_pub = *reserve_pub;
|
||||||
|
}
|
||||||
|
ss->rgah = TALER_EXCHANGE_reserves_get_attestable (is->exchange,
|
||||||
|
&ss->reserve_pub,
|
||||||
|
&reserve_get_attestable_cb,
|
||||||
|
ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,15 +178,16 @@ get_attestable_cleanup (void *cls,
|
|||||||
{
|
{
|
||||||
struct GetAttestableState *ss = cls;
|
struct GetAttestableState *ss = cls;
|
||||||
|
|
||||||
if (NULL != ss->rsh)
|
if (NULL != ss->rgah)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"Command %u (%s) did not complete\n",
|
"Command %u (%s) did not complete\n",
|
||||||
ss->is->ip,
|
ss->is->ip,
|
||||||
cmd->label);
|
cmd->label);
|
||||||
TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rsh);
|
TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rgah);
|
||||||
ss->rsh = NULL;
|
ss->rgah = NULL;
|
||||||
}
|
}
|
||||||
|
GNUNET_free (ss->expected_attestables);
|
||||||
GNUNET_free (ss);
|
GNUNET_free (ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,12 +199,29 @@ TALER_TESTING_cmd_reserve_get_attestable (const char *label,
|
|||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
struct GetAttestableState *ss;
|
struct GetAttestableState *ss;
|
||||||
|
va_list ap;
|
||||||
|
unsigned int num_expected;
|
||||||
|
const char *ea;
|
||||||
|
|
||||||
|
num_expected = 0;
|
||||||
|
va_start (ap, expected_response_code);
|
||||||
|
while (NULL != va_arg (ap, const char *))
|
||||||
|
num_expected++;
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
GNUNET_assert (NULL != reserve_reference);
|
GNUNET_assert (NULL != reserve_reference);
|
||||||
ss = GNUNET_new (struct GetAttestableState);
|
ss = GNUNET_new (struct GetAttestableState);
|
||||||
ss->reserve_reference = reserve_reference;
|
ss->reserve_reference = reserve_reference;
|
||||||
ss->expected_balance = expected_balance;
|
|
||||||
ss->expected_response_code = expected_response_code;
|
ss->expected_response_code = expected_response_code;
|
||||||
|
ss->expected_attestables_length = num_expected;
|
||||||
|
ss->expected_attestables = GNUNET_new_array (num_expected,
|
||||||
|
const char *);
|
||||||
|
num_expected = 0;
|
||||||
|
va_start (ap, expected_response_code);
|
||||||
|
while (NULL != (ea = va_arg (ap, const char *)))
|
||||||
|
ss->expected_attestables[num_expected++] = ea;
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Command cmd = {
|
struct TALER_TESTING_Command cmd = {
|
||||||
.cls = ss,
|
.cls = ss,
|
||||||
|
Loading…
Reference in New Issue
Block a user