raft: add more assertions for dueling candidates test case

This commit is contained in:
swingbach@gmail.com 2016-05-18 14:20:02 +08:00
parent f2b2e0761a
commit c703ccab63

View File

@ -476,6 +476,16 @@ func TestDuelingCandidates(t *testing.T) {
nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
sm := nt.peers[1].(*raft)
if sm.state != StateLeader {
t.Errorf("state = %s, want %s", sm.state, StateLeader)
}
sm = nt.peers[3].(*raft)
if sm.state != StateCandidate {
t.Errorf("state = %s, want %s", sm.state, StateCandidate)
}
nt.recover()
nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})