]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'ticket29806_035_squashed_merged' into ticket29806_040_squashed_merged
authorteor <teor@torproject.org>
Tue, 26 Mar 2019 01:48:52 +0000 (11:48 +1000)
committerteor <teor@torproject.org>
Tue, 26 Mar 2019 01:48:52 +0000 (11:48 +1000)
1  2 
src/feature/dirauth/bwauth.c
src/test/test_dir.c

Simple merge
index 4132d42d12b3cbbc76ac3ff7c1ad5b0348a5c375,0e44c47f3f7ba7f29bbd8e5ab425f420059007c1..b9a48c65060bf23b3b8ee3743ccdead9522a12da
@@@ -2029,8 -1998,45 +2048,46 @@@ test_dir_dirserv_read_measured_bandwidt
    smartlist_free(bw_file_headers);
    tor_free(bw_file_headers_str);
  
+   /* Test v1.x.x bandwidth line with vote=0.
+    * It will be ignored it and logged it at debug level. */
+   const char *relay_lines_ignore =
+     "node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=0\n"
+     "node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=0"
+     "unmeasured=1\n"
+     "node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=0"
+     "unmeasured=0\n";
+   /* Create the bandwidth file */
+   tor_asprintf(&content, "%ld\n%s", (long)timestamp, relay_lines_ignore);
+   write_str_to_file(fname, content, 0);
+   tor_free(content);
+   /* Read the bandwidth file */
+   setup_full_capture_of_logs(LOG_DEBUG);
+   tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL, NULL));
+   expect_log_msg_containing("Ignoring bandwidth file line");
+   teardown_capture_of_logs();
+   /* Test v1.x.x bandwidth line with "vote=1" or "unmeasured=1" or
+    * "unmeasured=0".
+    * They will not be ignored. */
+   /* Create the bandwidth file */
+   const char *relay_lines_vote =
+     "node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=1\n"
+     "node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 unmeasured=0\n"
+     "node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 unmeasured=1\n";
+   tor_asprintf(&content, "%ld\n%s", (long)timestamp, relay_lines_vote);
+   write_str_to_file(fname, content, 0);
+   tor_free(content);
+   /* Read the bandwidth file */
+   setup_full_capture_of_logs(LOG_DEBUG);
+   tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL, NULL));
+   expect_log_msg_not_containing("Ignoring bandwidth file line");
+   teardown_capture_of_logs();
   done:
 +  unlink(fname);
    tor_free(fname);
    tor_free(header_lines_v100);
    tor_free(header_lines_v110_no_terminator);