diff --git a/pkg/container/announcement.go b/pkg/container/announcement.go index 6d82966e..20041aa4 100644 --- a/pkg/container/announcement.go +++ b/pkg/container/announcement.go @@ -16,6 +16,8 @@ func NewAnnouncement() *UsedSpaceAnnouncement { // NewAnnouncementFromV2 wraps protocol dependent version of // UsedSpaceAnnouncement message. +// +// Nil container.UsedSpaceAnnouncement converts to nil. func NewAnnouncementFromV2(v *container.UsedSpaceAnnouncement) *UsedSpaceAnnouncement { return (*UsedSpaceAnnouncement)(v) } @@ -53,6 +55,8 @@ func (a *UsedSpaceAnnouncement) SetUsedSpace(value uint64) { } // ToV2 returns protocol dependent version of UsedSpaceAnnouncement message. +// +// Nil UsedSpaceAnnouncement converts to nil. func (a *UsedSpaceAnnouncement) ToV2() *container.UsedSpaceAnnouncement { return (*container.UsedSpaceAnnouncement)(a) } diff --git a/pkg/container/announcement_test.go b/pkg/container/announcement_test.go index 26164bb3..3560ae6a 100644 --- a/pkg/container/announcement_test.go +++ b/pkg/container/announcement_test.go @@ -8,6 +8,7 @@ import ( cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" containertest "github.com/nspcc-dev/neofs-api-go/pkg/container/test" + containerv2 "github.com/nspcc-dev/neofs-api-go/v2/container" "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/stretchr/testify/require" ) @@ -64,3 +65,19 @@ func TestUsedSpaceEncoding(t *testing.T) { require.Equal(t, a, a2) }) } + +func TestUsedSpaceAnnouncement_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *container.UsedSpaceAnnouncement + + require.Nil(t, x.ToV2()) + }) +} + +func TestNewAnnouncementFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *containerv2.UsedSpaceAnnouncement + + require.Nil(t, container.NewAnnouncementFromV2(x)) + }) +}