summaryrefslogtreecommitdiff
path: root/src/test/test_shared_random.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-10-27 09:16:29 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-10-27 09:23:37 -0400
commit7ee0a2b9aa71693a09687dca431cc1880774f4f4 (patch)
treecd6bb633dfcf0f7731671af751cf3b2044ed2123 /src/test/test_shared_random.c
parent60164f057c4ac5471754f0326ab631448cd7c120 (diff)
downloadtor-7ee0a2b9aa71693a09687dca431cc1880774f4f4.tar.gz
tor-7ee0a2b9aa71693a09687dca431cc1880774f4f4.zip
sr: Don't use a dynamic voting schedule
The exposed get_voting_schedule() allocates and return a new object everytime it is called leading to an awful lot of memory allocation when getting the start time of the current round which is done for each node in the consensus. Closes #23623 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_shared_random.c')
-rw-r--r--src/test/test_shared_random.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index a9d58e6b8b..d9daa26cee 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -273,14 +273,9 @@ test_get_start_time_functions(void *arg)
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,
+ tt_int_op(get_start_time_of_current_round(), 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: ;
}
@@ -311,7 +306,7 @@ mock_networkstatus_get_live_consensus(time_t now)
return mock_consensus;
}
-/** Test the get_next_valid_after_time() function. */
+/** Test the dirvote_get_next_valid_after_time() function. */
static void
test_get_next_valid_after_time(void *arg)
{
@@ -324,7 +319,7 @@ test_get_next_valid_after_time(void *arg)
{
/* Setup a fake consensus just to get the times out of it, since
- get_next_valid_after_time() needs them. */
+ dirvote_get_next_valid_after_time() needs them. */
mock_consensus = tor_malloc_zero(sizeof(networkstatus_t));
retval = parse_rfc1123_time("Mon, 13 Jan 2016 16:00:00 UTC",
@@ -344,7 +339,7 @@ test_get_next_valid_after_time(void *arg)
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
&current_time);
tt_int_op(retval, OP_EQ, 0);
- valid_after_time = get_next_valid_after_time(current_time);
+ valid_after_time = dirvote_get_next_valid_after_time();
/* Compare it with the correct result */
format_iso_time(tbuf, valid_after_time);
@@ -356,7 +351,7 @@ test_get_next_valid_after_time(void *arg)
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
&current_time);
tt_int_op(retval, OP_EQ, 0);
- valid_after_time = get_next_valid_after_time(current_time);
+ valid_after_time = dirvote_get_next_valid_after_time();
/* Compare it with the correct result */
format_iso_time(tbuf, valid_after_time);
@@ -367,7 +362,7 @@ test_get_next_valid_after_time(void *arg)
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:30:01 UTC",
&current_time);
tt_int_op(retval, OP_EQ, 0);
- valid_after_time = get_next_valid_after_time(current_time);
+ valid_after_time = dirvote_get_next_valid_after_time();
/* Compare it with the correct result */
format_iso_time(tbuf, valid_after_time);