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

Function TestBlockPartMessageValidateBasic

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

Source from the content-addressed store, hash-verified

878}
879
880func TestBlockPartMessageValidateBasic(t *testing.T) {
881 testPart := new(types.Part)
882 testPart.Proof.LeafHash = tmhash.Sum([]byte("leaf"))
883 testCases := []struct {
884 testName string
885 messageHeight int64
886 messageRound int32
887 messagePart *types.Part
888 expectErr bool
889 }{
890 {"Valid Message", 0, 0, testPart, false},
891 {"Invalid Message", -1, 0, testPart, true},
892 {"Invalid Message", 0, -1, testPart, true},
893 }
894
895 for _, tc := range testCases {
896 tc := tc
897 t.Run(tc.testName, func(t *testing.T) {
898 message := BlockPartMessage{
899 Height: tc.messageHeight,
900 Round: tc.messageRound,
901 Part: tc.messagePart,
902 }
903
904 assert.Equal(t, tc.expectErr, message.ValidateBasic() != nil, "Validate Basic had an unexpected result")
905 })
906 }
907
908 message := BlockPartMessage{Height: 0, Round: 0, Part: new(types.Part)}
909 message.Part.Index = 1
910
911 assert.Equal(t, true, message.ValidateBasic() != nil, "Validate Basic had an unexpected result")
912}
913
914func TestHasVoteMessageValidateBasic(t *testing.T) {
915 const (

Callers

nothing calls this directly

Calls 4

ValidateBasicMethod · 0.95
SumFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected