aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dirvote.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-12-09 13:10:53 -0500
committerGeorge Kadianakis <desnacked@riseup.net>2021-01-13 15:23:27 +0200
commitfb3704b45982e6a97dbad4e2d6e9cf7ba8fd1151 (patch)
treec88820b2837804cfd8825048073915b74928c042 /src/test/test_dirvote.c
parent2bfb76b927111824a2051d09b1f5542ee58e2a6f (diff)
downloadtor-fb3704b45982e6a97dbad4e2d6e9cf7ba8fd1151.tar.gz
tor-fb3704b45982e6a97dbad4e2d6e9cf7ba8fd1151.zip
New consensus method to find bwweightscale & maxunmeasuredbw correctly.
Our original code for parsing these parameters out of our list of parameters pre-dated us having the dirvote_get_intermediate_param_value() function... and it was buggy. Specifically, it would reject any " ... K=V ..." value where there were additional unconverted characters after the V, and use the default value instead, We haven't run into this yet because we've never voted for bwweightscale to be anything besides the default 10000, or maxunmeasuredbw to be anything besides the default 20. This requires a new consensus method because it is a change in how consensuses are computed. Fixes bug 19011; bugfix on 0.2.2.10-alpha.
Diffstat (limited to 'src/test/test_dirvote.c')
-rw-r--r--src/test/test_dirvote.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test_dirvote.c b/src/test/test_dirvote.c
index b5e57ad071..d92d1aaf90 100644
--- a/src/test/test_dirvote.c
+++ b/src/test/test_dirvote.c
@@ -656,6 +656,30 @@ done:
ROUTER_FREE(pppp);
}
+static void
+test_dirvote_parse_param_buggy(void *arg)
+{
+ (void)arg;
+
+ /* Tests for behavior with bug emulation to migrate away from bug 19011. */
+ tt_i64_op(extract_param_buggy("blah blah", "bwweightscale", 10000),
+ OP_EQ, 10000);
+ tt_i64_op(extract_param_buggy("bwweightscale=7", "bwweightscale", 10000),
+ OP_EQ, 7);
+ tt_i64_op(extract_param_buggy("bwweightscale=7 foo=9",
+ "bwweightscale", 10000),
+ OP_EQ, 10000);
+ tt_i64_op(extract_param_buggy("foo=7 bwweightscale=777 bar=9",
+ "bwweightscale", 10000),
+ OP_EQ, 10000);
+ tt_i64_op(extract_param_buggy("foo=7 bwweightscale=1234",
+ "bwweightscale", 10000),
+ OP_EQ, 1234);
+
+ done:
+ ;
+}
+
#define NODE(name, flags) \
{ \
#name, test_dirvote_##name, (flags), NULL, NULL \
@@ -668,4 +692,5 @@ struct testcase_t dirvote_tests[] = {
NODE(get_sybil_by_ip_version_ipv4, TT_FORK),
NODE(get_sybil_by_ip_version_ipv6, TT_FORK),
NODE(get_all_possible_sybil, TT_FORK),
+ NODE(parse_param_buggy, 0),
END_OF_TESTCASES};