[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r16542: {tor} testsuite: Now that we add (pretty useless, but still) route (tor/trunk/src/or)



Author: weasel
Date: 2008-08-14 08:37:42 -0400 (Thu, 14 Aug 2008)
New Revision: 16542

Modified:
   tor/trunk/src/or/test.c
Log:
testsuite: Now that we add (pretty useless, but still) routerinfos to the routerlist for every one of our routerstatuses in the votes we pass again.  yay

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2008-08-14 12:37:34 UTC (rev 16541)
+++ tor/trunk/src/or/test.c	2008-08-14 12:37:42 UTC (rev 16542)
@@ -2862,12 +2862,31 @@
 #undef median
 }
 
+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));
+  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_create();
+  r->cache_info.published_on = ++published + time(NULL);
+  return r;
+};
+
 static void
 test_v3_networkstatus(void)
 {
   authority_cert_t *cert1, *cert2, *cert3;
   crypto_pk_env_t *sign_skey_1, *sign_skey_2, *sign_skey_3;
   crypto_pk_env_t *sign_skey_leg1;
+  const char *msg=NULL;
 
   time_t now = time(NULL);
   networkstatus_voter_info_t *voter;
@@ -2944,6 +2963,8 @@
   /* all flags but running cleared */
   rs->is_running = 1;
   smartlist_add(vote->routerstatus_list, vrs);
+  test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg, 0, 0) >= 0);
+
   /* add the second routerstatus. */
   vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
   rs = &vrs->status;
@@ -2958,6 +2979,8 @@
   rs->is_exit = rs->is_stable = rs->is_fast = rs->is_running =
     rs->is_valid = rs->is_v2_dir = rs->is_possible_guard = 1;
   smartlist_add(vote->routerstatus_list, vrs);
+  test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg, 0, 0) >= 0);
+
   /* add the third routerstatus. */
   vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
   rs = &vrs->status;
@@ -2965,13 +2988,15 @@
   rs->published_on = now-1000;
   strlcpy(rs->nickname, "router3", sizeof(rs->nickname));
   memset(rs->identity_digest, 33, DIGEST_LEN);
-  memset(rs->descriptor_digest, 78, 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_running = rs->is_valid = rs->is_v2_dir = rs->is_possible_guard = 1;
   smartlist_add(vote->routerstatus_list, vrs);
+  test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg, 0, 0) >= 0);
+
   /* add a fourth routerstatus that is not running. */
   vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
   rs = &vrs->status;
@@ -2985,9 +3010,8 @@
   rs->dir_port = 1999;
   /* Running flag (and others) cleared */
   smartlist_add(vote->routerstatus_list, vrs);
+  test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg, 0, 0) >= 0);
 
-/* XXX weasel */
-return;
   /* dump the vote and try to parse it. */
   v1_text = format_networkstatus_vote(sign_skey_1, vote);
   test_assert(v1_text);
@@ -3110,6 +3134,7 @@
   tor_free(vrs);
   vrs = smartlist_get(vote->routerstatus_list, 0);
   memset(vrs->status.descriptor_digest, (int)'Z', DIGEST_LEN);
+  test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg, 0, 0) >= 0);
 
   v3_text = format_networkstatus_vote(sign_skey_3, vote);
   test_assert(v3_text);