diff --git a/pkg/object/address.go b/pkg/object/address.go index a241e63e..54d550fd 100644 --- a/pkg/object/address.go +++ b/pkg/object/address.go @@ -19,6 +19,8 @@ const ( ) // NewAddressFromV2 converts v2 Address message to Address. +// +// Nil refs.Address converts to nil. func NewAddressFromV2(aV2 *refs.Address) *Address { return (*Address)(aV2) } @@ -31,6 +33,8 @@ func NewAddress() *Address { } // ToV2 converts Address to v2 Address message. +// +// Nil Address converts to nil. func (a *Address) ToV2() *refs.Address { return (*refs.Address)(a) } diff --git a/pkg/object/address_test.go b/pkg/object/address_test.go index 652f44bb..f3b8b35e 100644 --- a/pkg/object/address_test.go +++ b/pkg/object/address_test.go @@ -5,6 +5,7 @@ import ( "testing" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" + "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/stretchr/testify/require" ) @@ -84,3 +85,19 @@ func TestAddressEncoding(t *testing.T) { require.Equal(t, a, a2) }) } + +func TestNewAddressFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *refs.Address + + require.Nil(t, NewAddressFromV2(x)) + }) +} + +func TestAddress_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *Address + + require.Nil(t, x.ToV2()) + }) +}