tests: fix the logic of testNonleaderElectionTimeoutRandomized in raft_paper_test.go

In the test `testNonleaderElectionTimeoutRandomized`, the possible values of election timeout randomized out should be 10-19(inclusive), but the current test only tests the possible values as 11-19(inclusive), which is incorrect here. We need to expand the scope of the tests to ensure robustness, and also to make the logic clearer.

Signed-off-by: Zike Yang <zike@apache.org>
This commit is contained in:
Zike Yang 2022-07-25 23:12:54 +08:00
parent 08f4c340eb
commit b77f56ac25

View File

@ -325,7 +325,7 @@ func testNonleaderElectionTimeoutRandomized(t *testing.T, state StateType) {
timeouts[time] = true
}
for d := et + 1; d < 2*et; d++ {
for d := et; d < 2*et; d++ {
if !timeouts[d] {
t.Errorf("timeout in %d ticks should happen", d)
}