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

Function TestNewValidBlockMessageValidateBasic

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

Source from the content-addressed store, hash-verified

801}
802
803func TestNewValidBlockMessageValidateBasic(t *testing.T) {
804 testCases := []struct {
805 malleateFn func(*NewValidBlockMessage)
806 expErr string
807 }{
808 {func(msg *NewValidBlockMessage) {}, ""},
809 {func(msg *NewValidBlockMessage) { msg.Height = -1 }, "negative Height"},
810 {func(msg *NewValidBlockMessage) { msg.Round = -1 }, "negative Round"},
811 {
812 func(msg *NewValidBlockMessage) { msg.BlockPartSetHeader.Total = 2 },
813 "blockParts bit array size 1 not equal to BlockPartSetHeader.Total 2",
814 },
815 {
816 func(msg *NewValidBlockMessage) {
817 msg.BlockPartSetHeader.Total = 0
818 msg.BlockParts = bits.NewBitArray(0)
819 },
820 "empty blockParts",
821 },
822 {
823 func(msg *NewValidBlockMessage) { msg.BlockParts = bits.NewBitArray(int(types.MaxBlockPartsCount) + 1) },
824 "blockParts bit array size 1602 not equal to BlockPartSetHeader.Total 1",
825 },
826 }
827
828 for i, tc := range testCases {
829 tc := tc
830 t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
831 msg := &NewValidBlockMessage{
832 Height: 1,
833 Round: 0,
834 BlockPartSetHeader: types.PartSetHeader{
835 Total: 1,
836 },
837 BlockParts: bits.NewBitArray(1),
838 }
839
840 tc.malleateFn(msg)
841 err := msg.ValidateBasic()
842 if tc.expErr != "" && assert.Error(t, err) {
843 assert.Contains(t, err.Error(), tc.expErr)
844 }
845 })
846 }
847}
848
849func TestProposalPOLMessageValidateBasic(t *testing.T) {
850 testCases := []struct {

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