mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Test: make unit tests use a reasonably live consensus
Cleanup after 24661.
This commit is contained in:
parent
657618ba9b
commit
cebc39bcd5
@ -1448,13 +1448,10 @@ networkstatus_valid_until_is_reasonably_live(time_t valid_until,
|
||||
return (now <= valid_until + REASONABLY_LIVE_TIME);
|
||||
}
|
||||
|
||||
/* XXXX remove this in favor of get_live_consensus. But actually,
|
||||
* leave something like it for bridge users, who need to not totally
|
||||
* lose if they spend a while fetching a new consensus. */
|
||||
/** As networkstatus_get_live_consensus(), but is way more tolerant of expired
|
||||
* consensuses. */
|
||||
networkstatus_t *
|
||||
networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
|
||||
MOCK_IMPL(networkstatus_t *,
|
||||
networkstatus_get_reasonably_live_consensus,(time_t now, int flavor))
|
||||
{
|
||||
networkstatus_t *consensus =
|
||||
networkstatus_get_latest_consensus_by_flavor(flavor);
|
||||
|
@ -89,8 +89,9 @@ int networkstatus_consensus_reasonably_live(const networkstatus_t *consensus,
|
||||
time_t now);
|
||||
int networkstatus_valid_until_is_reasonably_live(time_t valid_until,
|
||||
time_t now);
|
||||
networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now,
|
||||
int flavor);
|
||||
MOCK_DECL(networkstatus_t *,networkstatus_get_reasonably_live_consensus,
|
||||
(time_t now,
|
||||
int flavor));
|
||||
MOCK_DECL(int, networkstatus_consensus_is_bootstrapping,(time_t now));
|
||||
int networkstatus_consensus_can_use_multiple_directories(
|
||||
const or_options_t *options);
|
||||
|
@ -74,9 +74,10 @@ bfn_mock_nodelist_get_list(void)
|
||||
}
|
||||
|
||||
static networkstatus_t *
|
||||
bfn_mock_networkstatus_get_live_consensus(time_t now)
|
||||
bfn_mock_networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
|
||||
{
|
||||
(void)now;
|
||||
(void)flavor;
|
||||
return dummy_consensus;
|
||||
}
|
||||
|
||||
@ -118,7 +119,7 @@ big_fake_network_cleanup(const struct testcase_t *testcase, void *ptr)
|
||||
UNMOCK(nodelist_get_list);
|
||||
UNMOCK(node_get_by_id);
|
||||
UNMOCK(get_or_state);
|
||||
UNMOCK(networkstatus_get_live_consensus);
|
||||
UNMOCK(networkstatus_get_reasonably_live_consensus);
|
||||
or_state_free(dummy_state);
|
||||
dummy_state = NULL;
|
||||
tor_free(dummy_consensus);
|
||||
@ -198,8 +199,8 @@ big_fake_network_setup(const struct testcase_t *testcase)
|
||||
MOCK(node_get_by_id, bfn_mock_node_get_by_id);
|
||||
MOCK(get_or_state,
|
||||
get_or_state_replacement);
|
||||
MOCK(networkstatus_get_live_consensus,
|
||||
bfn_mock_networkstatus_get_live_consensus);
|
||||
MOCK(networkstatus_get_reasonably_live_consensus,
|
||||
bfn_mock_networkstatus_get_reasonably_live_consensus);
|
||||
/* Return anything but NULL (it's interpreted as test fail) */
|
||||
return (void*)testcase;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user