forked from TrueCloudLab/frostfs-api-go
[#397] refs: Fix OIDs marshalling
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
3d3283411c
commit
870c1ffc0a
2 changed files with 4 additions and 5 deletions
|
@ -118,11 +118,11 @@ func (o *ObjectID) StableSize() int {
|
||||||
func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) {
|
func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) {
|
||||||
prefix, _ := proto.NestedStructurePrefix(fNum)
|
prefix, _ := proto.NestedStructurePrefix(fNum)
|
||||||
for i := range ids {
|
for i := range ids {
|
||||||
off += binary.PutUvarint(buf, prefix)
|
off += binary.PutUvarint(buf[off:], prefix)
|
||||||
|
|
||||||
n := ids[i].StableSize()
|
n := ids[i].StableSize()
|
||||||
off += binary.PutUvarint(buf[off:], uint64(n))
|
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
|
return
|
||||||
|
|
|
@ -16,7 +16,7 @@ type jsonMessage interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type binaryMessage interface {
|
type binaryMessage interface {
|
||||||
StableMarshal([]byte) ([]byte, error)
|
StableMarshal([]byte) []byte
|
||||||
Unmarshal([]byte) error
|
Unmarshal([]byte) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,7 @@ func TestRPCMessage(t *testing.T, msgGens ...func(empty bool) message.Message) {
|
||||||
|
|
||||||
if bm, ok := msg.(binaryMessage); ok {
|
if bm, ok := msg.(binaryMessage); ok {
|
||||||
t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) {
|
t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) {
|
||||||
data, err := bm.StableMarshal(nil)
|
data := bm.StableMarshal(nil)
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
bm2 := msgGen(true).(binaryMessage)
|
bm2 := msgGen(true).(binaryMessage)
|
||||||
require.NoError(t, bm2.Unmarshal(data))
|
require.NoError(t, bm2.Unmarshal(data))
|
||||||
|
|
Loading…
Reference in a new issue