aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-02-13 15:32:13 +0200
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:33 -0400
commitf53b72baf7472423f662b49bebde1a88727901fb (patch)
tree72e59b442c505ed5dc9d8f3b518906d898037747 /src/test
parent0f104ddce578c52d604931c595b28aa61a184b40 (diff)
downloadtor-f53b72baf7472423f662b49bebde1a88727901fb.tar.gz
tor-f53b72baf7472423f662b49bebde1a88727901fb.zip
prop224: Add descriptor overlap mode function
The function has been added but not used except for the unit tests. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_hs_service.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 174d07f488..fe4ce42336 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -553,6 +553,53 @@ test_access_service(void *arg)
hs_free_all();
}
+/** Test that our HS overlap period functions work properly. */
+static void
+test_desc_overlap_period(void *arg)
+{
+ (void) arg;
+ int retval;
+ time_t now = time(NULL);
+ networkstatus_t *dummy_consensus = NULL;
+
+ /* First try with a consensus inside the overlap period */
+ dummy_consensus = tor_malloc_zero(sizeof(networkstatus_t));
+ retval = parse_rfc1123_time("Wed, 13 Apr 2016 10:00:00 UTC",
+ &dummy_consensus->valid_after);
+ tt_int_op(retval, ==, 0);
+
+ retval = hs_overlap_mode_is_active(dummy_consensus, now);
+ tt_int_op(retval, ==, 1);
+
+ /* Now increase the valid_after so that it goes to 11:00:00 UTC. Overlap
+ period is still active. */
+ dummy_consensus->valid_after += 3600;
+ retval = hs_overlap_mode_is_active(dummy_consensus, now);
+ tt_int_op(retval, ==, 1);
+
+ /* Now increase the valid_after so that it goes to 11:59:59 UTC. Overlap
+ period is still active. */
+ dummy_consensus->valid_after += 3599;
+ retval = hs_overlap_mode_is_active(dummy_consensus, now);
+ tt_int_op(retval, ==, 1);
+
+ /* Now increase the valid_after so that it drifts to noon, and check that
+ overlap mode is not active anymore. */
+ dummy_consensus->valid_after += 1;
+ retval = hs_overlap_mode_is_active(dummy_consensus, now);
+ tt_int_op(retval, ==, 0);
+
+ /* Check that overlap mode is also inactive at 23:59:59 UTC */
+ retval = parse_rfc1123_time("Wed, 13 Apr 2016 23:59:59 UTC",
+ &dummy_consensus->valid_after);
+ tt_int_op(retval, ==, 0);
+ retval = hs_overlap_mode_is_active(dummy_consensus, now);
+ tt_int_op(retval, ==, 0);
+
+ done:
+ tor_free(dummy_consensus);
+}
+
struct testcase_t hs_service_tests[] = {
{ "gen_establish_intro_cell", test_gen_establish_intro_cell, TT_FORK,
NULL, NULL },
@@ -572,6 +619,8 @@ struct testcase_t hs_service_tests[] = {
NULL, NULL },
{ "access_service", test_access_service, TT_FORK,
NULL, NULL },
+ { "desc_overlap_period", test_desc_overlap_period, TT_FORK,
+ NULL, NULL },
END_OF_TESTCASES
};