diff options
author | teor <teor@torproject.org> | 2018-11-22 17:47:12 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2018-11-22 17:47:12 +1000 |
commit | 805f75182a87286a727df323be7c37add595bdff (patch) | |
tree | bfa491ed8bbe18f74cd3fa9e0059a5dfe8be117a /src/test/test_entrynodes.c | |
parent | 390112d07e7daad1ce1e79b37c3357ca936fd9ae (diff) | |
download | tor-805f75182a87286a727df323be7c37add595bdff.tar.gz tor-805f75182a87286a727df323be7c37add595bdff.zip |
Entry Nodes: Test on reasonably live consensuses
As well as live consensuses.
Tests for 24661.
Diffstat (limited to 'src/test/test_entrynodes.c')
-rw-r--r-- | src/test/test_entrynodes.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index 1071b04ce1..52b87a84a8 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -137,6 +137,12 @@ big_fake_network_setup(const struct testcase_t *testcase) * that we need for entrynodes.c. */ const int N_NODES = 271; + const char *argument = testcase->setup_data; + int reasonably_live_consensus = 0; + if (argument) { + reasonably_live_consensus = strstr(argument, "reasonably-live") != NULL; + } + big_fake_net_nodes = smartlist_new(); for (i = 0; i < N_NODES; ++i) { curve25519_secret_key_t curve25519_secret_key; @@ -192,8 +198,16 @@ big_fake_network_setup(const struct testcase_t *testcase) dummy_state = tor_malloc_zero(sizeof(or_state_t)); dummy_consensus = tor_malloc_zero(sizeof(networkstatus_t)); - dummy_consensus->valid_after = approx_time() - 3600; - dummy_consensus->valid_until = approx_time() + 3600; + if (reasonably_live_consensus) { + /* Make the dummy consensus valid from 4 hours ago, but expired an hour + * ago. */ + dummy_consensus->valid_after = approx_time() - 4*3600; + dummy_consensus->valid_until = approx_time() - 3600; + } else { + /* Make the dummy consensus valid for an hour either side of now. */ + dummy_consensus->valid_after = approx_time() - 3600; + dummy_consensus->valid_until = approx_time() + 3600; + } MOCK(nodelist_get_list, bfn_mock_nodelist_get_list); MOCK(node_get_by_id, bfn_mock_node_get_by_id); @@ -3020,10 +3034,14 @@ static const struct testcase_setup_t upgrade_circuits = { #define EN_TEST_FORK(name) EN_TEST_BASE(name, TT_FORK, NULL, NULL) #define BFN_TEST(name) \ - EN_TEST_BASE(name, TT_FORK, &big_fake_network, NULL) + EN_TEST_BASE(name, TT_FORK, &big_fake_network, NULL), \ + { #name "_reasonably_live", test_entry_guard_ ## name, TT_FORK, \ + &big_fake_network, (void*)("reasonably-live") } #define UPGRADE_TEST(name, arg) \ - EN_TEST_BASE(name, TT_FORK, &upgrade_circuits, arg) + EN_TEST_BASE(name, TT_FORK, &upgrade_circuits, arg), \ + { #name "_reasonably_live", test_entry_guard_ ## name, TT_FORK, \ + &upgrade_circuits, (void*)(arg " reasonably-live") } struct testcase_t entrynodes_tests[] = { NO_PREFIX_TEST(node_preferred_orport), |