summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-24 10:30:15 -0500
committerNick Mathewson <nickm@torproject.org>2018-11-24 10:30:15 -0500
commit0e9a963b6b87282011fe204e81b5c2530153a935 (patch)
tree8fe4464dc2e2c850d579db45d1ebb3b366291cab /src/test
parent3741f9e524a2d3bd7239ca865d6169fd1e3dddb5 (diff)
downloadtor-0e9a963b6b87282011fe204e81b5c2530153a935.tar.gz
tor-0e9a963b6b87282011fe204e81b5c2530153a935.zip
Revise nodefamily.c to match proposal 298
Prop298 says that family entries should be formatted with $hexids in uppercase, nicknames in lower case, $hexid~names truncated, and everything sorted lexically. These changes implement that ordering for nodefamily.c. We don't _strictly speaking_ need to nodefamily.c formatting use this for prop298 microdesc generation, but it seems silly to have two separate canonicalization algorithms.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_microdesc.c2
-rw-r--r--src/test/test_nodelist.c18
2 files changed, 10 insertions, 10 deletions
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 3318408d53..debb11155a 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -176,7 +176,7 @@ test_md_cache(void *data)
tt_ptr_op(md3->family, OP_NE, NULL);
encoded_family = nodefamily_format(md3->family);
- tt_str_op(encoded_family, OP_EQ, "nodeX nodeY nodeZ");
+ tt_str_op(encoded_family, OP_EQ, "nodex nodey nodez");
/* Now rebuild the cache! */
tt_int_op(microdesc_cache_rebuild(mc, 1), OP_EQ, 0);
diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c
index 0287be3305..afbcc60ac0 100644
--- a/src/test/test_nodelist.c
+++ b/src/test/test_nodelist.c
@@ -299,7 +299,7 @@ test_nodelist_nodefamily(void *arg)
tt_ptr_op(nf1, OP_EQ, nf3);
/* Do we get the expected result when we re-encode? */
- tor_asprintf(&enc, "hello $%s", h1);
+ tor_asprintf(&enc, "$%s hello", h1);
enc2 = nodefamily_format(nf1);
tt_str_op(enc2, OP_EQ, enc);
tor_free(enc2);
@@ -399,8 +399,8 @@ test_nodelist_nodefamily_parse_err(void *arg)
tt_assert(nf1);
enc = nodefamily_format(nf1);
tt_str_op(enc, OP_EQ,
- "reticulatogranulate "
- "$7468696E67732D696E2D7468656D73656C766573");
+ "$7468696E67732D696E2D7468656D73656C766573 "
+ "reticulatogranulate");
tor_free(enc);
}
@@ -470,11 +470,11 @@ test_nodelist_nodefamily_lookup(void *arg)
tt_int_op(smartlist_len(sl), OP_EQ, 3);
const node_t *n = smartlist_get(sl, 0);
- tt_str_op(n->identity, OP_EQ, "erewhon");
- n = smartlist_get(sl, 1);
test_memeq_hex(n->identity, "3333333333333333333333333333333333333333");
- n = smartlist_get(sl, 2);
+ n = smartlist_get(sl, 1);
test_memeq_hex(n->identity, "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
+ n = smartlist_get(sl, 2);
+ tt_str_op(n->identity, OP_EQ, "erewhon");
done:
UNMOCK(node_get_by_nickname);
@@ -583,9 +583,9 @@ test_nodelist_node_nodefamily(void *arg)
node_lookup_declared_family(nodes, &mock_node1);
tt_int_op(smartlist_len(nodes), OP_EQ, 2);
const node_t *n = smartlist_get(nodes, 0);
- tt_str_op(n->identity, OP_EQ, "NodeFour");
- n = smartlist_get(nodes, 1);
tt_mem_op(n->identity, OP_EQ, "SecondNodeWe'reTestn", DIGEST_LEN);
+ n = smartlist_get(nodes, 1);
+ tt_str_op(n->identity, OP_EQ, "nodefour");
// free, try the other one.
SMARTLIST_FOREACH(nodes, node_t *, x, tor_free(x));
@@ -594,9 +594,9 @@ test_nodelist_node_nodefamily(void *arg)
node_lookup_declared_family(nodes, &mock_node2);
tt_int_op(smartlist_len(nodes), OP_EQ, 2);
n = smartlist_get(nodes, 0);
+ // This gets a truncated hex hex ID since it was looked up by name
tt_str_op(n->identity, OP_EQ, "NodeThree");
n = smartlist_get(nodes, 1);
- // This gets a truncated hex hex ID since it was looked up by name
tt_str_op(n->identity, OP_EQ, "4e6f64654f6e654e6f6");
done: