From 5ecfd19e3be1cfed4ab73e61e78a09c2a6a2b42c Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 15 Apr 2022 10:41:17 +0800 Subject: [PATCH] fix unit test --- protocol/dubbo/impl/codec.go | 2 +- remoting/getty/readwriter_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go index 95acbd9e0f..e7e6abcc67 100644 --- a/protocol/dubbo/impl/codec.go +++ b/protocol/dubbo/impl/codec.go @@ -157,7 +157,7 @@ func (c *ProtocolCodec) Decode(p *DubboPackage) error { return err } } - if c.reader.Size() < p.GetBodyLen() { + if c.reader.Size() < p.GetBodyLen()+HEADER_LENGTH { return hessian.ErrBodyNotEnough } body, err := c.reader.Peek(p.GetBodyLen()) diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go index 7eb1732343..48e4b3f76e 100644 --- a/remoting/getty/readwriter_test.go +++ b/remoting/getty/readwriter_test.go @@ -75,8 +75,8 @@ func testDecodeTCPPackage(t *testing.T, svr *Server, client *Client) { assert.True(t, incompletePkgLen >= impl.HEADER_LENGTH, "header buffer too short") incompletePkg := pkgBytes[0 : incompletePkgLen-1] pkg, pkgLen, err := pkgReadHandler.Read(nil, incompletePkg) - assert.NoError(t, err) - assert.Equal(t, pkg, nil) + assert.Equal(t, err.Error(), "body buffer too short") + assert.Equal(t, pkg.(*remoting.DecodeResult).Result, nil) assert.Equal(t, pkgLen, 0) }