forked from TrueCloudLab/frostfs-api-go
[#168] refs: Implement binary/JSON encoders/decoders on Address
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
9325e22871
commit
4ce751f13c
7 changed files with 114 additions and 33 deletions
|
@ -69,16 +69,13 @@ func TestAddress_StableMarshal(t *testing.T) {
|
|||
|
||||
addressFrom := generateAddress(cid, oid)
|
||||
|
||||
addressTransport := new(grpc.Address)
|
||||
|
||||
t.Run("non empty", func(t *testing.T) {
|
||||
wire, err := addressFrom.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = goproto.Unmarshal(wire, addressTransport)
|
||||
require.NoError(t, err)
|
||||
addressTo := new(refs.Address)
|
||||
require.NoError(t, addressTo.Unmarshal(wire))
|
||||
|
||||
addressTo := refs.AddressFromGRPCMessage(addressTransport)
|
||||
require.Equal(t, addressFrom, addressTo)
|
||||
})
|
||||
}
|
||||
|
@ -161,15 +158,3 @@ func generateAddress(bCid, bOid []byte) *refs.Address {
|
|||
|
||||
return addr
|
||||
}
|
||||
|
||||
func TestAddress_StableUnmarshal(t *testing.T) {
|
||||
addr := generateAddress([]byte("container id"), []byte("object id"))
|
||||
|
||||
data, err := addr.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
addr2 := new(refs.Address)
|
||||
require.NoError(t, addr2.StableUnmarshal(data))
|
||||
|
||||
require.Equal(t, addr, addr2)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue