From 33ca88f85f5bdb9992c8531a39888397fee88830 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 1 Oct 2020 20:14:10 +0300 Subject: [PATCH] [#64] core/object: Claim TombstoneContent in tombstone payload Signed-off-by: Leonard Lyubich --- pkg/core/object/fmt.go | 10 ++++++---- pkg/core/object/fmt_test.go | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/core/object/fmt.go b/pkg/core/object/fmt.go index b6365cae1..eb2431b07 100644 --- a/pkg/core/object/fmt.go +++ b/pkg/core/object/fmt.go @@ -89,13 +89,15 @@ func (v *FormatValidator) ValidateContent(t object.Type, payload []byte) error { return errors.Errorf("(%T) empty payload in tombstone", v) } - addr, err := object.AddressFromBytes(payload) + content, err := TombstoneContentFromBytes(payload) if err != nil { - return errors.Wrapf(err, "(%T) could not parse object address from tombstone", v) + return errors.Wrapf(err, "(%T) could not parse tombstone content", err) } - if addr.GetContainerID() == nil || addr.GetObjectID() == nil { - return errors.Errorf("(%T) empty address reference in tombstone", v) + for _, addr := range content.GetAddressList() { + if addr.GetContainerID() == nil || addr.GetObjectID() == nil { + return errors.Errorf("(%T) empty address reference in tombstone", v) + } } } diff --git a/pkg/core/object/fmt_test.go b/pkg/core/object/fmt_test.go index 06b638784..18200a151 100644 --- a/pkg/core/object/fmt_test.go +++ b/pkg/core/object/fmt_test.go @@ -109,7 +109,10 @@ func TestFormatValidator_Validate(t *testing.T) { addr := object.NewAddress() - data, err := addr.ToV2().StableMarshal(nil) + content := NewTombstoneContent() + content.SetAddressList(addr) + + data, err := content.MarshalBinary() require.NoError(t, err) require.Error(t, v.ValidateContent(object.TypeTombstone, data)) @@ -117,7 +120,7 @@ func TestFormatValidator_Validate(t *testing.T) { addr.SetContainerID(testContainerID(t)) addr.SetObjectID(testObjectID(t)) - data, err = addr.ToV2().StableMarshal(nil) + data, err = content.MarshalBinary() require.NoError(t, err) require.NoError(t, v.ValidateContent(object.TypeTombstone, data))