diff --git a/pkg/owner/id.go b/pkg/owner/id.go index 2743b73b..fadb8181 100644 --- a/pkg/owner/id.go +++ b/pkg/owner/id.go @@ -16,6 +16,8 @@ type ID refs.OwnerID var errInvalidIDString = errors.New("incorrect format of the string owner ID") // NewIDFromV2 wraps v2 OwnerID message to ID. +// +// Nil refs.OwnerID converts to nil. func NewIDFromV2(idV2 *refs.OwnerID) *ID { return (*ID)(idV2) } @@ -33,6 +35,8 @@ func (id *ID) SetNeo3Wallet(v *NEO3Wallet) { } // ToV2 returns the v2 owner ID message. +// +// Nil ID converts to nil. func (id *ID) ToV2() *refs.OwnerID { return (*refs.OwnerID)(id) } diff --git a/pkg/owner/id_test.go b/pkg/owner/id_test.go index 9ab2e304..d32b8952 100644 --- a/pkg/owner/id_test.go +++ b/pkg/owner/id_test.go @@ -7,6 +7,7 @@ import ( "github.com/mr-tron/base58" . "github.com/nspcc-dev/neofs-api-go/pkg/owner" ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test" + "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-crypto/test" "github.com/stretchr/testify/require" ) @@ -99,3 +100,19 @@ func TestID_Equal(t *testing.T) { ownertest.GenerateFromBytes(data3), )) } + +func TestNewIDFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *refs.OwnerID + + require.Nil(t, NewIDFromV2(x)) + }) +} + +func TestID_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *ID + + require.Nil(t, x.ToV2()) + }) +}