diff options
author | George Kadianakis <desnacked@riseup.net> | 2018-07-17 11:00:18 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-07-17 15:57:46 -0400 |
commit | 9e6235d290fce3eac4b9aa39da21a4f4479292c6 (patch) | |
tree | 654dd926ce6f8f2b24d36fbca95ceebe5e5f7972 /src/test/test_shared_random.c | |
parent | 4cfade2f4682fa2554f79b2edf51f9dde8f924dc (diff) | |
download | tor-9e6235d290fce3eac4b9aa39da21a4f4479292c6.tar.gz tor-9e6235d290fce3eac4b9aa39da21a4f4479292c6.zip |
Fix time source bug in sr_state_get_start_time_of_current_protocol_run().
The following bug was causing many issues for this branch in chutney:
In sr_state_get_start_time_of_current_protocol_run() we were using the
consensus valid-after to calculate beginning_of_current_round, but we were
using time(NULL) to calculate the current_round slot. This was causing time
sync issues when the consensus valid-after and time(NULL) were disagreeing on
what the current round is. Our fix is to use the consensus valid-after in both
places.
This also means that we are not using 'now' (aka time(NULL)) anymore in that
function, and hence we can remove that argument from the function (and its
callers). I'll do this in the next commit so that we keep things separated.
Furthermore, we fix a unittest that broke.
Diffstat (limited to 'src/test/test_shared_random.c')
-rw-r--r-- | src/test/test_shared_random.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index 55910a351e..5b3fdbb103 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -249,8 +249,7 @@ test_get_start_time_of_current_run(void *arg) ¤t_time); tt_int_op(retval, OP_EQ, 0); voting_schedule_recalculate_timing(get_options(), current_time); - run_start_time = - sr_state_get_start_time_of_current_protocol_run(current_time); + run_start_time = sr_state_get_start_time_of_current_protocol_run(); /* Compare it with the correct result */ format_iso_time(tbuf, run_start_time); @@ -262,8 +261,7 @@ test_get_start_time_of_current_run(void *arg) ¤t_time); tt_int_op(retval, OP_EQ, 0); voting_schedule_recalculate_timing(get_options(), current_time); - run_start_time = - sr_state_get_start_time_of_current_protocol_run(current_time); + run_start_time = sr_state_get_start_time_of_current_protocol_run(); /* Compare it with the correct result */ format_iso_time(tbuf, run_start_time); @@ -275,8 +273,7 @@ test_get_start_time_of_current_run(void *arg) ¤t_time); tt_int_op(retval, OP_EQ, 0); voting_schedule_recalculate_timing(get_options(), current_time); - run_start_time = - sr_state_get_start_time_of_current_protocol_run(current_time); + run_start_time = sr_state_get_start_time_of_current_protocol_run(); /* Compare it with the correct result */ format_iso_time(tbuf, run_start_time); @@ -298,8 +295,7 @@ test_get_start_time_of_current_run(void *arg) ¤t_time); tt_int_op(retval, OP_EQ, 0); voting_schedule_recalculate_timing(get_options(), current_time); - run_start_time = - sr_state_get_start_time_of_current_protocol_run(current_time); + run_start_time = sr_state_get_start_time_of_current_protocol_run(); /* Compare it with the correct result */ format_iso_time(tbuf, run_start_time); @@ -332,7 +328,7 @@ test_get_start_time_functions(void *arg) voting_schedule_recalculate_timing(get_options(), now); time_t start_time_of_protocol_run = - sr_state_get_start_time_of_current_protocol_run(now); + sr_state_get_start_time_of_current_protocol_run(); tt_assert(start_time_of_protocol_run); /* Check that the round start time of the beginning of the run, is itself */ |