fixup! Add networkstatus_consensus_has_ipv6() and unit tests

This is what happens when you don't run:
make check-spaces
make check-changes
This commit is contained in:
teor 2017-12-11 00:51:40 +11:00
parent b66b62fb75
commit bbc781885d
No known key found for this signature in database
GPG Key ID: 740D9E39025272A2
2 changed files with 11 additions and 6 deletions

View File

@ -1,7 +1,7 @@
o Minor feature (IPv6):
- When a consensus has IPv6 ORPorts, make IPv6-only clients use them,
rather than waiting to download microdescriptors.
Implements #23827.
Implements 23827.
- Make IPv6-only clients wait for microdescs for relays, even if we were
previously using descriptors (or were using them as a bridge) and have
a cached descriptor for them.

View File

@ -6228,25 +6228,30 @@ test_dir_networkstatus_consensus_has_ipv6(void *arg)
/* Test the bounds for A lines in the microdesc consensus */
mock_options->UseMicrodescriptors = 1;
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS;
mock_networkstatus->consensus_method =
MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS + 1;
mock_networkstatus->consensus_method =
MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS + 1;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS + 20;
mock_networkstatus->consensus_method =
MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS + 20;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS - 1;
mock_networkstatus->consensus_method =
MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS - 1;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(!has_ipv6);
/* Test the edge cases */
mock_options->UseMicrodescriptors = 1;
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS;
mock_networkstatus->consensus_method =
MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS;
/* Reasonably live */
mock_networkstatus->valid_until = time(NULL) - 60;