summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-08-05 23:11:37 +0300
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:35 -0400
commit4a1b57e9b00c8474ada28dd052a2de73a1e9c641 (patch)
tree47f39aa091ddfb3b15e18225d74a35e77f931cb5 /src/test
parent0bf8587858b927d1dcb39189442f55d8dabe50aa (diff)
downloadtor-4a1b57e9b00c8474ada28dd052a2de73a1e9c641.tar.gz
tor-4a1b57e9b00c8474ada28dd052a2de73a1e9c641.zip
prop224 tests: Improve SRV protocol tests.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_shared_random.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index ea037d417b..bee0ea0a32 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -260,6 +260,30 @@ test_get_start_time_of_current_run(void *arg)
;
}
+/** Do some rudimentary consistency checks between the functions that
+ * understand the shared random protocol schedule */
+static void
+test_get_start_time_functions(void *arg)
+{
+ (void) arg;
+ time_t now = approx_time();
+
+ time_t start_time_of_protocol_run =
+ sr_state_get_start_time_of_current_protocol_run(now);
+ tt_assert(start_time_of_protocol_run);
+
+ /* Check that the round start time of the beginning of the run, is itself */
+ tt_int_op(get_start_time_of_current_round(start_time_of_protocol_run), OP_EQ,
+ start_time_of_protocol_run);
+
+ /* Check that even if we increment the start time, we still get the start
+ time of the run as the beginning of the round. */
+ tt_int_op(get_start_time_of_current_round(start_time_of_protocol_run+1),
+ OP_EQ, start_time_of_protocol_run);
+
+ done: ;
+}
+
static void
test_get_sr_protocol_duration(void *arg)
{
@@ -1364,6 +1388,8 @@ struct testcase_t sr_tests[] = {
NULL, NULL },
{ "get_start_time_of_current_run", test_get_start_time_of_current_run,
TT_FORK, NULL, NULL },
+ { "get_start_time_functions", test_get_start_time_functions,
+ TT_FORK, NULL, NULL },
{ "get_sr_protocol_duration", test_get_sr_protocol_duration, TT_FORK,
NULL, NULL },
{ "get_state_valid_until_time", test_get_state_valid_until_time, TT_FORK,