diff options
author | David Goulet <dgoulet@torproject.org> | 2017-09-01 16:18:50 -0400 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2017-09-07 18:16:07 +0300 |
commit | 72c7f81459e087e2a0485361eb34db1023d12155 (patch) | |
tree | d8f01ee1d12860ac5cff8f90fcaa93df7359265f /src/test/test_hs_service.c | |
parent | f117da3ea006fbdda3f5e921d5f8da2ae3d3bdfd (diff) | |
download | tor-72c7f81459e087e2a0485361eb34db1023d12155.tar.gz tor-72c7f81459e087e2a0485361eb34db1023d12155.zip |
prop224: When computing hsdir index and time period, use valid_after time
Use the valid_after time from the consensus to get the time period number else
we might get out of sync with the overlap period that uses valid_after.
Make it an optional feature since some functions require passing a
specific time (like hs_get_start_time_of_next_time_period()).
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_hs_service.c')
-rw-r--r-- | src/test/test_hs_service.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index 4c7880c0ee..357fade049 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -1043,8 +1043,6 @@ test_build_update_descriptors(void *arg) { int ret; time_t now = time(NULL); - uint64_t period_num = hs_get_time_period_num(now); - uint64_t next_period_num = hs_get_next_time_period_num(now); node_t *node; hs_service_t *service; hs_service_intro_point_t *ip_cur, *ip_next; @@ -1055,9 +1053,20 @@ test_build_update_descriptors(void *arg) MOCK(hs_overlap_mode_is_active, mock_hs_overlap_mode_is_active_true); MOCK(get_or_state, get_or_state_replacement); + MOCK(networkstatus_get_live_consensus, + mock_networkstatus_get_live_consensus); dummy_state = tor_malloc_zero(sizeof(or_state_t)); + ret = parse_rfc1123_time("Sat, 26 Oct 1985 13:00:00 UTC", + &mock_ns.valid_after); + ret = parse_rfc1123_time("Sat, 26 Oct 1985 14:00:00 UTC", + &mock_ns.fresh_until); + tt_int_op(ret, OP_EQ, 0); + + uint64_t period_num = hs_get_time_period_num(0); + uint64_t next_period_num = hs_get_next_time_period_num(0); + /* Create a service without a current descriptor to trigger a build. */ service = hs_service_new(get_options()); tt_assert(service); @@ -1203,8 +1212,17 @@ test_upload_descriptors(void *arg) MOCK(hs_overlap_mode_is_active, mock_hs_overlap_mode_is_active_true); MOCK(get_or_state, get_or_state_replacement); + MOCK(networkstatus_get_live_consensus, + mock_networkstatus_get_live_consensus); + dummy_state = tor_malloc_zero(sizeof(or_state_t)); + ret = parse_rfc1123_time("Sat, 26 Oct 1985 13:00:00 UTC", + &mock_ns.valid_after); + ret = parse_rfc1123_time("Sat, 26 Oct 1985 14:00:00 UTC", + &mock_ns.fresh_until); + tt_int_op(ret, OP_EQ, 0); + /* Create a service with no descriptor. It's added to the global map. */ service = hs_service_new(get_options()); tt_assert(service); |