Skip to content

Commit

Permalink
TestSingleNodeCommit
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Grieger <tobias.b.grieger@gmail.com>
  • Loading branch information
tbg committed Sep 20, 2022
1 parent 99adcaa commit d6f3e88
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion raft/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,18 @@ func TestLearnerLogReplication(t *testing.T) {
}

func TestSingleNodeCommit(t *testing.T) {
tt := newNetwork(nil)
s := newTestMemoryStorage(withPeers(1))
cfg := newTestConfig(1, 10, 1, s)
r := newRaft(cfg)
tt := newNetwork(r)
tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})

rd := newReady(r, &SoftState{}, pb.HardState{})
s.Append(rd.Entries)
r.advance(rd)

sm := tt.peers[1].(*raft)
if sm.raftLog.committed != 3 {
t.Errorf("committed = %d, want %d", sm.raftLog.committed, 3)
Expand Down

0 comments on commit d6f3e88

Please sign in to comment.