summaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index efc3ec7940..84e80ea760 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -714,9 +714,10 @@ mock_get_by_ei_desc_digest(const char *d)
static smartlist_t *mock_ei_insert_list = NULL;
static was_router_added_t
-mock_ei_insert(routerlist_t *rl, extrainfo_t *ei)
+mock_ei_insert(routerlist_t *rl, extrainfo_t *ei, int warn_if_incompatible)
{
(void) rl;
+ (void) warn_if_incompatible;
smartlist_add(mock_ei_insert_list, ei);
return ROUTER_ADDED_SUCCESSFULLY;
}
@@ -2930,6 +2931,30 @@ test_dir_http_handling(void *args)
}
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;
+ tt_assert(dir_fetch_type(DIR_PURPOSE_FETCH_MICRODESC, ROUTER_PURPOSE_GENERAL,
+ NULL) == MICRODESC_DIRINFO);
+ tt_assert(dir_fetch_type(DIR_PURPOSE_FETCH_SERVERDESC, ROUTER_PURPOSE_BRIDGE,
+ NULL) == BRIDGE_DIRINFO);
+ tt_assert(dir_fetch_type(DIR_PURPOSE_FETCH_CONSENSUS, ROUTER_PURPOSE_GENERAL,
+ "microdesc") == (V3_DIRINFO | MICRODESC_DIRINFO));
+ done: ;
+}
+
+static void
test_dir_packages(void *arg)
{
smartlist_t *votes = smartlist_new();
@@ -3102,6 +3127,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),
DIR(packages, 0),
END_OF_TESTCASES
};