Auditor tests.

Fix double connection.
This commit is contained in:
Marcello Stanisci 2019-01-24 17:53:10 +01:00
parent 16002d2078
commit 862ed50d7d
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
6 changed files with 19 additions and 38 deletions

View File

@ -369,12 +369,6 @@ struct TALER_TESTING_Interpreter
*/ */
int working; int working;
/**
* Is the auditor running (#GNUNET_YES) or waiting
* for /version (#GNUNET_NO)?
*/
int auditor_working;
/** /**
* How often have we gotten a /keys response so far? * How often have we gotten a /keys response so far?
*/ */

View File

@ -447,6 +447,9 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
{ {
struct TALER_AUDITOR_Handle *auditor; struct TALER_AUDITOR_Handle *auditor;
TALER_LOG_DEBUG ("Connecting to the auditor (%s)\n",
url);
auditor = GNUNET_new (struct TALER_AUDITOR_Handle); auditor = GNUNET_new (struct TALER_AUDITOR_Handle);
auditor->ctx = ctx; auditor->ctx = ctx;
auditor->url = GNUNET_strdup (url); auditor->url = GNUNET_strdup (url);

View File

@ -685,8 +685,11 @@ update_auditors (struct TALER_EXCHANGE_Handle *exchange)
{ {
struct TALER_EXCHANGE_Keys *kd = &exchange->key_data; struct TALER_EXCHANGE_Keys *kd = &exchange->key_data;
TALER_LOG_DEBUG ("Updating auditors\n");
for (unsigned int i=0;i<kd->num_auditors;i++) for (unsigned int i=0;i<kd->num_auditors;i++)
{ {
/* Compare auditor data from /keys with auditor data
* from owned exchange structures. */
struct TALER_EXCHANGE_AuditorInformation *auditor = &kd->auditors[i]; struct TALER_EXCHANGE_AuditorInformation *auditor = &kd->auditors[i];
struct TEAH_AuditorListEntry *ale = NULL; struct TEAH_AuditorListEntry *ale = NULL;
@ -704,7 +707,9 @@ update_auditors (struct TALER_EXCHANGE_Handle *exchange)
} }
if (NULL != ale) if (NULL != ale)
continue; /* found, no need to add */ continue; /* found, no need to add */
/* new auditor, add */ /* new auditor, add */
TALER_LOG_DEBUG ("Found new auditor!\n");
ale = GNUNET_new (struct TEAH_AuditorListEntry); ale = GNUNET_new (struct TEAH_AuditorListEntry);
ale->auditor_pub = auditor->auditor_pub; ale->auditor_pub = auditor->auditor_pub;
ale->auditor_url = GNUNET_strdup (auditor->auditor_url); ale->auditor_url = GNUNET_strdup (auditor->auditor_url);
@ -1206,6 +1211,7 @@ keys_completed_cb (void *cls,
aold->num_denom_keys * sizeof (struct TALER_EXCHANGE_AuditorDenominationInfo)); aold->num_denom_keys * sizeof (struct TALER_EXCHANGE_AuditorDenominationInfo));
} }
/* Old auditors got just copied into new ones. */
if (GNUNET_OK != if (GNUNET_OK !=
decode_keys_json (j, decode_keys_json (j,
GNUNET_YES, GNUNET_YES,
@ -1728,6 +1734,9 @@ TALER_EXCHANGE_connect
va_list ap; va_list ap;
enum TALER_EXCHANGE_Option opt; enum TALER_EXCHANGE_Option opt;
TALER_LOG_DEBUG ("Connecting to the exchange (%s)\n",
url);
exchange = GNUNET_new (struct TALER_EXCHANGE_Handle); exchange = GNUNET_new (struct TALER_EXCHANGE_Handle);
exchange->ctx = ctx; exchange->ctx = ctx;
exchange->url = GNUNET_strdup (url); exchange->url = GNUNET_strdup (url);

View File

@ -471,6 +471,8 @@ run (void *cls,
}; };
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
#if 0
CMD_RUN_AUDITOR("virgin-auditor"), CMD_RUN_AUDITOR("virgin-auditor"),
CMD_RUN_WIRE_AUDITOR("virgin-wire-auditor"), CMD_RUN_WIRE_AUDITOR("virgin-wire-auditor"),
TALER_TESTING_cmd_batch ("withdraw", TALER_TESTING_cmd_batch ("withdraw",
@ -489,6 +491,8 @@ run (void *cls,
payback), payback),
CMD_RUN_AUDITOR("normal-auditor"), CMD_RUN_AUDITOR("normal-auditor"),
CMD_RUN_WIRE_AUDITOR("normal-wire-auditor"), CMD_RUN_WIRE_AUDITOR("normal-wire-auditor"),
#endif
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };

View File

@ -309,6 +309,7 @@ do_shutdown (void *cls)
if (NULL != is->exchange) if (NULL != is->exchange)
{ {
TALER_LOG_DEBUG ("Disconnecting the exchange\n");
TALER_EXCHANGE_disconnect (is->exchange); TALER_EXCHANGE_disconnect (is->exchange);
is->exchange = NULL; is->exchange = NULL;
} }

View File

@ -70,28 +70,6 @@ cleanup_auditor (void *cls)
GNUNET_free (cc); GNUNET_free (cc);
} }
/**
* Function called with information about the auditor.
*
* @param cls closure
* @param vi basic information about the auditor
* @param compat protocol compatibility information
*/
static void
auditor_version_cb (void *cls,
const struct TALER_AUDITOR_VersionInformation *vi,
enum TALER_AUDITOR_VersionCompatibility compat)
{
struct TALER_TESTING_Interpreter *is = cls;
/* TODO: check vi/compat? */
is->auditor_working = GNUNET_YES;
}
/** /**
* Closure for #auditor_main_wrapper() * Closure for #auditor_main_wrapper()
*/ */
@ -145,21 +123,13 @@ auditor_main_wrapper (void *cls,
"BASE_URL"); "BASE_URL");
return; return;
} }
is->auditor = TALER_AUDITOR_connect (is->ctx,
auditor_base_url,
&auditor_version_cb,
is);
GNUNET_free (auditor_base_url); GNUNET_free (auditor_base_url);
if (NULL == is->auditor)
{
GNUNET_break (0);
return;
}
cc = GNUNET_new (struct CleanupContext); cc = GNUNET_new (struct CleanupContext);
cc->is = is; cc->is = is;
cc->fcb = is->final_cleanup_cb; cc->fcb = is->final_cleanup_cb;
cc->fcb_cls = is->final_cleanup_cb; cc->fcb_cls = is->final_cleanup_cb;
is->final_cleanup_cb = &cleanup_auditor; is->final_cleanup_cb = NULL;
is->final_cleanup_cb_cls = cc; is->final_cleanup_cb_cls = cc;
mwc->main_cb (mwc->main_cb_cls, mwc->main_cb (mwc->main_cb_cls,
is); is);