summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-09-23 03:02:32 -0400
committerNick Mathewson <nickm@torproject.org>2009-10-15 15:17:13 -0400
commit3471057486a8aef0be6e74b090a3173e0794c84b (patch)
tree551f1b2e7a172176b32459005ac6dedd49e2c461 /src/test
parentd9c71816b15af4325fb8ab9befa8600185d9aa90 (diff)
downloadtor-3471057486a8aef0be6e74b090a3173e0794c84b.tar.gz
tor-3471057486a8aef0be6e74b090a3173e0794c84b.zip
Implement signatures for microdesc consensuses right.
This means we need to handle the existence of multiple flavors of signature in a detached signatures document, generate them correctly, and so on.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_dir.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index b1fac683cc..13b46c63c3 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -559,6 +559,21 @@ generate_ri_from_rs(const vote_routerstatus_t *vrs)
return r;
}
+/** Helper: get a detached signatures document for a single FLAV_NS
+ * consensus. */
+static char *
+get_detached_sigs(networkstatus_t *ns)
+{
+ char *r;
+ smartlist_t *sl;
+ tor_assert(ns && ns->flavor == FLAV_NS);
+ sl = smartlist_create();
+ smartlist_add(sl,ns);
+ r = networkstatus_get_detached_signatures(sl);
+ smartlist_free(sl);
+ return r;
+}
+
/** Run unit tests for generating and parsing V3 consensus networkstatus
* documents. */
static void
@@ -994,7 +1009,7 @@ test_dir_v3_networkstatus(void)
test_memeq(&con->digests, &con3->digests, sizeof(digests_t));
/* Extract a detached signature from con3. */
- detached_text1 = networkstatus_get_detached_signatures(con3);
+ detached_text1 = get_detached_sigs(con3);
tor_assert(detached_text1);
/* Try to parse it. */
dsig1 = networkstatus_parse_detached_signatures(detached_text1, NULL);
@@ -1020,10 +1035,10 @@ test_dir_v3_networkstatus(void)
}
/* Try adding it to con2. */
- detached_text2 = networkstatus_get_detached_signatures(con2);
+ detached_text2 = get_detached_sigs(con2);
test_eq(1, networkstatus_add_detached_signatures(con2, dsig1, &msg));
tor_free(detached_text2);
- detached_text2 = networkstatus_get_detached_signatures(con2);
+ detached_text2 = get_detached_sigs(con2);
//printf("\n<%s>\n", detached_text2);
dsig2 = networkstatus_parse_detached_signatures(detached_text2, NULL);
test_assert(dsig2);