(t *testing.T)
| 847 | } |
| 848 | |
| 849 | func 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 | |
| 880 | func TestBlockPartMessageValidateBasic(t *testing.T) { |
| 881 | testPart := new(types.Part) |
nothing calls this directly
no test coverage detected