Browse Source

raft: add more assertions for dueling candidates test case

swingbach@gmail.com 9 years ago
parent
commit
c703ccab63
1 changed files with 10 additions and 0 deletions
  1. 10 0
      raft/raft_test.go

+ 10 - 0
raft/raft_test.go

@@ -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: 1, To: 1, Type: pb.MsgHup})
 	nt.send(pb.Message{From: 3, To: 3, 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.recover()
 	nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
 	nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})