raft: fix promotable

This commit is contained in:
Yicheng Qin
2014-07-31 13:34:51 -07:00
parent 01c40fcf50
commit 15029381e1
3 changed files with 11 additions and 10 deletions

View File

@@ -13,8 +13,7 @@ const (
func TestTickMsgHup(t *testing.T) {
n := New(0, defaultHeartbeat, defaultElection)
n.sm = newStateMachine(0, []int64{0, 1, 2})
// simulate to patch the join log
n.Step(Message{From: 1, Type: msgApp, Commit: 1, Entries: []Entry{Entry{}}})
n.sm.promotable = true
for i := 0; i < defaultElection*2; i++ {
n.Tick()
@@ -80,6 +79,7 @@ func TestResetElapse(t *testing.T) {
for i, tt := range tests {
n := New(0, defaultHeartbeat, defaultElection)
n.sm = newStateMachine(0, []int64{0, 1, 2})
n.sm.promotable = true
n.sm.raftLog.append(0, Entry{Type: Normal, Term: 1})
n.sm.term = 2
n.sm.raftLog.committed = 1