aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-07-24 13:30:04 +0300
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:34 -0400
commit0b22b7fce3f1ce97a85f4022533b206f847b7307 (patch)
tree44eff9cd6443b39b27380a719c2d7e615ba46e0f /src/test
parent2af254096f68f0cefadb5cb06b010d19edd2e6e1 (diff)
downloadtor-0b22b7fce3f1ce97a85f4022533b206f847b7307.tar.gz
tor-0b22b7fce3f1ce97a85f4022533b206f847b7307.zip
SR: Calculate current SRV phase/run duration.
This is also needed to make the HS desc overlap mode function independent of absolute hours.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_shared_random.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index 3eb47dfbc3..ea037d417b 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -260,6 +260,25 @@ test_get_start_time_of_current_run(void *arg)
;
}
+static void
+test_get_sr_protocol_duration(void *arg)
+{
+ (void) arg;
+
+ /* Check that by default an SR phase is 12 hours */
+ tt_int_op(sr_state_get_phase_duration(), ==, 12*60*60);
+ tt_int_op(sr_state_get_protocol_run_duration(), ==, 24*60*60);
+
+ /* Now alter the voting interval and check that the SR phase is 2 mins long
+ * if voting happens every 10 seconds (10*12 seconds = 2 mins) */
+ or_options_t *options = get_options_mutable();
+ options->V3AuthVotingInterval = 10;
+ tt_int_op(sr_state_get_phase_duration(), ==, 2*60);
+ tt_int_op(sr_state_get_protocol_run_duration(), ==, 4*60);
+
+ done: ;
+}
+
/* Mock function to immediately return our local 'mock_consensus'. */
static networkstatus_t *
mock_networkstatus_get_live_consensus(time_t now)
@@ -1345,6 +1364,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_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,
NULL, NULL },
{ "vote", test_vote, TT_FORK,