|
@@ -70,3 +70,35 @@ func TestLimitSize(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func TestIsLocalMsg(t *testing.T) {
|
|
|
|
|
+ tests := []struct {
|
|
|
|
|
+ msgt pb.MessageType
|
|
|
|
|
+ isLocal bool
|
|
|
|
|
+ }{
|
|
|
|
|
+ {pb.MsgHup, true},
|
|
|
|
|
+ {pb.MsgBeat, true},
|
|
|
|
|
+ {pb.MsgUnreachable, true},
|
|
|
|
|
+ {pb.MsgSnapStatus, true},
|
|
|
|
|
+ {pb.MsgCheckQuorum, true},
|
|
|
|
|
+ {pb.MsgTransferLeader, false},
|
|
|
|
|
+ {pb.MsgProp, false},
|
|
|
|
|
+ {pb.MsgApp, false},
|
|
|
|
|
+ {pb.MsgAppResp, false},
|
|
|
|
|
+ {pb.MsgVote, false},
|
|
|
|
|
+ {pb.MsgVoteResp, false},
|
|
|
|
|
+ {pb.MsgSnap, false},
|
|
|
|
|
+ {pb.MsgHeartbeat, false},
|
|
|
|
|
+ {pb.MsgHeartbeatResp, false},
|
|
|
|
|
+ {pb.MsgTimeoutNow, false},
|
|
|
|
|
+ {pb.MsgReadIndex, false},
|
|
|
|
|
+ {pb.MsgReadIndexResp, false},
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for i, tt := range tests {
|
|
|
|
|
+ got := IsLocalMsg(tt.msgt)
|
|
|
|
|
+ if got != tt.isLocal {
|
|
|
|
|
+ t.Errorf("#%d: got %v, want %v", i, got, tt.isLocal)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|