frostfs-api-go/v2/audit/marshal_test.go

56 lines
1.1 KiB
Go
Raw Normal View History

package audit_test
import (
"testing"
"github.com/nspcc-dev/neofs-api-go/v2/audit"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/stretchr/testify/require"
)
func TestDataAuditResult_StableMarshal(t *testing.T) {
from := generateDataAuditResult()
t.Run("non empty", func(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
to := new(audit.DataAuditResult)
require.NoError(t, to.Unmarshal(wire))
require.Equal(t, from, to)
})
}
func generateDataAuditResult() *audit.DataAuditResult {
a := new(audit.DataAuditResult)
oid1 := new(refs.ObjectID)
oid1.SetValue([]byte("Object ID 1"))
oid2 := new(refs.ObjectID)
oid2.SetValue([]byte("Object ID 2"))
cid := new(refs.ContainerID)
cid.SetValue([]byte("Container ID"))
a.SetAuditEpoch(13)
a.SetContainerID(cid)
a.SetPublicKey([]byte("Public key"))
a.SetPassSG([]*refs.ObjectID{oid1, oid2})
a.SetFailSG([]*refs.ObjectID{oid2, oid1})
a.SetHit(1)
a.SetMiss(2)
a.SetFail(3)
a.SetPassNodes([][]byte{
{1, 2},
{3, 4},
})
a.SetFailNodes([][]byte{
{5, 6},
{7, 8},
})
return a
}