diff --git a/pkg/container/announcement.go b/pkg/container/announcement.go index 20041aa4..cfa9510b 100644 --- a/pkg/container/announcement.go +++ b/pkg/container/announcement.go @@ -10,6 +10,11 @@ import ( type UsedSpaceAnnouncement container.UsedSpaceAnnouncement // NewAnnouncement initialize empty UsedSpaceAnnouncement message. +// +// Defaults: +// - epoch: 0; +// - usedSpace: 0; +// - cid: nil. func NewAnnouncement() *UsedSpaceAnnouncement { return NewAnnouncementFromV2(new(container.UsedSpaceAnnouncement)) } diff --git a/pkg/container/announcement_test.go b/pkg/container/announcement_test.go index 3560ae6a..dc669b89 100644 --- a/pkg/container/announcement_test.go +++ b/pkg/container/announcement_test.go @@ -72,6 +72,22 @@ func TestUsedSpaceAnnouncement_ToV2(t *testing.T) { require.Nil(t, x.ToV2()) }) + + t.Run("default values", func(t *testing.T) { + announcement := container.NewAnnouncement() + + // check initial values + require.Zero(t, announcement.Epoch()) + require.Zero(t, announcement.UsedSpace()) + require.Nil(t, announcement.ContainerID()) + + // convert to v2 message + announcementV2 := announcement.ToV2() + + require.Zero(t, announcementV2.GetEpoch()) + require.Zero(t, announcementV2.GetUsedSpace()) + require.Nil(t, announcementV2.GetContainerID()) + }) } func TestNewAnnouncementFromV2(t *testing.T) {