prop224: Refactor the overlap function to not use absolute time.

We consider to be in overlap mode when we are in the period of time between a
fresh SRV and the beginning of the new time period (in the normal network this
is between 00:00 and 12:00 UTC). This commit edits that function to use the
above semantic logic instead of absolute times.

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
George Kadianakis
2017-07-18 16:06:12 +03:00
committed by Nick Mathewson
parent 6c00bd1f10
commit 2e5a2d64bd
3 changed files with 86 additions and 11 deletions
+6
View File
@@ -936,6 +936,8 @@ test_rotate_descriptors(void *arg)
* overlap check doesn't care about the year. */
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 a default descriptor and state. It's added to the
@@ -954,6 +956,8 @@ test_rotate_descriptors(void *arg)
/* Entering an overlap period. */
ret = parse_rfc1123_time("Sat, 26 Oct 1985 01:00:00 UTC",
&mock_ns.valid_after);
ret = parse_rfc1123_time("Sat, 26 Oct 1985 02:00:00 UTC",
&mock_ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
desc_next = service_descriptor_new();
desc_next->next_upload_time = 42; /* Our marker to recognize it. */
@@ -977,6 +981,8 @@ test_rotate_descriptors(void *arg)
/* Going out of the overlap period. */
ret = parse_rfc1123_time("Sat, 26 Oct 1985 12:00:00 UTC",
&mock_ns.valid_after);
ret = parse_rfc1123_time("Sat, 26 Oct 1985 13:00:00 UTC",
&mock_ns.fresh_until);
/* This should reset the state and not touch the current descriptor. */
tt_int_op(ret, OP_EQ, 0);
rotate_all_descriptors(now);