Skip to content

Commit

Permalink
Fix: message size check in timeout test (#1014)
Browse files Browse the repository at this point in the history
Fix message size check in `TestMessageTimeoutReached`. Since the message parser has parsed two packets of size 63 << 10, then the message size should be 63 << 11
  • Loading branch information
monrax authored and buger committed Oct 6, 2021
1 parent 41da139 commit f8ef77e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tcp/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,16 @@ func TestMessageParserWithoutHint(t *testing.T) {
}

func TestMessageTimeoutReached(t *testing.T) {
var data [63 << 10]byte
const size = 63 << 11
var data [size >> 1]byte
packets := GetPackets(true, 1, 2, data[:])
p := NewMessageParser(nil, nil, nil, 10*time.Millisecond, true)
p.processPacket(packets[0])
time.Sleep(time.Millisecond * 200)
p.processPacket(packets[1])
m := p.Read()
if m.Length != 63<<10 {
t.Errorf("expected %d to equal %d", m.Length, 63<<10)
if m.Length != size {
t.Errorf("expected %d to equal %d", m.Length, size)
}
if !m.TimedOut {
t.Error("expected message to be timeout")
Expand Down

0 comments on commit f8ef77e

Please sign in to comment.