aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_shared_random.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_shared_random.c')
-rw-r--r--src/test/test_shared_random.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index b4fe6eef64..413dfbeb03 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -164,6 +164,15 @@ mock_networkstatus_get_live_consensus(time_t now)
return &mock_consensus;
}
+/* Mock function to immediately return our local 'mock_consensus'. */
+static networkstatus_t *
+mock_networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
+{
+ (void) now;
+ (void) flavor;
+ return &mock_consensus;
+}
+
static void
test_get_state_valid_until_time(void *arg)
{
@@ -176,6 +185,8 @@ test_get_state_valid_until_time(void *arg)
MOCK(networkstatus_get_live_consensus,
mock_networkstatus_get_live_consensus);
+ MOCK(networkstatus_get_reasonably_live_consensus,
+ mock_networkstatus_get_reasonably_live_consensus);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 01:00:00 UTC",
&mock_consensus.fresh_until);
@@ -232,7 +243,7 @@ test_get_state_valid_until_time(void *arg)
}
done:
- UNMOCK(networkstatus_get_live_consensus);
+ UNMOCK(networkstatus_get_reasonably_live_consensus);
}
/** Test the function that calculates the start time of the current SRV
@@ -248,6 +259,8 @@ test_get_start_time_of_current_run(void *arg)
MOCK(networkstatus_get_live_consensus,
mock_networkstatus_get_live_consensus);
+ MOCK(networkstatus_get_reasonably_live_consensus,
+ mock_networkstatus_get_reasonably_live_consensus);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 01:00:00 UTC",
&mock_consensus.fresh_until);
@@ -331,6 +344,7 @@ test_get_start_time_of_current_run(void *arg)
/* Next test is testing it without a consensus to use the testing voting
* interval . */
UNMOCK(networkstatus_get_live_consensus);
+ UNMOCK(networkstatus_get_reasonably_live_consensus);
/* Now let's alter the voting schedule and check the correctness of the
* function. Voting interval of 10 seconds, means that an SRV protocol run
@@ -362,8 +376,8 @@ test_get_start_time_functions(void *arg)
(void) arg;
int retval;
- MOCK(networkstatus_get_live_consensus,
- mock_networkstatus_get_live_consensus);
+ MOCK(networkstatus_get_reasonably_live_consensus,
+ mock_networkstatus_get_reasonably_live_consensus);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 01:00:00 UTC",
&mock_consensus.fresh_until);
@@ -384,7 +398,7 @@ test_get_start_time_functions(void *arg)
start_time_of_protocol_run);
done:
- UNMOCK(networkstatus_get_live_consensus);
+ UNMOCK(networkstatus_get_reasonably_live_consensus);
}
static void