From b77f56ac25b2072ee96b11c93d3bf696f1854ee1 Mon Sep 17 00:00:00 2001 From: Zike Yang Date: Mon, 25 Jul 2022 23:12:54 +0800 Subject: [PATCH] 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 --- raft/raft_paper_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raft/raft_paper_test.go b/raft/raft_paper_test.go index 9c71ebaa2..9577823d4 100644 --- a/raft/raft_paper_test.go +++ b/raft/raft_paper_test.go @@ -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) }