adding separate test just for /verison API

This commit is contained in:
Christian Grothoff 2019-01-24 18:46:49 +01:00
commit 531b61cd43
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
11 changed files with 82 additions and 74 deletions

View File

@ -97,11 +97,11 @@ check_PROGRAMS += \
test_bank_api_with_fakebank_twisted_SOURCES = \ test_bank_api_with_fakebank_twisted_SOURCES = \
test_bank_api_with_fakebank_twisted.c test_bank_api_with_fakebank_twisted.c
test_bank_api_with_fakebank_twisted_LDADD = \ test_bank_api_with_fakebank_twisted_LDADD = \
$(top_builddir)/src/exchange-lib/libtalertesting.la \ $(top_builddir)/src/lib/libtalertesting.la \
libtalerbank.la \ libtalerbank.la \
libtalerbanktesting.la \ libtalerbanktesting.la \
libtalerfakebank.la \ libtalerfakebank.la \
$(top_builddir)/src/exchange-lib/libtalerexchange.la \ $(top_builddir)/src/lib/libtalerexchange.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
-ltalertwistertesting \ -ltalertwistertesting \
-lgnunetjson \ -lgnunetjson \
@ -113,11 +113,11 @@ endif
test_bank_api_twisted_SOURCES = \ test_bank_api_twisted_SOURCES = \
test_bank_api_twisted.c test_bank_api_twisted.c
test_bank_api_twisted_LDADD = \ test_bank_api_twisted_LDADD = \
$(top_builddir)/src/exchange-lib/libtalertesting.la \ $(top_builddir)/src/lib/libtalertesting.la \
libtalerbank.la \ libtalerbank.la \
libtalerbanktesting.la \ libtalerbanktesting.la \
libtalerfakebank.la \ libtalerfakebank.la \
$(top_builddir)/src/exchange-lib/libtalerexchange.la \ $(top_builddir)/src/lib/libtalerexchange.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
-ltalertwistertesting \ -ltalertwistertesting \
-lgnunetjson \ -lgnunetjson \
@ -143,7 +143,7 @@ test_bank_api_new_SOURCES = \
test_bank_api_new.c test_bank_api_new.c
test_bank_api_new_LDADD = \ test_bank_api_new_LDADD = \
$(top_builddir)/src/exchange-lib/libtalertesting.la \ $(top_builddir)/src/lib/libtalertesting.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
libtalerbanktesting.la \ libtalerbanktesting.la \
-ltalerexchange \ -ltalerexchange \
@ -165,7 +165,7 @@ test_bank_api_with_fakebank_new_SOURCES = \
test_bank_api_with_fakebank_new.c test_bank_api_with_fakebank_new.c
test_bank_api_with_fakebank_new_LDADD = \ test_bank_api_with_fakebank_new_LDADD = \
$(top_builddir)/src/exchange-lib/libtalertesting.la \ $(top_builddir)/src/lib/libtalertesting.la \
libtalerbanktesting.la \ libtalerbanktesting.la \
-ltalerexchange \ -ltalerexchange \
-lgnunetutil \ -lgnunetutil \

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

@ -156,7 +156,6 @@ endif
check_PROGRAMS = \ check_PROGRAMS = \
test_exchange_api_keys_cherry_picking_new \ test_exchange_api_keys_cherry_picking_new \
test_exchange_api_overlapping_keys_bug \ test_exchange_api_overlapping_keys_bug \
test_exchange_api_interpreter_on-off \
test_exchange_api_new \ test_exchange_api_new \
test_auditor_api_version \ test_auditor_api_version \
test_auditor_api test_auditor_api
@ -202,19 +201,6 @@ test_exchange_api_new_LDADD = \
-lgnunetutil \ -lgnunetutil \
-ljansson -ljansson
test_exchange_api_interpreter_on_off_SOURCES = \
test_exchange_api_interpreter_on-off.c
test_exchange_api_interpreter_on_off_LDADD = \
libtalertesting.la \
libtalerexchange.la \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/bank-lib/libtalerbank.la \
-lgnunetcurl \
-lgnunetutil \
-ljansson
test_exchange_api_overlapping_keys_bug_SOURCES = \ test_exchange_api_overlapping_keys_bug_SOURCES = \
test_exchange_api_overlapping_keys_bug.c test_exchange_api_overlapping_keys_bug.c
test_exchange_api_overlapping_keys_bug_LDADD = \ test_exchange_api_overlapping_keys_bug_LDADD = \

View File

@ -259,7 +259,6 @@ decode_version_json (const json_t *resp_obj,
return GNUNET_OK; return GNUNET_OK;
} }
/** /**
* Initiate download of /version from the auditor. * Initiate download of /version from the auditor.
* *
@ -308,6 +307,7 @@ version_completed_cb (void *cls,
if (NULL == resp_obj) if (NULL == resp_obj)
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
TALER_LOG_WARNING ("NULL body for a 200-OK /version\n");
response_code = 0; response_code = 0;
break; break;
} }
@ -348,6 +348,7 @@ version_completed_cb (void *cls,
auditor->vr = NULL; auditor->vr = NULL;
free_version_request (vr); free_version_request (vr);
TALER_LOG_DEBUG ("Switching auditor state to 'version'\n");
auditor->state = MHS_VERSION; auditor->state = MHS_VERSION;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Auditor %p is now READY!\n", "Auditor %p is now READY!\n",

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);
@ -719,6 +724,50 @@ update_auditors (struct TALER_EXCHANGE_Handle *exchange)
} }
} }
/**
* Compare two denomination keys.
*
* @param denoma first denomination key
* @param denomb second denomination key
* @return 0 if the two keys are equal (not necessarily
* the same object), 1 otherwise.
*/
unsigned int
TALER_denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1,
struct TALER_EXCHANGE_DenomPublicKey *denom2)
{
struct GNUNET_CRYPTO_RsaPublicKey *tmp1;
struct GNUNET_CRYPTO_RsaPublicKey *tmp2;
/* First check if pub is the same. */
if (0 != GNUNET_CRYPTO_rsa_public_key_cmp
(denom1->key.rsa_public_key,
denom2->key.rsa_public_key))
return 1;
tmp1 = denom1->key.rsa_public_key;
tmp2 = denom2->key.rsa_public_key;
denom1->key.rsa_public_key = NULL;
denom2->key.rsa_public_key = NULL;
/* Then procede with the rest of the object. */
if (0 != memcmp (denom1,
denom2,
sizeof (struct TALER_EXCHANGE_DenomPublicKey)))
{
denom1->key.rsa_public_key = tmp1;
denom2->key.rsa_public_key = tmp2;
return 1;
}
denom1->key.rsa_public_key = tmp1;
denom2->key.rsa_public_key = tmp2;
return 0;
}
/** /**
* Decode the JSON in @a resp_obj from the /keys response * Decode the JSON in @a resp_obj from the /keys response
@ -857,7 +906,7 @@ decode_keys_json (const json_t *resp_obj,
index = 0; index = 0;
json_array_foreach (denom_keys_array, index, denom_key_obj) { json_array_foreach (denom_keys_array, index, denom_key_obj) {
struct TALER_EXCHANGE_DenomPublicKey dk; struct TALER_EXCHANGE_DenomPublicKey dk;
bool found = false; int found = GNUNET_NO;
EXITIF (GNUNET_SYSERR == EXITIF (GNUNET_SYSERR ==
parse_json_denomkey (&dk, parse_json_denomkey (&dk,
@ -865,17 +914,19 @@ decode_keys_json (const json_t *resp_obj,
denom_key_obj, denom_key_obj,
&key_data->master_pub, &key_data->master_pub,
hash_context)); hash_context));
for (unsigned int j=0;j<key_data->num_denom_keys;j++)
for (unsigned int j=0;
j<key_data->num_denom_keys;
j++)
{ {
if (0 == memcmp (&dk, if (0 == TALER_denoms_cmp (&dk,
&key_data->denom_keys[j], &key_data->denom_keys[j]))
sizeof (dk)))
{ {
found = true; found = GNUNET_YES;
break; break;
} }
} }
if (found) if (GNUNET_YES == found)
{ {
/* 0:0:0 did not support /keys cherry picking */ /* 0:0:0 did not support /keys cherry picking */
GNUNET_break_op (0 == current); GNUNET_break_op (0 == current);
@ -910,7 +961,7 @@ decode_keys_json (const json_t *resp_obj,
index = 0; index = 0;
json_array_foreach (auditors_array, index, auditor_info) { json_array_foreach (auditors_array, index, auditor_info) {
struct TALER_EXCHANGE_AuditorInformation ai; struct TALER_EXCHANGE_AuditorInformation ai;
bool found = false; int found = GNUNET_NO;
memset (&ai, memset (&ai,
0, 0,
@ -928,7 +979,7 @@ decode_keys_json (const json_t *resp_obj,
&aix->auditor_pub, &aix->auditor_pub,
sizeof (struct TALER_AuditorPublicKeyP))) sizeof (struct TALER_AuditorPublicKeyP)))
{ {
found = true; found = GNUNET_YES;
/* Merge denomination key signatures of downloaded /keys into existing /* Merge denomination key signatures of downloaded /keys into existing
auditor information 'aix'. */ auditor information 'aix'. */
GNUNET_array_grow (aix->denom_keys, GNUNET_array_grow (aix->denom_keys,
@ -940,7 +991,7 @@ decode_keys_json (const json_t *resp_obj,
break; break;
} }
} }
if (found) if (GNUNET_YES == found)
continue; /* we are done */ continue; /* we are done */
if (key_data->auditors_size == key_data->num_auditors) if (key_data->auditors_size == key_data->num_auditors)
GNUNET_array_grow (key_data->auditors, GNUNET_array_grow (key_data->auditors,
@ -1077,7 +1128,6 @@ TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
return GNUNET_TIME_UNIT_ZERO_ABS; return GNUNET_TIME_UNIT_ZERO_ABS;
} }
/** /**
* Callback used when downloading the reply to a /keys request * Callback used when downloading the reply to a /keys request
* is complete. * is complete.
@ -1136,6 +1186,7 @@ keys_completed_cb (void *cls,
memcpy (kd.denom_keys, memcpy (kd.denom_keys,
kd_old.denom_keys, kd_old.denom_keys,
kd_old.num_denom_keys * sizeof (struct TALER_EXCHANGE_DenomPublicKey)); kd_old.num_denom_keys * sizeof (struct TALER_EXCHANGE_DenomPublicKey));
for (unsigned int i=0;i<kd_old.num_denom_keys;i++) for (unsigned int i=0;i<kd_old.num_denom_keys;i++)
kd.denom_keys[i].key.rsa_public_key kd.denom_keys[i].key.rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_dup (kd_old.denom_keys[i].key.rsa_public_key); = GNUNET_CRYPTO_rsa_public_key_dup (kd_old.denom_keys[i].key.rsa_public_key);
@ -1160,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,
@ -1682,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,7 @@ run (void *cls,
}; };
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
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",

View File

@ -2,4 +2,4 @@
[exchange] [exchange]
# Lengthen over firstly extended value (100 s) # Lengthen over firstly extended value (100 s)
LOOKAHEAD_SIGN = 1500 s LOOKAHEAD_SIGN = 3500 s

View File

@ -113,7 +113,7 @@ run (void *cls,
*/ */
TALER_TESTING_cmd_check_keys ("check-freshest-keys", TALER_TESTING_cmd_check_keys ("check-freshest-keys",
8, 8,
8), 10),
TALER_TESTING_cmd_wire ("verify-/wire-with-fresh-keys", TALER_TESTING_cmd_wire ("verify-/wire-with-fresh-keys",
"x-taler-bank", "x-taler-bank",

View File

@ -93,8 +93,8 @@ run (void *cls,
/* Causes GET /keys?last_denom_issue=0 */ /* Causes GET /keys?last_denom_issue=0 */
TALER_TESTING_cmd_check_keys_with_last_denom ("second-download", TALER_TESTING_cmd_check_keys_with_last_denom ("second-download",
2, 3,
8, 4,
GNUNET_TIME_UNIT_ZERO_ABS), GNUNET_TIME_UNIT_ZERO_ABS),
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);