aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_microdesc.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-06-25 10:40:58 -0400
committerNick Mathewson <nickm@torproject.org>2015-06-25 10:40:58 -0400
commit03e3cf6a7aa86c74d01cebd61c9ad89200661e73 (patch)
treed7e558a1e47105585c80ce26915c8dc3727d592d /src/test/test_microdesc.c
parentf18ee7fc7287e9d5f55c7c6c2007a8a1c2466a3e (diff)
parente0b7598833238766b157f8eb799f448dac4c1283 (diff)
downloadtor-03e3cf6a7aa86c74d01cebd61c9ad89200661e73.tar.gz
tor-03e3cf6a7aa86c74d01cebd61c9ad89200661e73.zip
Merge remote-tracking branch 'public/bug16400_026' into maint-0.2.6
Diffstat (limited to 'src/test/test_microdesc.c')
-rw-r--r--src/test/test_microdesc.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index fb3df77edc..c0376348dd 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -713,12 +713,46 @@ test_md_reject_cache(void *arg)
tor_free(mock_ns_val);
}
+static void
+test_md_corrupt_desc(void *arg)
+{
+ char *cp = NULL;
+ smartlist_t *sl = NULL;
+ (void) arg;
+
+ sl = microdescs_add_to_cache(get_microdesc_cache(),
+ "@last-listed 2015-06-22 10:00:00\n"
+ "onion-k\n",
+ NULL, SAVED_IN_JOURNAL, 0, time(NULL), NULL);
+ tt_int_op(smartlist_len(sl), ==, 0);
+ smartlist_free(sl);
+
+ sl = microdescs_add_to_cache(get_microdesc_cache(),
+ "@last-listed 2015-06-22 10:00:00\n"
+ "wiggly\n",
+ NULL, SAVED_IN_JOURNAL, 0, time(NULL), NULL);
+ tt_int_op(smartlist_len(sl), ==, 0);
+ smartlist_free(sl);
+
+ tor_asprintf(&cp, "%s\n%s", test_md1, "@foobar\nonion-wobble\n");
+
+ sl = microdescs_add_to_cache(get_microdesc_cache(),
+ cp, cp+strlen(cp),
+ SAVED_IN_JOURNAL, 0, time(NULL), NULL);
+ tt_int_op(smartlist_len(sl), ==, 0);
+ smartlist_free(sl);
+
+ done:
+ tor_free(cp);
+}
+
struct testcase_t microdesc_tests[] = {
{ "cache", test_md_cache, TT_FORK, NULL, NULL },
{ "broken_cache", test_md_cache_broken, TT_FORK, NULL, NULL },
{ "generate", test_md_generate, 0, NULL, NULL },
{ "parse", test_md_parse, 0, NULL, NULL },
{ "reject_cache", test_md_reject_cache, TT_FORK, NULL, NULL },
+ { "corrupt_desc", test_md_corrupt_desc, TT_FORK, NULL, NULL },
END_OF_TESTCASES
};