MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestVoteSetMaj23MessageValidateBasic

Function TestVoteSetMaj23MessageValidateBasic

consensus/reactor_test.go:950–993  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

948}
949
950func TestVoteSetMaj23MessageValidateBasic(t *testing.T) {
951 const (
952 validSignedMsgType tmproto.SignedMsgType = 0x01
953 invalidSignedMsgType tmproto.SignedMsgType = 0x03
954 )
955
956 validBlockID := types.BlockID{}
957 invalidBlockID := types.BlockID{
958 Hash: bytes.HexBytes{},
959 PartSetHeader: types.PartSetHeader{
960 Total: 1,
961 Hash: []byte{0},
962 },
963 }
964
965 testCases := []struct { //nolint: maligned
966 expectErr bool
967 messageRound int32
968 messageHeight int64
969 testName string
970 messageType tmproto.SignedMsgType
971 messageBlockID types.BlockID
972 }{
973 {false, 0, 0, "Valid Message", validSignedMsgType, validBlockID},
974 {true, -1, 0, "Invalid Message", validSignedMsgType, validBlockID},
975 {true, 0, -1, "Invalid Message", validSignedMsgType, validBlockID},
976 {true, 0, 0, "Invalid Message", invalidSignedMsgType, validBlockID},
977 {true, 0, 0, "Invalid Message", validSignedMsgType, invalidBlockID},
978 }
979
980 for _, tc := range testCases {
981 tc := tc
982 t.Run(tc.testName, func(t *testing.T) {
983 message := VoteSetMaj23Message{
984 Height: tc.messageHeight,
985 Round: tc.messageRound,
986 Type: tc.messageType,
987 BlockID: tc.messageBlockID,
988 }
989
990 assert.Equal(t, tc.expectErr, message.ValidateBasic() != nil, "Validate Basic had an unexpected result")
991 })
992 }
993}
994
995func TestVoteSetBitsMessageValidateBasic(t *testing.T) {
996 testCases := []struct {

Callers

nothing calls this directly

Calls 3

ValidateBasicMethod · 0.95
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected