[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.2' into maint-0.3.3
commit c31700d6640a10eb5e406205c2753e69efd217ec
Merge: 28d1057d5 559f79fd7
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Jul 18 15:04:14 2018 -0400
Merge branch 'maint-0.3.2' into maint-0.3.3
changes/bug26485 | 4 ++++
src/or/config.c | 9 ++++++++-
src/or/dirserv.c | 43 +++++++++++++++++++++++++++++++++++++------
src/or/dirserv.h | 3 +--
src/or/dirvote.c | 9 ++++++++-
src/test/test_dir.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
6 files changed, 110 insertions(+), 11 deletions(-)
diff --cc src/test/test_dir.c
index 165029d23,28489d939..a33b23bcc
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@@ -5753,106 -6193,57 +5753,157 @@@ test_dir_platform_str(void *arg
;
}
+static networkstatus_t *mock_networkstatus;
+
+static networkstatus_t *
+mock_networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f)
+{
+ (void)f;
+ return mock_networkstatus;
+}
+
+static void
+test_dir_networkstatus_consensus_has_ipv6(void *arg)
+{
+ (void)arg;
+
+ int has_ipv6 = 0;
+
+ /* Init options and networkstatus */
+ or_options_t our_options;
+ mock_options = &our_options;
+ reset_options(mock_options, &mock_get_options_calls);
+ MOCK(get_options, mock_get_options);
+
+ networkstatus_t our_networkstatus;
+ mock_networkstatus = &our_networkstatus;
+ memset(mock_networkstatus, 0, sizeof(*mock_networkstatus));
+ MOCK(networkstatus_get_latest_consensus_by_flavor,
+ mock_networkstatus_get_latest_consensus_by_flavor);
+
+ /* A live consensus */
+ mock_networkstatus->valid_after = time(NULL) - 3600;
+ mock_networkstatus->valid_until = time(NULL) + 3600;
+
+ /* Test the bounds for A lines in the NS consensus */
+ mock_options->UseMicrodescriptors = 0;
+
+ mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(has_ipv6);
+
+ mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES + 1;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(has_ipv6);
+
+ mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES + 20;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(has_ipv6);
+
+ mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES - 1;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(!has_ipv6);
+
+ /* 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;
+ 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;
+ 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;
+ 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;
+ 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;
+
+ /* Reasonably live */
+ mock_networkstatus->valid_until = approx_time() - 60;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(has_ipv6);
+
+ /* Not reasonably live */
+ mock_networkstatus->valid_after = approx_time() - 24*60*60 - 3600;
+ mock_networkstatus->valid_until = approx_time() - 24*60*60 - 60;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(!has_ipv6);
+
+ /* NULL consensus */
+ mock_networkstatus = NULL;
+ has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
+ tt_assert(!has_ipv6);
+
+ done:
+ UNMOCK(get_options);
+ UNMOCK(networkstatus_get_latest_consensus_by_flavor);
+}
+
+ static void
+ test_dir_format_versions_list(void *arg)
+ {
+ (void)arg;
+ char *s = NULL;
+ config_line_t *lines = NULL;
+
+ setup_capture_of_logs(LOG_WARN);
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "");
+
+ tor_free(s);
+ config_line_append(&lines, "ignored", "0.3.4.1, 0.2.9.111-alpha, 4.4.4-rc");
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
+
+ tor_free(s);
+ config_line_append(&lines, "ignored", "0.1.2.3,0.2.9.10 ");
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
+
+ /* There should be no warnings so far. */
+ expect_no_log_entry();
+
+ /* Now try a line with a space in it. */
+ tor_free(s);
+ config_line_append(&lines, "ignored", "1.3.3.8 1.3.3.7");
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,"
+ "1.3.3.7,1.3.3.8,4.4.4-rc");
+
+ expect_single_log_msg_containing(
+ "Unexpected space in versions list member \"1.3.3.8 1.3.3.7\"." );
+
+ /* Start over, with a line containing a bogus version */
+ config_free_lines(lines);
+ lines = NULL;
+ tor_free(s);
+ mock_clean_saved_logs();
+ config_line_append(&lines, "ignored", "0.1.2.3, alpha-complex, 0.1.1.8-rc");
+ s = format_recommended_version_list(lines,1);
+ tt_str_op(s, OP_EQ, "0.1.1.8-rc,0.1.2.3,alpha-complex");
+ expect_single_log_msg_containing(
+ "Recommended version \"alpha-complex\" does not look valid.");
+
+ done:
+ tor_free(s);
+ config_free_lines(lines);
+ teardown_capture_of_logs();
+ }
+
#define DIR_LEGACY(name) \
{ #name, test_dir_ ## name , TT_FORK, NULL, NULL }
@@@ -5920,7 -6312,6 +5971,7 @@@ struct testcase_t dir_tests[] =
DIR(assumed_flags, 0),
DIR(networkstatus_compute_bw_weights_v10, 0),
DIR(platform_str, 0),
+ DIR(networkstatus_consensus_has_ipv6, TT_FORK),
+ DIR(format_versions_list, TT_FORK),
END_OF_TESTCASES
};
-
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits