diff --git a/src/test/include.am b/src/test/include.am index c6743a19b0..74ac5261cb 100644 --- a/src/test/include.am +++ b/src/test/include.am @@ -22,6 +22,7 @@ src_test_test_SOURCES = \ src/test/test_cell_formats.c \ src/test/test_circuitlist.c \ src/test/test_circuitmux.c \ + src/test/test_config.c \ src/test/test_containers.c \ src/test/test_controller_events.c \ src/test/test_crypto.c \ @@ -29,19 +30,19 @@ src_test_test_SOURCES = \ src/test/test_data.c \ src/test/test_dir.c \ src/test/test_extorport.c \ + src/test/test_hs.c \ src/test/test_introduce.c \ src/test/test_logging.c \ src/test/test_microdesc.c \ + src/test/test_nodelist.c \ src/test/test_oom.c \ src/test/test_options.c \ src/test/test_pt.c \ src/test/test_replay.c \ src/test/test_routerkeys.c \ + src/test/test_routerlist.c \ src/test/test_socks.c \ src/test/test_util.c \ - src/test/test_config.c \ - src/test/test_hs.c \ - src/test/test_nodelist.c \ src/ext/tinytest.c src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) diff --git a/src/test/test.c b/src/test/test.c index 0ba5da3672..8b53754d5d 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -1637,33 +1637,35 @@ extern struct testcase_t hs_tests[]; extern struct testcase_t nodelist_tests[]; extern struct testcase_t routerkeys_tests[]; extern struct testcase_t oom_tests[]; +extern struct testcase_t routerlist_tests[]; static struct testgroup_t testgroups[] = { { "", test_array }, - { "buffer/", buffer_tests }, - { "socks/", socks_tests }, { "addr/", addr_tests }, - { "crypto/", crypto_tests }, - { "container/", container_tests }, - { "util/", util_tests }, - { "util/logging/", logging_tests }, + { "buffer/", buffer_tests }, { "cellfmt/", cell_format_tests }, { "cellqueue/", cell_queue_tests }, - { "dir/", dir_tests }, - { "dir/md/", microdesc_tests }, - { "pt/", pt_tests }, - { "config/", config_tests }, - { "replaycache/", replaycache_tests }, - { "introduce/", introduce_tests }, { "circuitlist/", circuitlist_tests }, { "circuitmux/", circuitmux_tests }, - { "options/", options_tests }, - { "extorport/", extorport_tests }, + { "config/", config_tests }, + { "container/", container_tests }, { "control/", controller_event_tests }, + { "crypto/", crypto_tests }, + { "dir/", dir_tests }, + { "dir/md/", microdesc_tests }, + { "extorport/", extorport_tests }, { "hs/", hs_tests }, + { "introduce/", introduce_tests }, { "nodelist/", nodelist_tests }, - { "routerkeys/", routerkeys_tests }, { "oom/", oom_tests }, + { "options/", options_tests }, + { "pt/", pt_tests }, + { "routerkeys/", routerkeys_tests }, + { "routerlist/", routerlist_tests }, + { "replaycache/", replaycache_tests }, + { "socks/", socks_tests }, + { "util/", util_tests }, + { "util/logging/", logging_tests }, END_OF_GROUPS }; diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 9e01bdbd48..f6ea6f3775 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -2357,6 +2357,30 @@ test_dir_http_handling(void *args) tor_free(url); } +static void +test_dir_purpose_needs_anonymity(void *arg) +{ + (void)arg; + tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE)); + tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_GENERAL)); + tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC, + ROUTER_PURPOSE_GENERAL)); + done: ; +} + +static void +test_dir_fetch_type(void *arg) +{ + (void)arg; + test_eq(dir_fetch_type(DIR_PURPOSE_FETCH_MICRODESC, ROUTER_PURPOSE_GENERAL, + NULL), MICRODESC_DIRINFO); + test_eq(dir_fetch_type(DIR_PURPOSE_FETCH_SERVERDESC, ROUTER_PURPOSE_BRIDGE, + NULL), BRIDGE_DIRINFO); + test_eq(dir_fetch_type(DIR_PURPOSE_FETCH_CONSENSUS, ROUTER_PURPOSE_GENERAL, + "microdesc"), V3_DIRINFO | MICRODESC_DIRINFO); + done: ; +} + #define DIR_LEGACY(name) \ { #name, legacy_test_helper, TT_FORK, &legacy_setup, test_dir_ ## name } @@ -2379,6 +2403,8 @@ struct testcase_t dir_tests[] = { DIR_LEGACY(clip_unmeasured_bw_kb_alt), DIR(fmt_control_ns, 0), DIR(http_handling, 0), + DIR(purpose_needs_anonymity, 0), + DIR(fetch_type, 0), END_OF_TESTCASES }; diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c index 600e6a89d4..67d39f35cd 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -10,7 +10,7 @@ #include "nodelist.h" #include "test.h" -/** Tese the case when node_get_by_id() returns NULL, +/** Test the case when node_get_by_id() returns NULL, * node_get_verbose_nickname_by_id should return the base 16 encoding * of the id. */