package object_test import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" objecttest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/test" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" ) func TestLockEncoding(t *testing.T) { l := *objecttest.Lock() t.Run("binary", func(t *testing.T) { data := l.Marshal() l2 := object.NewLock() require.NoError(t, l2.Unmarshal(data)) require.True(t, proto.Equal(l.ToV2(), l2.ToV2())) }) } func TestWriteLock(t *testing.T) { l := *objecttest.Lock() o := object.New() object.WriteLock(o, l) l2 := object.NewLock() require.NoError(t, object.ReadLock(l2, o)) require.True(t, proto.Equal(l.ToV2(), l2.ToV2())) // corrupt payload o.Payload()[0]++ require.Error(t, object.ReadLock(l2, o)) }