Export testing-cert_cb in the API.
This way, this very basic cert_cb can be reused by other testing commands.
This commit is contained in:
parent
5a1594f63d
commit
08eafb1add
@ -116,6 +116,21 @@ TALER_TESTING_prepare_exchange (const char *config_filename,
|
|||||||
char **auditor_base_url,
|
char **auditor_base_url,
|
||||||
char **exchange_base_url);
|
char **exchange_base_url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Canonical" cert_cb used when we are connecting to the
|
||||||
|
* Exchange.
|
||||||
|
*
|
||||||
|
* @param cls closure, typically, the "run" method containing
|
||||||
|
* all the commands to be run, and a closure for it.
|
||||||
|
* @param keys the exchange's keys.
|
||||||
|
* @param compat protocol compatibility information.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TALER_TESTING_cert_cb
|
||||||
|
(void *cls,
|
||||||
|
const struct TALER_EXCHANGE_Keys *keys,
|
||||||
|
enum TALER_EXCHANGE_VersionCompatibility compat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the exchange to have started. Waits for at
|
* Wait for the exchange to have started. Waits for at
|
||||||
* most 10s, after that returns 77 to indicate an error.
|
* most 10s, after that returns 77 to indicate an error.
|
||||||
@ -1477,6 +1492,14 @@ TALER_TESTING_cmd_batch (const char *label,
|
|||||||
int
|
int
|
||||||
TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd);
|
TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advance internal pointer to next command.
|
||||||
|
*
|
||||||
|
* @param is interpreter state.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TALER_TESTING_cmd_batch_next
|
||||||
|
(struct TALER_TESTING_Interpreter *is);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain what command the batch is at.
|
* Obtain what command the batch is at.
|
||||||
|
@ -175,16 +175,7 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
|
|||||||
if (GNUNET_SYSERR == is->result)
|
if (GNUNET_SYSERR == is->result)
|
||||||
return; /* ignore, we already failled! */
|
return; /* ignore, we already failled! */
|
||||||
if (TALER_TESTING_cmd_is_batch (cmd))
|
if (TALER_TESTING_cmd_is_batch (cmd))
|
||||||
{
|
TALER_TESTING_cmd_batch_next (is);
|
||||||
#define CURRENT_BATCH_SUBCMD_INDEX 0
|
|
||||||
struct TALER_TESTING_Command *sub_cmd;
|
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_cmd
|
|
||||||
(cmd, CURRENT_BATCH_SUBCMD_INDEX, &sub_cmd));
|
|
||||||
|
|
||||||
if (NULL == sub_cmd->label)
|
|
||||||
is->ip++;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
is->ip++;
|
is->ip++;
|
||||||
if (0 == (ipc % 1000))
|
if (0 == (ipc % 1000))
|
||||||
@ -310,9 +301,12 @@ do_shutdown (void *cls)
|
|||||||
"Executing shutdown at `%s'\n",
|
"Executing shutdown at `%s'\n",
|
||||||
label);
|
label);
|
||||||
|
|
||||||
for (unsigned int j=0;NULL != (cmd = &is->commands[j])->label;j++)
|
for (unsigned int j=0;
|
||||||
|
NULL != (cmd = &is->commands[j])->label;
|
||||||
|
j++)
|
||||||
cmd->cleanup (cmd->cls,
|
cmd->cleanup (cmd->cls,
|
||||||
cmd);
|
cmd);
|
||||||
|
|
||||||
if (NULL != is->exchange)
|
if (NULL != is->exchange)
|
||||||
{
|
{
|
||||||
TALER_EXCHANGE_disconnect (is->exchange);
|
TALER_EXCHANGE_disconnect (is->exchange);
|
||||||
@ -585,26 +579,17 @@ sighandler_child_death ()
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called once a connection to the exchange has been
|
* "Canonical" cert_cb used when we are connecting to the
|
||||||
* established.
|
* Exchange.
|
||||||
*
|
|
||||||
* Do:
|
|
||||||
*
|
|
||||||
* recognized states:
|
|
||||||
* got NULL for keys, or not.
|
|
||||||
* interpreter is running or not.
|
|
||||||
*
|
|
||||||
* in symbols:
|
|
||||||
* !K, K
|
|
||||||
* !IR, IR
|
|
||||||
*
|
*
|
||||||
* @param cls closure, typically, the "run" method containing
|
* @param cls closure, typically, the "run" method containing
|
||||||
* all the commands to be run, and a closure for it.
|
* all the commands to be run, and a closure for it.
|
||||||
* @param keys the exchange's keys.
|
* @param keys the exchange's keys.
|
||||||
* @param compat protocol compatibility information.
|
* @param compat protocol compatibility information.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
cert_cb (void *cls,
|
TALER_TESTING_cert_cb
|
||||||
|
(void *cls,
|
||||||
const struct TALER_EXCHANGE_Keys *keys,
|
const struct TALER_EXCHANGE_Keys *keys,
|
||||||
enum TALER_EXCHANGE_VersionCompatibility compat)
|
enum TALER_EXCHANGE_VersionCompatibility compat)
|
||||||
{
|
{
|
||||||
@ -617,28 +602,27 @@ cert_cb (void *cls,
|
|||||||
{
|
{
|
||||||
GNUNET_log
|
GNUNET_log
|
||||||
(GNUNET_ERROR_TYPE_WARNING,
|
(GNUNET_ERROR_TYPE_WARNING,
|
||||||
"Got NULL response for /keys during startup, retrying!\n");
|
"Got NULL response for /keys"
|
||||||
|
" during startup, retrying!\n");
|
||||||
TALER_EXCHANGE_disconnect (is->exchange);
|
TALER_EXCHANGE_disconnect (is->exchange);
|
||||||
GNUNET_assert
|
GNUNET_assert
|
||||||
(NULL != (is->exchange = TALER_EXCHANGE_connect
|
(NULL != (is->exchange = TALER_EXCHANGE_connect
|
||||||
(is->ctx,
|
(is->ctx,
|
||||||
main_ctx->exchange_url,
|
main_ctx->exchange_url,
|
||||||
&cert_cb,
|
&TALER_TESTING_cert_cb,
|
||||||
main_ctx,
|
main_ctx,
|
||||||
TALER_EXCHANGE_OPTION_END)));
|
TALER_EXCHANGE_OPTION_END)));
|
||||||
// !K && !IR
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// !K && IR
|
|
||||||
GNUNET_log
|
GNUNET_log
|
||||||
(GNUNET_ERROR_TYPE_ERROR,
|
(GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Got NULL response for /keys during execution!\n");
|
"Got NULL response for /keys"
|
||||||
|
" during execution!\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// K && ?IR
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Got %d DK from /keys\n",
|
"Got %d DK from /keys\n",
|
||||||
keys->num_denom_keys);
|
keys->num_denom_keys);
|
||||||
@ -649,7 +633,6 @@ cert_cb (void *cls,
|
|||||||
/* /keys has been called for some reason and
|
/* /keys has been called for some reason and
|
||||||
* the interpreter is already running. */
|
* the interpreter is already running. */
|
||||||
if (GNUNET_YES == is->working)
|
if (GNUNET_YES == is->working)
|
||||||
// ?K && IR
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
is->working = GNUNET_YES;
|
is->working = GNUNET_YES;
|
||||||
@ -659,15 +642,15 @@ cert_cb (void *cls,
|
|||||||
{
|
{
|
||||||
main_ctx->main_cb (main_ctx->main_cb_cls,
|
main_ctx->main_cb (main_ctx->main_cb_cls,
|
||||||
is);
|
is);
|
||||||
// ?IR && ?K
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tests already started, just trigger the
|
/* Tests already started, just trigger the
|
||||||
* next command. */
|
* next command. */
|
||||||
|
TALER_LOG_DEBUG ("Cert_cb, scheduling CMD (ip: %d)\n",
|
||||||
|
is->ip);
|
||||||
GNUNET_SCHEDULER_add_now (&interpreter_run,
|
GNUNET_SCHEDULER_add_now (&interpreter_run,
|
||||||
is);
|
is);
|
||||||
// IR && ?K
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -719,7 +702,8 @@ do_abort (void *cls)
|
|||||||
* @param cfg configuration to use
|
* @param cfg configuration to use
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
main_exchange_connect_with_cfg (void *cls,
|
main_exchange_connect_with_cfg
|
||||||
|
(void *cls,
|
||||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||||
{
|
{
|
||||||
struct MainContext *main_ctx = cls;
|
struct MainContext *main_ctx = cls;
|
||||||
@ -741,10 +725,11 @@ main_exchange_connect_with_cfg (void *cls,
|
|||||||
is->cfg = cfg;
|
is->cfg = cfg;
|
||||||
is->timeout_task = GNUNET_SCHEDULER_add_shutdown (&do_abort,
|
is->timeout_task = GNUNET_SCHEDULER_add_shutdown (&do_abort,
|
||||||
main_ctx);
|
main_ctx);
|
||||||
GNUNET_break (NULL !=
|
GNUNET_break
|
||||||
(is->exchange = TALER_EXCHANGE_connect (is->ctx,
|
(NULL != (is->exchange = TALER_EXCHANGE_connect
|
||||||
|
(is->ctx,
|
||||||
exchange_url,
|
exchange_url,
|
||||||
&cert_cb,
|
&TALER_TESTING_cert_cb,
|
||||||
main_ctx,
|
main_ctx,
|
||||||
TALER_EXCHANGE_OPTION_END)));
|
TALER_EXCHANGE_OPTION_END)));
|
||||||
is->cfg = NULL;
|
is->cfg = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user