aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-04-02 13:59:53 -0400
committerNick Mathewson <nickm@torproject.org>2013-04-18 11:04:58 -0400
commit4d672f3ae3467203e7badc214576ae7cf7ead9e5 (patch)
tree61a29862a314fbdac3164e1cd9639933aa9cbe2b /src/test
parent0f83fcc5c239776211d0c111c628a7f95a802808 (diff)
downloadtor-4d672f3ae3467203e7badc214576ae7cf7ead9e5.tar
tor-4d672f3ae3467203e7badc214576ae7cf7ead9e5.tar.gz
Test networkstatus_getinfo_helper_single
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_dir.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 71008b5f0..42bdb9ca1 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -2217,6 +2217,39 @@ test_dir_v2_dir(void *arg)
cached_dir_decref(v2);
}
+static void
+test_dir_fmt_control_ns(void *arg)
+{
+ char *s = NULL;
+ routerstatus_t rs;
+ (void)arg;
+
+ memset(&rs, 0, sizeof(rs));
+ rs.published_on = 1364925198;
+ strlcpy(rs.nickname, "TetsuoMilk", sizeof(rs.nickname));
+ memcpy(rs.identity_digest, "Stately, plump Buck ", DIGEST_LEN);
+ memcpy(rs.descriptor_digest, "Mulligan came up fro", DIGEST_LEN);
+ rs.addr = 0x20304050;
+ rs.or_port = 9001;
+ rs.dir_port = 9002;
+ rs.is_exit = 1;
+ rs.is_fast = 1;
+ rs.is_flagged_running = 1;
+ rs.has_bandwidth = 1;
+ rs.bandwidth = 1000;
+
+ s = networkstatus_getinfo_helper_single(&rs);
+ tt_assert(s);
+ tt_str_op(s, ==,
+ "r TetsuoMilk U3RhdGVseSwgcGx1bXAgQnVjayA "
+ "TXVsbGlnYW4gY2FtZSB1cCBmcm8 2013-04-02 17:53:18 "
+ "32.48.64.80 9001 9002\n"
+ "s Exit Fast Running\n"
+ "w Bandwidth=1000\n");
+
+ done:
+ tor_free(s);
+}
#define DIR_LEGACY(name) \
{ #name, legacy_test_helper, TT_FORK, &legacy_setup, test_dir_ ## name }
@@ -2238,6 +2271,7 @@ struct testcase_t dir_tests[] = {
DIR_LEGACY(clip_unmeasured_bw),
DIR_LEGACY(clip_unmeasured_bw_alt),
DIR(v2_dir, TT_FORK),
+ DIR(fmt_control_ns, 0),
END_OF_TESTCASES
};