aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_service.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-08-24 16:17:26 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2017-08-25 14:41:06 +0300
commitc980be951157b68e6bd658ce01850e96ce97d422 (patch)
treebb4a27b22019fa2292ea91bd86b45ab67e3a7155 /src/test/test_hs_service.c
parent8b8e39e04b365eefd7d69a488c04405cd6371645 (diff)
downloadtor-c980be951157b68e6bd658ce01850e96ce97d422.tar.gz
tor-c980be951157b68e6bd658ce01850e96ce97d422.zip
prop224: Refactor descriptor reupload logic.
We refactor the descriptor reupload logic to be similar to the v2 logic where we update a global 'consider_republishing_rend_descriptors' flag and then we use that to check for hash ring changes during the global hidden service callbacks. This fixes bugs where we would inspect the hash ring immediately as we receive new dirinfo (e.g. consensus) but before running the hidden service housekeeping events. That was leaving us in an inconsistent state wrt hsdir indices and causing bugs all around.
Diffstat (limited to 'src/test/test_hs_service.c')
-rw-r--r--src/test/test_hs_service.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index cf1c36a528..4c7880c0ee 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -1005,6 +1005,13 @@ test_rotate_descriptors(void *arg)
OP_EQ, 0);
tt_assert(service->desc_next == NULL);
+ /* Now let's re-create desc_next and get out of overlap period. We should
+ test that desc_current gets replaced by desc_next, and desc_next becomes
+ NULL. */
+ desc_next = service_descriptor_new();
+ desc_next->next_upload_time = 240; /* Our marker to recognize it. */
+ service->desc_next = desc_next;
+
/* Going out of the overlap period. */
ret = parse_rfc1123_time("Sat, 26 Oct 1985 12:00:00 UTC",
&mock_ns.valid_after);
@@ -1017,6 +1024,12 @@ test_rotate_descriptors(void *arg)
tt_mem_op(service->desc_current, OP_EQ, desc_next, sizeof(*desc_next));
tt_assert(service->desc_next == NULL);
+ /* Calling rotate_all_descriptors() another time should do nothing */
+ rotate_all_descriptors(now);
+ tt_int_op(service->state.in_overlap_period, OP_EQ, 0);
+ tt_mem_op(service->desc_current, OP_EQ, desc_next, sizeof(*desc_next));
+ tt_assert(service->desc_next == NULL);
+
done:
hs_free_all();
UNMOCK(circuit_mark_for_close_);