diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-24 10:53:38 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-24 10:53:38 -0500 |
commit | d29e3a02d57aef402a1aaf9747ef44393b043d98 (patch) | |
tree | 167123ebf54d20cc8ed7cb938c30b77977a7c17d /src/test/test_nodelist.c | |
parent | 0e9a963b6b87282011fe204e81b5c2530153a935 (diff) | |
download | tor-d29e3a02d57aef402a1aaf9747ef44393b043d98.tar.gz tor-d29e3a02d57aef402a1aaf9747ef44393b043d98.zip |
Add a function to canonicalize nodefamilies per prop298
This is the same as the regular canonical nodefamily format, except
that unrecognized elements are preserved.
Diffstat (limited to 'src/test/test_nodelist.c')
-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 afbcc60ac0..ed919f4edf 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -610,6 +610,36 @@ test_nodelist_node_nodefamily(void *arg) smartlist_free(nodes); } +static void +test_nodelist_nodefamily_canonicalize(void *arg) +{ + (void)arg; + char *c = NULL; + + c = nodefamily_canonicalize("", NULL, 0); + tt_str_op(c, OP_EQ, ""); + tor_free(c); + + uint8_t own_id[20]; + memset(own_id, 0, sizeof(own_id)); + c = nodefamily_canonicalize( + "alice BOB caroL %potrzebie !!!@#@# " + "$bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb=fred " + "ffffffffffffffffffffffffffffffffffffffff " + "$cccccccccccccccccccccccccccccccccccccccc ", own_id, 0); + tt_str_op(c, OP_EQ, + "!!!@#@# " + "$0000000000000000000000000000000000000000 " + "$BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB " + "$CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC " + "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF " + "%potrzebie " + "alice bob carol"); + + done: + tor_free(c); +} + #define NODE(name, flags) \ { #name, test_nodelist_##name, (flags), NULL, NULL } @@ -623,5 +653,6 @@ struct testcase_t nodelist_tests[] = { NODE(nodefamily_lookup, TT_FORK), NODE(nickname_matches, 0), NODE(node_nodefamily, TT_FORK), + NODE(nodefamily_canonicalize, 0), END_OF_TESTCASES }; |