[or-cvs] r10588: More vote unit tests: check that we are parsing routerstatus (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Wed Jun 13 18:29:16 UTC 2007


Author: nickm
Date: 2007-06-13 14:29:16 -0400 (Wed, 13 Jun 2007)
New Revision: 10588

Modified:
   tor/trunk/
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/test.c
Log:
 r13393 at catbus:  nickm | 2007-06-13 14:29:14 -0400
 More vote unit tests: check that we are parsing routerstatuses correctly.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13393] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-06-13 18:16:05 UTC (rev 10587)
+++ tor/trunk/src/or/dirserv.c	2007-06-13 18:29:16 UTC (rev 10588)
@@ -1649,8 +1649,8 @@
                    rs->is_named?" Named":"",
                    rs->is_stable?" Stable":"",
                    rs->is_running?" Running":"",
-                   rs->is_valid?" Valid":"",
-                   rs->is_v2_dir?" V2Dir":"");
+                   rs->is_v2_dir?" V2Dir":"",
+                   rs->is_valid?" Valid":"");
   if (r<0) {
     log_warn(LD_BUG, "Not enough space in buffer.");
     return -1;

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-06-13 18:16:05 UTC (rev 10587)
+++ tor/trunk/src/or/test.c	2007-06-13 18:29:16 UTC (rev 10588)
@@ -2210,7 +2210,7 @@
   rs->published_on = now-1500;
   strlcpy(rs->nickname, "router2", sizeof(rs->nickname));
   memset(rs->identity_digest, 3, DIGEST_LEN);
-  memset(rs->descriptor_digest, 11, DIGEST_LEN);
+  memset(rs->descriptor_digest, 78, DIGEST_LEN);
   rs->addr = 0x99008801;
   rs->or_port = 443;
   rs->dir_port = 8000;
@@ -2223,13 +2223,12 @@
   rs->published_on = now-1000;
   strlcpy(rs->nickname, "router1", sizeof(rs->nickname));
   memset(rs->identity_digest, 5, DIGEST_LEN);
-  memset(rs->descriptor_digest, 2, DIGEST_LEN);
+  memset(rs->descriptor_digest, 77, DIGEST_LEN);
   rs->addr = 0x99009901;
   rs->or_port = 443;
   rs->dir_port = 0;
   rs->is_exit = rs->is_stable = rs->is_fast = rs->is_running =
-    rs->is_v2_dir = rs->is_possible_guard = 1;
-  // rs->named = rs->is_bad_exit = rs->is_bad_directory = 1;
+    rs->is_valid = rs->is_v2_dir = rs->is_possible_guard = 1;
   smartlist_add(vote->routerstatus_list, vrs);
 
   /* dump the vote and try to parse it. */
@@ -2263,7 +2262,34 @@
   test_streq(cp, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
   tor_free(cp);
   test_eq(smartlist_len(v1->routerstatus_list), 2);
-  /*XXXX020 test contents of v1->routerstatus_list. */
+  /* Check the first routerstatus. */
+  vrs = smartlist_get(v1->routerstatus_list, 0);
+  rs = &vrs->status;
+  test_streq(vrs->version, "0.1.2.14");
+  test_eq(rs->published_on, now-1500);
+  test_streq(rs->nickname, "router2");
+  test_memeq(rs->identity_digest,
+             "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
+             DIGEST_LEN);
+  test_memeq(rs->descriptor_digest, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
+  test_eq(rs->addr, 0x099008801);
+  test_eq(rs->or_port, 443);
+  test_eq(rs->dir_port, 8000);
+  test_eq(vrs->flags, U64_LITERAL(0));
+  /* Check the second routerstatus. */
+  vrs = smartlist_get(v1->routerstatus_list, 1);
+  rs = &vrs->status;
+  test_streq(vrs->version, "0.2.0.5");
+  test_eq(rs->published_on, now-1000);
+  test_streq(rs->nickname, "router1");
+  test_memeq(rs->identity_digest,
+             "\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
+             DIGEST_LEN);
+  test_memeq(rs->descriptor_digest, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
+  test_eq(rs->addr, 0x099009901);
+  test_eq(rs->or_port, 443);
+  test_eq(rs->dir_port, 0);
+  test_eq(vrs->flags, U64_LITERAL(254)); // all flags except "authority."
 
   /* XXXXX020 Generate 2 more votes */
 



More information about the tor-commits mailing list