diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-12-18 13:16:49 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-12-18 13:16:49 -0500 |
commit | c4fb7ad0348a190be8496b429aa96982f1b26917 (patch) | |
tree | 5898237d9b67e5669448b8265ae1415fc1c19aab /src/test/test_nodelist.c | |
parent | 14c9b9905180a21b8aa648b642ff5d3f7d86e29f (diff) | |
parent | ea6f88478cec6b3151a992cf2fd99539997ebb94 (diff) | |
download | tor-c4fb7ad0348a190be8496b429aa96982f1b26917.tar.gz tor-c4fb7ad0348a190be8496b429aa96982f1b26917.zip |
Merge branch 'feature12538_028_01_squashed'
Diffstat (limited to 'src/test/test_nodelist.c')
-rw-r--r-- | src/test/test_nodelist.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c index a8693ec9b5..0a4151ada1 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -60,12 +60,53 @@ test_nodelist_node_get_verbose_nickname_not_named(void *arg) return; } +/** A node should be considered a directory server if it has an open dirport + * of it accepts tunnelled directory requests. + */ +static void +test_nodelist_node_is_dir(void *arg) +{ + (void)arg; + + routerstatus_t rs; + routerinfo_t ri; + node_t node; + memset(&node, 0, sizeof(node_t)); + memset(&rs, 0, sizeof(routerstatus_t)); + memset(&ri, 0, sizeof(routerinfo_t)); + + tt_assert(!node_is_dir(&node)); + + node.rs = &rs; + tt_assert(!node_is_dir(&node)); + + rs.is_v2_dir = 1; + tt_assert(node_is_dir(&node)); + + rs.is_v2_dir = 0; + rs.dir_port = 1; + tt_assert(node_is_dir(&node)); + + node.rs = NULL; + tt_assert(!node_is_dir(&node)); + node.ri = &ri; + ri.supports_tunnelled_dir_requests = 1; + tt_assert(node_is_dir(&node)); + ri.supports_tunnelled_dir_requests = 0; + ri.dir_port = 1; + tt_assert(node_is_dir(&node)); + + done: + return; +} + #define NODE(name, flags) \ { #name, test_nodelist_##name, (flags), NULL, NULL } struct testcase_t nodelist_tests[] = { NODE(node_get_verbose_nickname_by_id_null_node, TT_FORK), NODE(node_get_verbose_nickname_not_named, TT_FORK), + NODE(node_is_dir, TT_FORK), END_OF_TESTCASES }; |