|
@@ -26,6 +26,7 @@
|
|
|
#include "routerparse.h"
|
|
|
#include "routerset.h"
|
|
|
#include "test.h"
|
|
|
+#include "test_dir_common.h"
|
|
|
#include "torcert.h"
|
|
|
|
|
|
static void
|
|
@@ -110,6 +111,7 @@ test_dir_formats(void *arg)
|
|
|
r1->cache_info.published_on = 0;
|
|
|
r1->or_port = 9000;
|
|
|
r1->dir_port = 9003;
|
|
|
+ r1->supports_tunnelled_dir_requests = 1;
|
|
|
tor_addr_parse(&r1->ipv6_addr, "1:2:3:4::");
|
|
|
r1->ipv6_orport = 9999;
|
|
|
r1->onion_pkey = crypto_pk_dup_key(pk1);
|
|
@@ -154,6 +156,7 @@ test_dir_formats(void *arg)
|
|
|
r2->cache_info.published_on = 5;
|
|
|
r2->or_port = 9005;
|
|
|
r2->dir_port = 0;
|
|
|
+ r2->supports_tunnelled_dir_requests = 1;
|
|
|
r2->onion_pkey = crypto_pk_dup_key(pk2);
|
|
|
curve25519_keypair_t r2_onion_keypair;
|
|
|
curve25519_keypair_generate(&r2_onion_keypair, 0);
|
|
@@ -174,7 +177,9 @@ test_dir_formats(void *arg)
|
|
|
|
|
|
options->ContactInfo = tor_strdup("Magri White "
|
|
|
"<magri@elsewhere.example.com>");
|
|
|
+
|
|
|
buf = router_dump_router_to_string(r1, pk2, NULL, NULL, NULL);
|
|
|
+
|
|
|
tor_free(options->ContactInfo);
|
|
|
tt_assert(buf);
|
|
|
|
|
@@ -200,7 +205,8 @@ test_dir_formats(void *arg)
|
|
|
strlcat(buf2, "hidden-service-dir\n", sizeof(buf2));
|
|
|
strlcat(buf2, "contact Magri White <magri@elsewhere.example.com>\n",
|
|
|
sizeof(buf2));
|
|
|
- strlcat(buf2, "reject *:*\nrouter-signature\n", sizeof(buf2));
|
|
|
+ strlcat(buf2, "reject *:*\n", sizeof(buf2));
|
|
|
+ strlcat(buf2, "tunnelled-dir-server\nrouter-signature\n", sizeof(buf2));
|
|
|
buf[strlen(buf2)] = '\0';
|
|
|
* twice */
|
|
|
|
|
@@ -214,12 +220,13 @@ test_dir_formats(void *arg)
|
|
|
tt_assert(rp1);
|
|
|
tt_int_op(rp1->addr,OP_EQ, r1->addr);
|
|
|
tt_int_op(rp1->or_port,OP_EQ, r1->or_port);
|
|
|
-
|
|
|
+ tt_int_op(rp1->dir_port,OP_EQ, r1->dir_port);
|
|
|
tt_int_op(rp1->bandwidthrate,OP_EQ, r1->bandwidthrate);
|
|
|
tt_int_op(rp1->bandwidthburst,OP_EQ, r1->bandwidthburst);
|
|
|
tt_int_op(rp1->bandwidthcapacity,OP_EQ, r1->bandwidthcapacity);
|
|
|
tt_assert(crypto_pk_cmp_keys(rp1->onion_pkey, pk1) == 0);
|
|
|
tt_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0);
|
|
|
+ tt_assert(rp1->supports_tunnelled_dir_requests);
|
|
|
|
|
|
tor_free(buf);
|
|
|
|
|
@@ -290,6 +297,7 @@ test_dir_formats(void *arg)
|
|
|
BASE64_ENCODE_MULTILINE);
|
|
|
strlcat(buf2, cert_buf, sizeof(buf2));
|
|
|
strlcat(buf2, "accept *:80\nreject 18.0.0.0/8:24\n", sizeof(buf2));
|
|
|
+ strlcat(buf2, "tunnelled-dir-server\n", sizeof(buf2));
|
|
|
strlcat(buf2, "router-sig-ed25519 ", sizeof(buf2));
|
|
|
|
|
|
buf = router_dump_router_to_string(r2, pk1, pk2, &r2_onion_keypair, &kp2);
|
|
@@ -301,6 +309,8 @@ test_dir_formats(void *arg)
|
|
|
tor_free(buf);
|
|
|
|
|
|
buf = router_dump_router_to_string(r2, pk1, NULL, NULL, NULL);
|
|
|
+
|
|
|
+
|
|
|
cp = buf;
|
|
|
rp2 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL,NULL);
|
|
|
tt_assert(rp2);
|
|
@@ -315,6 +325,7 @@ test_dir_formats(void *arg)
|
|
|
CURVE25519_PUBKEY_LEN);
|
|
|
tt_assert(crypto_pk_cmp_keys(rp2->onion_pkey, pk2) == 0);
|
|
|
tt_assert(crypto_pk_cmp_keys(rp2->identity_pkey, pk1) == 0);
|
|
|
+ tt_assert(rp2->supports_tunnelled_dir_requests);
|
|
|
|
|
|
tt_int_op(smartlist_len(rp2->exit_policy),OP_EQ, 2);
|
|
|
|
|
@@ -1477,13 +1488,6 @@ test_dir_param_voting(void *arg)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-extern const char AUTHORITY_CERT_1[];
|
|
|
-extern const char AUTHORITY_SIGNKEY_1[];
|
|
|
-extern const char AUTHORITY_CERT_2[];
|
|
|
-extern const char AUTHORITY_SIGNKEY_2[];
|
|
|
-extern const char AUTHORITY_CERT_3[];
|
|
|
-extern const char AUTHORITY_SIGNKEY_3[];
|
|
|
-
|
|
|
|
|
|
* same voting authority, and that they do in fact have all the same
|
|
|
* information. */
|
|
@@ -1503,42 +1507,6 @@ test_same_voter(networkstatus_voter_info_t *v1,
|
|
|
;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * given vote_routerstatus_t. */
|
|
|
-static routerinfo_t *
|
|
|
-generate_ri_from_rs(const vote_routerstatus_t *vrs)
|
|
|
-{
|
|
|
- routerinfo_t *r;
|
|
|
- const routerstatus_t *rs = &vrs->status;
|
|
|
- static time_t published = 0;
|
|
|
-
|
|
|
- r = tor_malloc_zero(sizeof(routerinfo_t));
|
|
|
- r->cert_expiration_time = TIME_MAX;
|
|
|
- memcpy(r->cache_info.identity_digest, rs->identity_digest, DIGEST_LEN);
|
|
|
- memcpy(r->cache_info.signed_descriptor_digest, rs->descriptor_digest,
|
|
|
- DIGEST_LEN);
|
|
|
- r->cache_info.do_not_cache = 1;
|
|
|
- r->cache_info.routerlist_index = -1;
|
|
|
- r->cache_info.signed_descriptor_body =
|
|
|
- tor_strdup("123456789012345678901234567890123");
|
|
|
- r->cache_info.signed_descriptor_len =
|
|
|
- strlen(r->cache_info.signed_descriptor_body);
|
|
|
- r->exit_policy = smartlist_new();
|
|
|
- r->cache_info.published_on = ++published + time(NULL);
|
|
|
- if (rs->has_bandwidth) {
|
|
|
-
|
|
|
- * Multiply by 1000 because the routerinfo_t and the routerstatus_t
|
|
|
- * seem to use different units (*sigh*) and because we seem stuck on
|
|
|
- * icky and perverse decimal kilobytes (*double sigh*) - see
|
|
|
- * router_get_advertised_bandwidth_capped() of routerlist.c and
|
|
|
- * routerstatus_format_entry() of dirserv.c.
|
|
|
- */
|
|
|
- r->bandwidthrate = rs->bandwidth_kb * 1000;
|
|
|
- r->bandwidthcapacity = rs->bandwidth_kb * 1000;
|
|
|
- }
|
|
|
- return r;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
* consensuses. */
|
|
|
static char *
|
|
@@ -1556,100 +1524,6 @@ get_detached_sigs(networkstatus_t *ns, networkstatus_t *ns2)
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * Generate a routerstatus for v3_networkstatus test
|
|
|
- */
|
|
|
-static vote_routerstatus_t *
|
|
|
-gen_routerstatus_for_v3ns(int idx, time_t now)
|
|
|
-{
|
|
|
- vote_routerstatus_t *vrs=NULL;
|
|
|
- routerstatus_t *rs;
|
|
|
- tor_addr_t addr_ipv6;
|
|
|
-
|
|
|
- switch (idx) {
|
|
|
- case 0:
|
|
|
-
|
|
|
- vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
- rs = &vrs->status;
|
|
|
- vrs->version = tor_strdup("0.1.2.14");
|
|
|
- rs->published_on = now-1500;
|
|
|
- strlcpy(rs->nickname, "router2", sizeof(rs->nickname));
|
|
|
- memset(rs->identity_digest, 3, DIGEST_LEN);
|
|
|
- memset(rs->descriptor_digest, 78, DIGEST_LEN);
|
|
|
- rs->addr = 0x99008801;
|
|
|
- rs->or_port = 443;
|
|
|
- rs->dir_port = 8000;
|
|
|
-
|
|
|
- rs->is_flagged_running = 1;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
-
|
|
|
- vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
- rs = &vrs->status;
|
|
|
- vrs->version = tor_strdup("0.2.0.5");
|
|
|
- rs->published_on = now-1000;
|
|
|
- strlcpy(rs->nickname, "router1", sizeof(rs->nickname));
|
|
|
- memset(rs->identity_digest, 5, DIGEST_LEN);
|
|
|
- memset(rs->descriptor_digest, 77, DIGEST_LEN);
|
|
|
- rs->addr = 0x99009901;
|
|
|
- rs->or_port = 443;
|
|
|
- rs->dir_port = 0;
|
|
|
- tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
|
|
|
- tor_addr_copy(&rs->ipv6_addr, &addr_ipv6);
|
|
|
- rs->ipv6_orport = 4711;
|
|
|
- rs->is_exit = rs->is_stable = rs->is_fast = rs->is_flagged_running =
|
|
|
- rs->is_valid = rs->is_possible_guard = 1;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
-
|
|
|
- vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
- rs = &vrs->status;
|
|
|
- vrs->version = tor_strdup("0.1.0.3");
|
|
|
- rs->published_on = now-1000;
|
|
|
- strlcpy(rs->nickname, "router3", sizeof(rs->nickname));
|
|
|
- memset(rs->identity_digest, 33, DIGEST_LEN);
|
|
|
- memset(rs->descriptor_digest, 79, DIGEST_LEN);
|
|
|
- rs->addr = 0xAA009901;
|
|
|
- rs->or_port = 400;
|
|
|
- rs->dir_port = 9999;
|
|
|
- rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
|
|
|
- rs->is_flagged_running = rs->is_valid =
|
|
|
- rs->is_possible_guard = 1;
|
|
|
- break;
|
|
|
- case 3:
|
|
|
-
|
|
|
- vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
- rs = &vrs->status;
|
|
|
- vrs->version = tor_strdup("0.1.6.3");
|
|
|
- rs->published_on = now-1000;
|
|
|
- strlcpy(rs->nickname, "router4", sizeof(rs->nickname));
|
|
|
- memset(rs->identity_digest, 34, DIGEST_LEN);
|
|
|
- memset(rs->descriptor_digest, 47, DIGEST_LEN);
|
|
|
- rs->addr = 0xC0000203;
|
|
|
- rs->or_port = 500;
|
|
|
- rs->dir_port = 1999;
|
|
|
-
|
|
|
- break;
|
|
|
- case 4:
|
|
|
-
|
|
|
- vrs = NULL;
|
|
|
- break;
|
|
|
- default:
|
|
|
-
|
|
|
- tt_assert(0);
|
|
|
- }
|
|
|
- if (vrs) {
|
|
|
- vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
|
|
|
- tor_asprintf(&vrs->microdesc->microdesc_hash_line,
|
|
|
- "m 9,10,11,12,13,14,15,16,17 "
|
|
|
- "sha256=xyzajkldsdsajdadlsdjaslsdksdjlsdjsdaskdaaa%d\n",
|
|
|
- idx);
|
|
|
- }
|
|
|
-
|
|
|
- done:
|
|
|
- return vrs;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
static int
|
|
|
vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
|
|
@@ -1681,7 +1555,7 @@ vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
|
|
|
vrs = smartlist_get(v->routerstatus_list, 0);
|
|
|
memset(vrs->status.descriptor_digest, (int)'Z', DIGEST_LEN);
|
|
|
tt_assert(router_add_to_routerlist(
|
|
|
- generate_ri_from_rs(vrs), &msg,0,0) >= 0);
|
|
|
+ dir_common_generate_ri_from_rs(vrs), &msg,0,0) >= 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1746,11 +1620,11 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
|
|
|
tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
|
|
|
tt_int_op(rs->ipv6_orport,OP_EQ, 4711);
|
|
|
if (voter == 1) {
|
|
|
-
|
|
|
- tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(190));
|
|
|
+
|
|
|
+ tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(254));
|
|
|
} else {
|
|
|
-
|
|
|
- tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(718));
|
|
|
+
|
|
|
+ tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(974));
|
|
|
}
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
|
|
@@ -1820,6 +1694,7 @@ test_routerstatus_for_v3ns(routerstatus_t *rs, time_t now)
|
|
|
tt_assert(rs->is_flagged_running);
|
|
|
tt_assert(!rs->is_valid);
|
|
|
tt_assert(!rs->is_named);
|
|
|
+ tt_assert(rs->is_v2_dir);
|
|
|
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
@@ -1845,6 +1720,7 @@ test_routerstatus_for_v3ns(routerstatus_t *rs, time_t now)
|
|
|
tt_assert(rs->is_stable);
|
|
|
tt_assert(rs->is_flagged_running);
|
|
|
tt_assert(rs->is_valid);
|
|
|
+ tt_assert(rs->is_v2_dir);
|
|
|
tt_assert(!rs->is_named);
|
|
|
|
|
|
} else {
|
|
@@ -1869,7 +1745,6 @@ test_a_networkstatus(
|
|
|
authority_cert_t *cert1=NULL, *cert2=NULL, *cert3=NULL;
|
|
|
crypto_pk_t *sign_skey_1=NULL, *sign_skey_2=NULL, *sign_skey_3=NULL;
|
|
|
crypto_pk_t *sign_skey_leg1=NULL;
|
|
|
- const char *msg=NULL;
|
|
|
|
|
|
* Sum the non-zero returns from vote_tweaks() we've seen; if vote_tweaks()
|
|
|
* returns non-zero, it changed net_params and we should skip the tests for
|
|
@@ -1885,8 +1760,7 @@ test_a_networkstatus(
|
|
|
vote_routerstatus_t *vrs;
|
|
|
routerstatus_t *rs;
|
|
|
int idx, n_rs, n_vrs;
|
|
|
- char *v1_text=NULL, *v2_text=NULL, *v3_text=NULL, *consensus_text=NULL,
|
|
|
- *cp=NULL;
|
|
|
+ char *consensus_text=NULL, *cp=NULL;
|
|
|
smartlist_t *votes = smartlist_new();
|
|
|
|
|
|
|
|
@@ -1901,79 +1775,13 @@ test_a_networkstatus(
|
|
|
tt_assert(rs_test);
|
|
|
tt_assert(vrs_test);
|
|
|
|
|
|
-
|
|
|
- cert1 = authority_cert_parse_from_string(AUTHORITY_CERT_1, NULL);
|
|
|
- tt_assert(cert1);
|
|
|
- cert2 = authority_cert_parse_from_string(AUTHORITY_CERT_2, NULL);
|
|
|
- tt_assert(cert2);
|
|
|
- cert3 = authority_cert_parse_from_string(AUTHORITY_CERT_3, NULL);
|
|
|
- tt_assert(cert3);
|
|
|
- sign_skey_1 = crypto_pk_new();
|
|
|
- sign_skey_2 = crypto_pk_new();
|
|
|
- sign_skey_3 = crypto_pk_new();
|
|
|
+ tt_assert(!dir_common_authority_pk_init(&cert1, &cert2, &cert3,
|
|
|
+ &sign_skey_1, &sign_skey_2,
|
|
|
+ &sign_skey_3));
|
|
|
sign_skey_leg1 = pk_generate(4);
|
|
|
|
|
|
- tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_1,
|
|
|
- AUTHORITY_SIGNKEY_1, -1));
|
|
|
- tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_2,
|
|
|
- AUTHORITY_SIGNKEY_2, -1));
|
|
|
- tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_3,
|
|
|
- AUTHORITY_SIGNKEY_3, -1));
|
|
|
-
|
|
|
- tt_assert(!crypto_pk_cmp_keys(sign_skey_1, cert1->signing_key));
|
|
|
- tt_assert(!crypto_pk_cmp_keys(sign_skey_2, cert2->signing_key));
|
|
|
-
|
|
|
-
|
|
|
- * Set up a vote; generate it; try to parse it.
|
|
|
- */
|
|
|
- vote = tor_malloc_zero(sizeof(networkstatus_t));
|
|
|
- vote->type = NS_TYPE_VOTE;
|
|
|
- vote->published = now;
|
|
|
- vote->valid_after = now+1000;
|
|
|
- vote->fresh_until = now+2000;
|
|
|
- vote->valid_until = now+3000;
|
|
|
- vote->vote_seconds = 100;
|
|
|
- vote->dist_seconds = 200;
|
|
|
- vote->supported_methods = smartlist_new();
|
|
|
- smartlist_split_string(vote->supported_methods, "1 2 3", NULL, 0, -1);
|
|
|
- vote->client_versions = tor_strdup("0.1.2.14,0.1.2.15");
|
|
|
- vote->server_versions = tor_strdup("0.1.2.14,0.1.2.15,0.1.2.16");
|
|
|
- vote->known_flags = smartlist_new();
|
|
|
- smartlist_split_string(vote->known_flags,
|
|
|
- "Authority Exit Fast Guard Running Stable V2Dir Valid",
|
|
|
- 0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
|
|
|
- vote->voters = smartlist_new();
|
|
|
- voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t));
|
|
|
- voter->nickname = tor_strdup("Voter1");
|
|
|
- voter->address = tor_strdup("1.2.3.4");
|
|
|
- voter->addr = 0x01020304;
|
|
|
- voter->dir_port = 80;
|
|
|
- voter->or_port = 9000;
|
|
|
- voter->contact = tor_strdup("voter@example.com");
|
|
|
- crypto_pk_get_digest(cert1->identity_key, voter->identity_digest);
|
|
|
- smartlist_add(vote->voters, voter);
|
|
|
- vote->cert = authority_cert_dup(cert1);
|
|
|
- vote->net_params = smartlist_new();
|
|
|
- smartlist_split_string(vote->net_params, "circuitwindow=101 foo=990",
|
|
|
- NULL, 0, 0);
|
|
|
- vote->routerstatus_list = smartlist_new();
|
|
|
-
|
|
|
- idx = 0;
|
|
|
- do {
|
|
|
- vrs = vrs_gen(idx, now);
|
|
|
- if (vrs) {
|
|
|
- smartlist_add(vote->routerstatus_list, vrs);
|
|
|
- tt_assert(router_add_to_routerlist(generate_ri_from_rs(vrs),
|
|
|
- &msg,0,0)>=0);
|
|
|
- ++idx;
|
|
|
- }
|
|
|
- } while (vrs);
|
|
|
- n_vrs = idx;
|
|
|
-
|
|
|
-
|
|
|
- v1_text = format_networkstatus_vote(sign_skey_1, vote);
|
|
|
- tt_assert(v1_text);
|
|
|
- v1 = networkstatus_parse_vote_from_string(v1_text, NULL, NS_TYPE_VOTE);
|
|
|
+ tt_assert(!dir_common_construct_vote_1(&vote, cert1, sign_skey_1, vrs_gen,
|
|
|
+ &v1, &n_vrs, now, 1));
|
|
|
tt_assert(v1);
|
|
|
|
|
|
|
|
@@ -2000,6 +1808,7 @@ test_a_networkstatus(
|
|
|
tt_str_op(cp,OP_EQ, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
|
|
|
tor_free(cp);
|
|
|
tt_int_op(smartlist_len(v1->routerstatus_list),OP_EQ, n_vrs);
|
|
|
+ tor_free(vote);
|
|
|
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v1, 1, now);
|
|
|
|
|
@@ -2011,33 +1820,10 @@ test_a_networkstatus(
|
|
|
}
|
|
|
|
|
|
|
|
|
- * and doesn't list versions, and knows some crazy flags */
|
|
|
- vote->published = now+1;
|
|
|
- vote->fresh_until = now+3005;
|
|
|
- vote->dist_seconds = 300;
|
|
|
- authority_cert_free(vote->cert);
|
|
|
- vote->cert = authority_cert_dup(cert2);
|
|
|
- SMARTLIST_FOREACH(vote->net_params, char *, c, tor_free(c));
|
|
|
- smartlist_clear(vote->net_params);
|
|
|
- smartlist_split_string(vote->net_params, "bar=2000000000 circuitwindow=20",
|
|
|
- NULL, 0, 0);
|
|
|
- tor_free(vote->client_versions);
|
|
|
- tor_free(vote->server_versions);
|
|
|
- voter = smartlist_get(vote->voters, 0);
|
|
|
- tor_free(voter->nickname);
|
|
|
- tor_free(voter->address);
|
|
|
- voter->nickname = tor_strdup("Voter2");
|
|
|
- voter->address = tor_strdup("2.3.4.5");
|
|
|
- voter->addr = 0x02030405;
|
|
|
- crypto_pk_get_digest(cert2->identity_key, voter->identity_digest);
|
|
|
- smartlist_add(vote->known_flags, tor_strdup("MadeOfCheese"));
|
|
|
- smartlist_add(vote->known_flags, tor_strdup("MadeOfTin"));
|
|
|
- smartlist_sort_strings(vote->known_flags);
|
|
|
-
|
|
|
-
|
|
|
- v2_text = format_networkstatus_vote(sign_skey_2, vote);
|
|
|
- tt_assert(v2_text);
|
|
|
- v2 = networkstatus_parse_vote_from_string(v2_text, NULL, NS_TYPE_VOTE);
|
|
|
+ * and doesn't list versions, and knows some crazy flags.
|
|
|
+ * Generate and parse v2. */
|
|
|
+ tt_assert(!dir_common_construct_vote_2(&vote, cert2, sign_skey_2, vrs_gen,
|
|
|
+ &v2, &n_vrs, now, 1));
|
|
|
tt_assert(v2);
|
|
|
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v2, 2, now);
|
|
@@ -2055,34 +1841,11 @@ test_a_networkstatus(
|
|
|
tt_assert(vrs);
|
|
|
vrs_test(vrs, 2, now);
|
|
|
}
|
|
|
+ tor_free(vote);
|
|
|
|
|
|
-
|
|
|
- vote->published = now;
|
|
|
- vote->fresh_until = now+2003;
|
|
|
- vote->dist_seconds = 250;
|
|
|
- authority_cert_free(vote->cert);
|
|
|
- vote->cert = authority_cert_dup(cert3);
|
|
|
- SMARTLIST_FOREACH(vote->net_params, char *, c, tor_free(c));
|
|
|
- smartlist_clear(vote->net_params);
|
|
|
- smartlist_split_string(vote->net_params, "circuitwindow=80 foo=660",
|
|
|
- NULL, 0, 0);
|
|
|
- smartlist_add(vote->supported_methods, tor_strdup("4"));
|
|
|
- vote->client_versions = tor_strdup("0.1.2.14,0.1.2.17");
|
|
|
- vote->server_versions = tor_strdup("0.1.2.10,0.1.2.15,0.1.2.16");
|
|
|
- voter = smartlist_get(vote->voters, 0);
|
|
|
- tor_free(voter->nickname);
|
|
|
- tor_free(voter->address);
|
|
|
- voter->nickname = tor_strdup("Voter3");
|
|
|
- voter->address = tor_strdup("3.4.5.6");
|
|
|
- voter->addr = 0x03040506;
|
|
|
- crypto_pk_get_digest(cert3->identity_key, voter->identity_digest);
|
|
|
-
|
|
|
- memset(voter->legacy_id_digest, (int)'A', DIGEST_LEN);
|
|
|
-
|
|
|
- v3_text = format_networkstatus_vote(sign_skey_3, vote);
|
|
|
- tt_assert(v3_text);
|
|
|
-
|
|
|
- v3 = networkstatus_parse_vote_from_string(v3_text, NULL, NS_TYPE_VOTE);
|
|
|
+
|
|
|
+ tt_assert(!dir_common_construct_vote_3(&vote, cert3, sign_skey_3, vrs_gen,
|
|
|
+ &v3, &n_vrs, now, 1));
|
|
|
tt_assert(v3);
|
|
|
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v3, 3, now);
|
|
@@ -2153,12 +1916,20 @@ test_a_networkstatus(
|
|
|
|
|
|
|
|
|
n_rs = smartlist_len(con->routerstatus_list);
|
|
|
+ tt_assert(n_rs);
|
|
|
for (idx = 0; idx < n_rs; ++idx) {
|
|
|
rs = smartlist_get(con->routerstatus_list, idx);
|
|
|
tt_assert(rs);
|
|
|
rs_test(rs, now);
|
|
|
}
|
|
|
|
|
|
+ n_rs = smartlist_len(con_md->routerstatus_list);
|
|
|
+ tt_assert(n_rs);
|
|
|
+ for (idx = 0; idx < n_rs; ++idx) {
|
|
|
+ rs = smartlist_get(con_md->routerstatus_list, idx);
|
|
|
+ tt_assert(rs);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* The second one hasn't signed. The fourth one has signed: validate it. */
|
|
|
voter = smartlist_get(con->voters, 1);
|
|
@@ -2309,9 +2080,6 @@ test_a_networkstatus(
|
|
|
done:
|
|
|
tor_free(cp);
|
|
|
smartlist_free(votes);
|
|
|
- tor_free(v1_text);
|
|
|
- tor_free(v2_text);
|
|
|
- tor_free(v3_text);
|
|
|
tor_free(consensus_text);
|
|
|
tor_free(consensus_text_md);
|
|
|
|
|
@@ -2368,7 +2136,7 @@ static void
|
|
|
test_dir_v3_networkstatus(void *arg)
|
|
|
{
|
|
|
(void)arg;
|
|
|
- test_a_networkstatus(gen_routerstatus_for_v3ns,
|
|
|
+ test_a_networkstatus(dir_common_gen_routerstatus_for_v3ns,
|
|
|
vote_tweaks_for_v3ns,
|
|
|
test_vrs_for_v3ns,
|
|
|
test_consensus_for_v3ns,
|
|
@@ -2965,6 +2733,7 @@ test_dir_fmt_control_ns(void *arg)
|
|
|
rs.is_fast = 1;
|
|
|
rs.is_flagged_running = 1;
|
|
|
rs.has_bandwidth = 1;
|
|
|
+ rs.is_v2_dir = 1;
|
|
|
rs.bandwidth_kb = 1000;
|
|
|
|
|
|
s = networkstatus_getinfo_helper_single(&rs);
|