aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-26 11:01:10 -0700
committerNick Mathewson <nickm@torproject.org>2016-09-26 11:01:10 -0700
commited5d2daba1944d7910b991475763376162b31af9 (patch)
tree581ff9baaed0a19d328a89eca3e88130d56953b6 /src/test/test_dir.c
parent97337844b7282946dda12f59bcabc097fad42647 (diff)
parent8fdf2f583c73f249791bd3a7627d27da4a6ef36f (diff)
downloadtor-ed5d2daba1944d7910b991475763376162b31af9.tar.gz
tor-ed5d2daba1944d7910b991475763376162b31af9.zip
Merge remote-tracking branch 'public/ticket20001_v2'
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 7610ddc399..77c5dc13c8 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -5388,6 +5388,49 @@ test_dir_find_dl_schedule(void* data)
mock_options = NULL;
}
+static void
+test_dir_assumed_flags(void *arg)
+{
+ (void)arg;
+ smartlist_t *tokens = smartlist_new();
+ memarea_t *area = memarea_new();
+ routerstatus_t *rs = NULL;
+
+ /* First, we should always assume that the Running flag is set, even
+ * when it isn't listed, since the consensus method is always
+ * higher than 4. */
+ const char *str1 =
+ "r example hereiswhereyouridentitygoes 2015-08-30 12:00:00 "
+ "192.168.0.1 9001 0\n"
+ "m thisoneislongerbecauseitisa256bitmddigest33\n"
+ "s Fast Guard Stable\n";
+
+ const char *cp = str1;
+ rs = routerstatus_parse_entry_from_string(area, &cp, tokens, NULL, NULL,
+ 23, FLAV_MICRODESC);
+ tt_assert(rs);
+ tt_assert(rs->is_flagged_running);
+ tt_assert(! rs->is_valid);
+ tt_assert(! rs->is_exit);
+ tt_assert(rs->is_fast);
+ routerstatus_free(rs);
+
+ /* With method 24 or later, we can assume "valid" is set. */
+ cp = str1;
+ rs = routerstatus_parse_entry_from_string(area, &cp, tokens, NULL, NULL,
+ 24, FLAV_MICRODESC);
+ tt_assert(rs);
+ tt_assert(rs->is_flagged_running);
+ tt_assert(rs->is_valid);
+ tt_assert(! rs->is_exit);
+ tt_assert(rs->is_fast);
+
+ done:
+ smartlist_free(tokens);
+ memarea_drop_all(area);
+ routerstatus_free(rs);
+}
+
#define DIR_LEGACY(name) \
{ #name, test_dir_ ## name , TT_FORK, NULL, NULL }
@@ -5441,6 +5484,7 @@ struct testcase_t dir_tests[] = {
DIR_ARG(find_dl_schedule, TT_FORK, "ba"),
DIR_ARG(find_dl_schedule, TT_FORK, "cf"),
DIR_ARG(find_dl_schedule, TT_FORK, "ca"),
+ DIR(assumed_flags, 0),
END_OF_TESTCASES
};