|
@@ -26,6 +26,7 @@
|
|
#include "routerparse.h"
|
|
#include "routerparse.h"
|
|
#include "routerset.h"
|
|
#include "routerset.h"
|
|
#include "test.h"
|
|
#include "test.h"
|
|
|
|
+#include "test_dir_common.h"
|
|
#include "torcert.h"
|
|
#include "torcert.h"
|
|
|
|
|
|
static void
|
|
static void
|
|
@@ -300,6 +301,8 @@ test_dir_formats(void *arg)
|
|
strlcat(buf2, "tunnelled-dir-server\n", sizeof(buf2));
|
|
strlcat(buf2, "tunnelled-dir-server\n", sizeof(buf2));
|
|
strlcat(buf2, "router-sig-ed25519 ", sizeof(buf2));
|
|
strlcat(buf2, "router-sig-ed25519 ", sizeof(buf2));
|
|
|
|
|
|
|
|
+ options->ORPort_set = 1;
|
|
|
|
+
|
|
buf = router_dump_router_to_string(r2, pk1, pk2, &r2_onion_keypair, &kp2);
|
|
buf = router_dump_router_to_string(r2, pk1, pk2, &r2_onion_keypair, &kp2);
|
|
tt_assert(buf);
|
|
tt_assert(buf);
|
|
buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same
|
|
buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same
|
|
@@ -1489,13 +1492,6 @@ test_dir_param_voting(void *arg)
|
|
return;
|
|
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[];
|
|
|
|
-
|
|
|
|
/** Helper: Test that two networkstatus_voter_info_t do in fact represent the
|
|
/** Helper: Test that two networkstatus_voter_info_t do in fact represent the
|
|
* same voting authority, and that they do in fact have all the same
|
|
* same voting authority, and that they do in fact have all the same
|
|
* information. */
|
|
* information. */
|
|
@@ -1515,42 +1511,6 @@ test_same_voter(networkstatus_voter_info_t *v1,
|
|
;
|
|
;
|
|
}
|
|
}
|
|
|
|
|
|
-/** Helper: Make a new routerinfo containing the right information for a
|
|
|
|
- * 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;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/** Helper: get a detached signatures document for one or two
|
|
/** Helper: get a detached signatures document for one or two
|
|
* consensuses. */
|
|
* consensuses. */
|
|
static char *
|
|
static char *
|
|
@@ -1568,101 +1528,6 @@ get_detached_sigs(networkstatus_t *ns, networkstatus_t *ns2)
|
|
return r;
|
|
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:
|
|
|
|
- /* Generate the first routerstatus. */
|
|
|
|
- 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;
|
|
|
|
- /* all flags but running and v2dir cleared */
|
|
|
|
- rs->is_flagged_running = 1;
|
|
|
|
- rs->is_v2_dir = 1;
|
|
|
|
- break;
|
|
|
|
- case 1:
|
|
|
|
- /* Generate the second routerstatus. */
|
|
|
|
- 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 = rs->is_v2_dir = 1;
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- /* Generate the third routerstatus. */
|
|
|
|
- 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_v2_dir =
|
|
|
|
- rs->is_possible_guard = 1;
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- /* Generate a fourth routerstatus that is not running. */
|
|
|
|
- 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;
|
|
|
|
- /* Running flag (and others) cleared */
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- /* No more for this test; return NULL */
|
|
|
|
- vrs = NULL;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- /* Shouldn't happen */
|
|
|
|
- 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;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/** Apply tweaks to the vote list for each voter */
|
|
/** Apply tweaks to the vote list for each voter */
|
|
static int
|
|
static int
|
|
vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
|
|
vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
|
|
@@ -1694,7 +1559,7 @@ vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
|
|
vrs = smartlist_get(v->routerstatus_list, 0);
|
|
vrs = smartlist_get(v->routerstatus_list, 0);
|
|
memset(vrs->status.descriptor_digest, (int)'Z', DIGEST_LEN);
|
|
memset(vrs->status.descriptor_digest, (int)'Z', DIGEST_LEN);
|
|
tt_assert(router_add_to_routerlist(
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1884,7 +1749,6 @@ test_a_networkstatus(
|
|
authority_cert_t *cert1=NULL, *cert2=NULL, *cert3=NULL;
|
|
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_1=NULL, *sign_skey_2=NULL, *sign_skey_3=NULL;
|
|
crypto_pk_t *sign_skey_leg1=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()
|
|
* 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
|
|
* returns non-zero, it changed net_params and we should skip the tests for
|
|
@@ -1900,8 +1764,7 @@ test_a_networkstatus(
|
|
vote_routerstatus_t *vrs;
|
|
vote_routerstatus_t *vrs;
|
|
routerstatus_t *rs;
|
|
routerstatus_t *rs;
|
|
int idx, n_rs, n_vrs;
|
|
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();
|
|
smartlist_t *votes = smartlist_new();
|
|
|
|
|
|
/* For generating the two other consensuses. */
|
|
/* For generating the two other consensuses. */
|
|
@@ -1916,79 +1779,13 @@ test_a_networkstatus(
|
|
tt_assert(rs_test);
|
|
tt_assert(rs_test);
|
|
tt_assert(vrs_test);
|
|
tt_assert(vrs_test);
|
|
|
|
|
|
- /* Parse certificates and keys. */
|
|
|
|
- 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);
|
|
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();
|
|
|
|
- /* add routerstatuses */
|
|
|
|
- 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;
|
|
|
|
-
|
|
|
|
- /* dump the vote and try to parse it. */
|
|
|
|
- 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);
|
|
tt_assert(v1);
|
|
|
|
|
|
/* Make sure the parsed thing was right. */
|
|
/* Make sure the parsed thing was right. */
|
|
@@ -2015,6 +1812,7 @@ test_a_networkstatus(
|
|
tt_str_op(cp,OP_EQ, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
|
|
tt_str_op(cp,OP_EQ, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
|
|
tor_free(cp);
|
|
tor_free(cp);
|
|
tt_int_op(smartlist_len(v1->routerstatus_list),OP_EQ, n_vrs);
|
|
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);
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v1, 1, now);
|
|
|
|
|
|
@@ -2026,33 +1824,10 @@ test_a_networkstatus(
|
|
}
|
|
}
|
|
|
|
|
|
/* Generate second vote. It disagrees on some of the times,
|
|
/* Generate second vote. It disagrees on some of the times,
|
|
- * 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);
|
|
|
|
-
|
|
|
|
- /* generate and parse v2. */
|
|
|
|
- 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);
|
|
tt_assert(v2);
|
|
|
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v2, 2, now);
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v2, 2, now);
|
|
@@ -2070,34 +1845,11 @@ test_a_networkstatus(
|
|
tt_assert(vrs);
|
|
tt_assert(vrs);
|
|
vrs_test(vrs, 2, now);
|
|
vrs_test(vrs, 2, now);
|
|
}
|
|
}
|
|
|
|
+ tor_free(vote);
|
|
|
|
|
|
- /* Generate the third 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);
|
|
|
|
- /* This one has a legacy id. */
|
|
|
|
- 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);
|
|
|
|
|
|
+ /* Generate the third vote with a legacy id. */
|
|
|
|
+ tt_assert(!dir_common_construct_vote_3(&vote, cert3, sign_skey_3, vrs_gen,
|
|
|
|
+ &v3, &n_vrs, now, 1));
|
|
tt_assert(v3);
|
|
tt_assert(v3);
|
|
|
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v3, 3, now);
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v3, 3, now);
|
|
@@ -2324,9 +2076,6 @@ test_a_networkstatus(
|
|
done:
|
|
done:
|
|
tor_free(cp);
|
|
tor_free(cp);
|
|
smartlist_free(votes);
|
|
smartlist_free(votes);
|
|
- tor_free(v1_text);
|
|
|
|
- tor_free(v2_text);
|
|
|
|
- tor_free(v3_text);
|
|
|
|
tor_free(consensus_text);
|
|
tor_free(consensus_text);
|
|
tor_free(consensus_text_md);
|
|
tor_free(consensus_text_md);
|
|
|
|
|
|
@@ -2383,7 +2132,7 @@ static void
|
|
test_dir_v3_networkstatus(void *arg)
|
|
test_dir_v3_networkstatus(void *arg)
|
|
{
|
|
{
|
|
(void)arg;
|
|
(void)arg;
|
|
- test_a_networkstatus(gen_routerstatus_for_v3ns,
|
|
|
|
|
|
+ test_a_networkstatus(dir_common_gen_routerstatus_for_v3ns,
|
|
vote_tweaks_for_v3ns,
|
|
vote_tweaks_for_v3ns,
|
|
test_vrs_for_v3ns,
|
|
test_vrs_for_v3ns,
|
|
test_consensus_for_v3ns,
|
|
test_consensus_for_v3ns,
|