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

Function TestProposalPOLMessageValidateBasic

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

Source from the content-addressed store, hash-verified

847}
848
849func TestProposalPOLMessageValidateBasic(t *testing.T) {
850 testCases := []struct {
851 malleateFn func(*ProposalPOLMessage)
852 expErr string
853 }{
854 {func(msg *ProposalPOLMessage) {}, ""},
855 {func(msg *ProposalPOLMessage) { msg.Height = -1 }, "negative Height"},
856 {func(msg *ProposalPOLMessage) { msg.ProposalPOLRound = -1 }, "negative ProposalPOLRound"},
857 {func(msg *ProposalPOLMessage) { msg.ProposalPOL = bits.NewBitArray(0) }, "empty ProposalPOL bit array"},
858 {func(msg *ProposalPOLMessage) { msg.ProposalPOL = bits.NewBitArray(types.MaxVotesCount + 1) },
859 "proposalPOL bit array is too big: 10001, max: 10000"},
860 }
861
862 for i, tc := range testCases {
863 tc := tc
864 t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
865 msg := &ProposalPOLMessage{
866 Height: 1,
867 ProposalPOLRound: 1,
868 ProposalPOL: bits.NewBitArray(1),
869 }
870
871 tc.malleateFn(msg)
872 err := msg.ValidateBasic()
873 if tc.expErr != "" && assert.Error(t, err) {
874 assert.Contains(t, err.Error(), tc.expErr)
875 }
876 })
877 }
878}
879
880func TestBlockPartMessageValidateBasic(t *testing.T) {
881 testPart := new(types.Part)

Callers

nothing calls this directly

Calls 4

ValidateBasicMethod · 0.95
NewBitArrayFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected