aboutsummaryrefslogtreecommitdiff
path: root/network/protocol/pktline/decoder_rejects_over_maximum_length_test.go
blob: 357bfc36e25df918d40b72dec8a1663a352d226c (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package pktline_test

import (
	"errors"
	"strings"
	"testing"

	"codeberg.org/lindenii/furgit/network/protocol/pktline"
)

func TestDecoderRejectsOverMaximumLength(t *testing.T) {
	t.Parallel()

	dec := pktline.NewDecoder(strings.NewReader("fffe"), pktline.ReadOptions{})
	dec.SetMaxData(70000)

	_, err := dec.ReadFrame()

	if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
		t.Fatalf("got err %v, want ProtocolError", err)
	}
}