raft: add a single candidate test

release-2.0
Xiang Li 2014-05-28 11:59:01 -07:00 committed by Yicheng Qin
parent 2066ff5acb
commit 1170c21f89
1 changed files with 10 additions and 0 deletions

View File

@ -195,6 +195,16 @@ func TestCandidateConcede(t *testing.T) {
}
}
func TestSingleNodeCandidate(t *testing.T) {
tt := newNetwork(nil)
tt.Step(Message{To: 0, Type: msgHup})
sm := tt.ss[0].(*nsm)
if sm.state != stateLeader {
t.Errorf("state = %d, want %d", sm.state, stateLeader)
}
}
func TestOldMessages(t *testing.T) {
tt := newNetwork(nil, nil, nil)
// make 0 leader @ term 3