Test: make unit tests use a reasonably live consensus

Cleanup after 24661.
This commit is contained in:
teor 2018-11-21 15:55:43 +10:00
parent 657618ba9b
commit cebc39bcd5
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A
3 changed files with 10 additions and 11 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
}