aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_shared_random.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2016-07-02 02:49:59 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2016-07-02 02:49:59 +0300
commit43d317f99c7f30ecf1066b3887d5ef83b75fdb49 (patch)
treea3ab8186a88dc088acf6869cb7b27649f360e015 /src/test/test_shared_random.c
parentbe78e9ff3782639b9fa72dcfa9bda559cfc83f17 (diff)
downloadtor-43d317f99c7f30ecf1066b3887d5ef83b75fdb49.tar.gz
tor-43d317f99c7f30ecf1066b3887d5ef83b75fdb49.zip
Fix edge case fail of shared random unittest.
The test_state_update() test would fail if you run it between 23:30 and 00:00UTC in the following line because n_protocol_runs was 2: tt_u64_op(state->n_protocol_runs, ==, 1); The problem is that when you launch the test at 23:30UTC (reveal phase), sr_state_update() gets called from sr_state_init() and it will prepare the state for the voting round at 00:00UTC (commit phase). Since we transition from reveal to commit phase, this would trigger a phase transition and increment the n_protocol_runs counter. The solution is to initialize the n_protocol_runs to 0 explicitly in the beginning of the test, as we do for n_reveal_rounds, n_commit_rounds etc.
Diffstat (limited to 'src/test/test_shared_random.c')
-rw-r--r--src/test/test_shared_random.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index d001785340..91a4c39cd0 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -1193,6 +1193,7 @@ test_state_update(void *arg)
state->valid_after = 0;
state->n_reveal_rounds = 0;
state->n_commit_rounds = 0;
+ state->n_protocol_runs = 0;
}
/* We need to mock for the state update function call. */