forked from TrueCloudLab/frostfs-api-go
[#233] Implement data audit result type with basic methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3039aa20c7
commit
9986a4ecd1
9 changed files with 959 additions and 0 deletions
55
v2/audit/marshal_test.go
Normal file
55
v2/audit/marshal_test.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue