diff options
author | Arlo Breault <arlolra@gmail.com> | 2014-09-23 12:22:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-23 12:23:18 -0400 |
commit | bb137e23c1c30f7e9f469d4924bbce2bb9b2d2ed (patch) | |
tree | 44933bf6beeb24edb6396c104ae641711262f936 /src/test/test_dir.c | |
parent | 5ed5ac185bf6f30438af1638f30e04418ed27aff (diff) | |
download | tor-bb137e23c1c30f7e9f469d4924bbce2bb9b2d2ed.tar.gz tor-bb137e23c1c30f7e9f469d4924bbce2bb9b2d2ed.zip |
Unit tests for router download functions.
Also, sort test suites alphabetically.
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r-- | src/test/test_dir.c | 26 |
1 files changed, 26 insertions, 0 deletions
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 }; |