diff options
author | Qingping Hou <dave2008713@gmail.com> | 2014-02-04 20:52:48 -0500 |
---|---|---|
committer | Qingping Hou <dave2008713@gmail.com> | 2014-02-06 16:13:55 -0500 |
commit | 57da1a5057a3d95a9093384a3797d5a404863c5a (patch) | |
tree | 8aaf4ce48baa0c9121d46c9d7a440f31d4d5274b /src/test | |
parent | 39ff3b00cf965bab7ac82aa052ea3ea941d30a2c (diff) | |
download | tor-57da1a5057a3d95a9093384a3797d5a404863c5a.tar tor-57da1a5057a3d95a9093384a3797d5a404863c5a.tar.gz |
add test case for node_get_verbose_nickname
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_nodelist.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c index b01ceed77..cbdc4a72b 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -30,11 +30,42 @@ test_nodelist_node_get_verbose_nickname_by_id_null_node(void *arg) return; } +/** For routers without named flag, get_verbose_nickname should return + * "Fingerprint~Nickname" + */ +static void +test_nodelist_node_get_verbose_nickname_not_named(void *arg) +{ + node_t mock_node; + routerstatus_t mock_rs; + + char vname[MAX_VERBOSE_NICKNAME_LEN+1]; + + (void) arg; + + memset(&mock_node, 0, sizeof(node_t)); + memset(&mock_rs, 0, sizeof(routerstatus_t)); + + /* verbose nickname should use ~ instead of = for unnamed routers */ + strncpy(mock_rs.nickname, "TestOR", 6); + mock_node.rs = &mock_rs; + strncpy(mock_node.identity, + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", + DIGEST_LEN); + node_get_verbose_nickname(&mock_node, vname); + test_streq(vname, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~TestOR"); + + done: + return; +} + #define NODE(name, flags) \ { #name, test_nodelist_##name, (flags), NULL, NULL } struct testcase_t nodelist_tests[] = { NODE(node_get_verbose_nickname_by_id_null_node, TT_FORK), + NODE(node_get_verbose_nickname_not_named, TT_FORK), END_OF_TESTCASES }; |