From ba4ded3d6e038096c9a0ad6b32546716c418110a Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Thu, 11 Apr 2019 17:42:58 +0200 Subject: Re-enabling keys serialization test. --- src/lib/exchange_api_handle.c | 27 +++++---- .../test_exchange_api_keys_cherry_picking_new.c | 64 +++++++--------------- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index e0a6f6b71..8dbf2b5d8 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1570,9 +1570,10 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange, /** - * Serialize the latest key data from @a exchange to be persisted on - * disk (to be used with #TALER_EXCHANGE_OPTION_DATA to more - * efficiently recover the state). + * Serialize the latest key data from @a + * exchange to be persisted on disk (to be used with + * #TALER_EXCHANGE_OPTION_DATA to more efficiently recover + * the state). * * @param exchange which exchange's key and wire data should be * serialized @@ -1580,7 +1581,8 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange, * otherwise JSON object owned by the caller */ json_t * -TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) +TALER_EXCHANGE_serialize_data + (struct TALER_EXCHANGE_Handle *exchange) { const struct TALER_EXCHANGE_Keys *kd = &exchange->key_data; struct GNUNET_TIME_Absolute now; @@ -1600,15 +1602,20 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) continue; /* skip keys that have expired */ signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", "key", - GNUNET_JSON_from_data_auto (&sk->key), + GNUNET_JSON_from_data_auto + (&sk->key), "master_sig", - GNUNET_JSON_from_data_auto (&sk->master_sig), + GNUNET_JSON_from_data_auto + (&sk->master_sig), "stamp_start", - GNUNET_JSON_from_time_abs (sk->valid_from), + GNUNET_JSON_from_time_abs + (sk->valid_from), "stamp_expire", - GNUNET_JSON_from_time_abs (sk->valid_until), + GNUNET_JSON_from_time_abs + (sk->valid_until), "stamp_end", - GNUNET_JSON_from_time_abs (sk->valid_legal)); + GNUNET_JSON_from_time_abs + (sk->valid_legal)); if (NULL == signkey) { GNUNET_break (0); @@ -1839,7 +1846,7 @@ request_keys (void *cls) if (GNUNET_YES == exchange->with_now) { - TALER_LOG_DEBUG ("Faking now to GET /keys): %s\n", + TALER_LOG_DEBUG ("Faking now to GET /keys: %s\n", GNUNET_STRINGS_absolute_time_to_string (exchange->now)); sprintf (&url[strlen (url)], "now=%llu&", diff --git a/src/lib/test_exchange_api_keys_cherry_picking_new.c b/src/lib/test_exchange_api_keys_cherry_picking_new.c index 490961f8a..e9763bd4f 100644 --- a/src/lib/test_exchange_api_keys_cherry_picking_new.c +++ b/src/lib/test_exchange_api_keys_cherry_picking_new.c @@ -54,6 +54,9 @@ #define CONFIG_FILE_EXTENDED_2 \ "test_exchange_api_keys_cherry_picking_extended_2.conf" + +#define NDKS_RIGHT_BEFORE_SERIALIZATION 46 + /** * Add seconds. * @@ -128,52 +131,28 @@ run (void *cls, TALER_TESTING_cmd_connect_with_state ("reconnect-with-state", "serialize-keys"), - + /** + * Make sure we have the same keys situation as + * it was before the serialization. + */ + TALER_TESTING_cmd_check_keys_with_now + ("check-keys-after-deserialization", + 4, + NDKS_RIGHT_BEFORE_SERIALIZATION, + /** + * Pretend 5 seconds passed. + */ + ADDSECS (TTH_parse_time (JAN2030), + 5)), + /** + * Use one of the deserialized keys. + */ TALER_TESTING_cmd_wire ("verify-/wire-with-serialized-keys", "x-taler-bank", NULL, MHD_HTTP_OK), - /** - * This loads a very big lookahead_sign (3500s). - */ - TALER_TESTING_cmd_exec_keyup - ("keyup-serialization", - CONFIG_FILE_EXTENDED_2), - - #if 0 - - FIXME: #5672 - - The test below fails on different systems. Infact, different - systems can generate different "anchors" values for their - denoms, therefore the fixed value required by the test below - (45) is condemned to fail. - - However, this seems to happen only when very big values are - used for the "lookahead_sign" value. Here we use 3500 seconds, - and the test breaks. - - A reasonable fix is to allow for some slack in the number of - the expected keys. - - TALER_TESTING_cmd_check_keys ("check-freshest-keys", - /* At this point, /keys has been - * downloaded roughly 6 times, so by - * forcing 10 here we make sure we get - * all the new ones. */ - 10, - /* We use a very high number here to make - * sure the "big" lookahead value got - * respected. */ - 45), - #endif - TALER_TESTING_cmd_wire ("verify-/wire-with-fresh-keys", - "x-taler-bank", - NULL, - MHD_HTTP_OK), - TALER_TESTING_cmd_end (), }; @@ -233,10 +212,11 @@ run (void *cls, * ---- * 46 */ + TALER_TESTING_cmd_check_keys_with_now ("check-keys-3", 3, - 46, + NDKS_RIGHT_BEFORE_SERIALIZATION, TTH_parse_time (JAN2030)), TALER_TESTING_cmd_end () @@ -245,10 +225,8 @@ run (void *cls, TALER_TESTING_cmd_batch ("ordinary-cherry-pick", ordinary_cherry_pick), - /* TALER_TESTING_cmd_batch ("keys-serialization", keys_serialization), - */ TALER_TESTING_cmd_end () }; -- cgit v1.2.3