From 870c1ffc0a9f4166ade31b293eef994a515887ab Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 25 Apr 2022 21:24:19 +0300 Subject: [PATCH] [#397] refs: Fix OIDs marshalling Signed-off-by: Pavel Karpy --- refs/marshal.go | 4 ++-- rpc/message/test/message.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/refs/marshal.go b/refs/marshal.go index dc8517f0..ef85324b 100644 --- a/refs/marshal.go +++ b/refs/marshal.go @@ -118,11 +118,11 @@ func (o *ObjectID) StableSize() int { func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) { prefix, _ := proto.NestedStructurePrefix(fNum) for i := range ids { - off += binary.PutUvarint(buf, prefix) + off += binary.PutUvarint(buf[off:], prefix) n := ids[i].StableSize() off += binary.PutUvarint(buf[off:], uint64(n)) - off += proto.BytesMarshal(objectIDValField, buf, ids[i].val) + off += proto.BytesMarshal(objectIDValField, buf[off:], ids[i].val) } return diff --git a/rpc/message/test/message.go b/rpc/message/test/message.go index e3ce9cda..7c4450f0 100644 --- a/rpc/message/test/message.go +++ b/rpc/message/test/message.go @@ -16,7 +16,7 @@ type jsonMessage interface { } type binaryMessage interface { - StableMarshal([]byte) ([]byte, error) + StableMarshal([]byte) []byte Unmarshal([]byte) error } @@ -54,8 +54,7 @@ func TestRPCMessage(t *testing.T, msgGens ...func(empty bool) message.Message) { if bm, ok := msg.(binaryMessage); ok { t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) { - data, err := bm.StableMarshal(nil) - require.NoError(t, err) + data := bm.StableMarshal(nil) bm2 := msgGen(true).(binaryMessage) require.NoError(t, bm2.Unmarshal(data))