diff options
author | David Goulet <dgoulet@torproject.org> | 2021-01-12 10:54:31 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-01-12 10:54:31 -0500 |
commit | b3652f2104c880bf626cb4e97e6088bca5a1571f (patch) | |
tree | 6cb537a2bc8f367f626f3dd728eb626d4041617d /src/test/test_shared_random.c | |
parent | 5a822b462aaa8cf3cd749c253bb1e9e5f4f37fa2 (diff) | |
parent | 0485c7ddba8c3474d1be8972caa9505b09d65644 (diff) | |
download | tor-b3652f2104c880bf626cb4e97e6088bca5a1571f.tar.gz tor-b3652f2104c880bf626cb4e97e6088bca5a1571f.zip |
Merge branch 'ticket40237_043_01' into ticket40237_044_01
Diffstat (limited to 'src/test/test_shared_random.c')
-rw-r--r-- | src/test/test_shared_random.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index 148eb5cf90..9e49e835c9 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -167,6 +167,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) { @@ -179,6 +188,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); @@ -235,7 +246,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 @@ -251,6 +262,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); @@ -335,6 +348,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 @@ -366,8 +380,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); @@ -388,7 +402,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 |