summaryrefslogtreecommitdiff
path: root/src/test/test_hs_common.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-08-05 23:43:05 +0300
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:35 -0400
commitbd3213b17e6ff94bfd1c5deb3ecf2d906dd8d0b6 (patch)
treebd77bc9eb533492c0ca867fa2b2f46b6f33dbb76 /src/test/test_hs_common.c
parente70341deb7dd8a8f50b872e9f7f999a113bb62b0 (diff)
downloadtor-bd3213b17e6ff94bfd1c5deb3ecf2d906dd8d0b6.tar.gz
tor-bd3213b17e6ff94bfd1c5deb3ecf2d906dd8d0b6.zip
prop224 tests: Better HS time period tests.
Diffstat (limited to 'src/test/test_hs_common.c')
-rw-r--r--src/test/test_hs_common.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index 65c6948382..cc62870cb6 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -128,7 +128,7 @@ test_time_period(void *arg)
(void) arg;
uint64_t tn;
int retval;
- time_t fake_time;
+ time_t fake_time, correct_time, start_time;
/* Let's do the example in prop224 section [TIME-PERIODS] */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
@@ -145,6 +145,15 @@ test_time_period(void *arg)
tn = hs_get_time_period_num(fake_time);
tt_u64_op(tn, ==, 16903);
+ { /* Check start time of next time period */
+ retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
+ &correct_time);
+ tt_int_op(retval, ==, 0);
+
+ start_time = hs_get_start_time_of_next_time_period(fake_time);
+ tt_int_op(start_time, OP_EQ, correct_time);
+ }
+
/* Now take time to 12:00:00 UTC and check that the time period rotated */
fake_time += 1;
tn = hs_get_time_period_num(fake_time);
@@ -154,6 +163,24 @@ test_time_period(void *arg)
tn = hs_get_next_time_period_num(fake_time);
tt_u64_op(tn, ==, 16905);
+ { /* Check start time of next time period again */
+ retval = parse_rfc1123_time("Wed, 14 Apr 2016 12:00:00 UTC",
+ &correct_time);
+ tt_int_op(retval, ==, 0);
+
+ start_time = hs_get_start_time_of_next_time_period(fake_time);
+ tt_int_op(start_time, OP_EQ, correct_time);
+ }
+
+ /* Now do another sanity check: The time period number at the start of the
+ * next time period, must be the same time period number as the one returned
+ * from hs_get_next_time_period_num() */
+ {
+ time_t next_tp_start = hs_get_start_time_of_next_time_period(fake_time);
+ tt_int_op(hs_get_time_period_num(next_tp_start), OP_EQ,
+ hs_get_next_time_period_num(fake_time));
+ }
+
done:
;
}