From 301f287b2b200ceb1beea50711c6611a3d1f6a2f Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Sat, 6 Apr 2019 20:17:41 +0200 Subject: Test the big lookahead_sign, plus notes. --- src/exchange-tools/taler-exchange-keyup.c | 11 ++- .../test_exchange_api_keys_cherry_picking_new.c | 78 ++++++++++++++++------ 2 files changed, 66 insertions(+), 23 deletions(-) diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index 397355ee7..295eaa276 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -439,12 +439,20 @@ get_anchor (const char *dir, } else if (anchor->abs_value_us != now.abs_value_us) { - /* Real starting time is the last start time + duration - overlap */ + + /** + * XXX-ANCHOR question: why adding the duration only in this + * case, and not _all the times we found a anchor_ ? Like + * for instance out of this block below ? + */ *anchor = GNUNET_TIME_absolute_add (*anchor, duration); *anchor = GNUNET_TIME_absolute_subtract (*anchor, overlap); } + + + /* anchor is now the stamp where we need to create a new key */ } @@ -838,7 +846,6 @@ exchange_keys_update_cointype (void *cls, (GNUNET_TIME_absolute_get_difference (p.anchor, lookahead_sign_stamp), GNUNET_NO)); - dkf = get_cointype_file (&p, p.anchor); GNUNET_break (GNUNET_YES != 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 53173aa63..610083c55 100644 --- a/src/lib/test_exchange_api_keys_cherry_picking_new.c +++ b/src/lib/test_exchange_api_keys_cherry_picking_new.c @@ -113,19 +113,25 @@ run (void *cls, { struct TALER_TESTING_Command keys_serialization[] = { - TALER_TESTING_cmd_serialize_keys ("serialize-keys"), - TALER_TESTING_cmd_connect_with_state ("reconnect-with-state", - "serialize-keys"), + TALER_TESTING_cmd_serialize_keys + ("serialize-keys"), + + TALER_TESTING_cmd_connect_with_state + ("reconnect-with-state", + "serialize-keys"), + + TALER_TESTING_cmd_wire + ("verify-/wire-with-serialized-keys", + "x-taler-bank", + NULL, + MHD_HTTP_OK), - 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), + TALER_TESTING_cmd_exec_keyup + ("keyup-serialization", + CONFIG_FILE_EXTENDED_2), #if 0 @@ -166,10 +172,6 @@ run (void *cls, now = GNUNET_TIME_absolute_get (); struct TALER_TESTING_Command ordinary_cherry_pick[] = { - /* Trigger keys reloading from disk. */ - TALER_TESTING_cmd_signal ("signal-reaction-1", - is->exchanged, - SIGUSR1), /** * 1 DK with 80s withdraw duration, lookahead_sign is 60s * => expect 1 DK. @@ -178,14 +180,20 @@ run (void *cls, 1, /* generation */ 1), /** - * This has a lookahead_sign == 60, and DK withdraw_time == 80 - * => one DK should be created. + * The far-future now will cause "keyup" to start a fresh + * key set. The new KS will have only one key, because the + * current lookahead_sign == 60 seconds and the key's withdraw + * duration is 80 seconds. */ - TALER_TESTING_cmd_exec_keyup_with_now ("keyup-serialization", - CONFIG_FILE, - TTH_parse_time (JAN2030)), + TALER_TESTING_cmd_exec_keyup_with_now + ("keyup-1", + CONFIG_FILE, + TTH_parse_time (JAN2030)), + /** - * Should return 1 key, + the original one = 2. + * Should return 1 new key, + the original one. NOTE: the + * original DK will never be 'cancelled' as for the current + * libtalerexchange logic, so it must always be counted. */ TALER_TESTING_cmd_check_keys_with_now ("check-keys-2", @@ -193,14 +201,42 @@ run (void *cls, 2, TTH_parse_time (JAN2030)), + /** + * We now load a very high lookahead_sign value of 3500 s, + * with now == JAN2030. + */ + TALER_TESTING_cmd_exec_keyup_with_now + ("keyup-3", + CONFIG_FILE_EXTENDED_2, + TTH_parse_time (JAN2030)), + + /** + * For each DK with a withdraw duration of 80 s, and for + * the latest 3500 s lookahead_sign value, we should have + * ((3500 - _80_) / 80) keys we just downloaded + 2 old DK + * keys stored in memory (total 45). The _80_ seconds + * we subtract are from the one key generated at "keyup-1". + * + * This currently fails: look for XXX-ANCHOR at + * taler-exchange-keyup.c to get some insight about the reason + * behind. + */ + TALER_TESTING_cmd_check_keys_with_now + ("check-keys-3", + 3, + 45, + TTH_parse_time (JAN2030)), + TALER_TESTING_cmd_end () }; struct TALER_TESTING_Command commands[] = { TALER_TESTING_cmd_batch ("ordinary-cherry-pick", ordinary_cherry_pick), - /*TALER_TESTING_cmd_batch ("keys-serialization", - keys_serialization),*/ + /* + TALER_TESTING_cmd_batch ("keys-serialization", + keys_serialization), + */ TALER_TESTING_cmd_end () }; -- cgit v1.2.3