diff --git a/pkg/audit/result_test.go b/pkg/audit/result_test.go index 4edd5fde..49081ce6 100644 --- a/pkg/audit/result_test.go +++ b/pkg/audit/result_test.go @@ -5,6 +5,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/audit" + audittest "github.com/nspcc-dev/neofs-api-go/pkg/audit/test" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" "github.com/nspcc-dev/neofs-api-go/pkg/object" objecttest "github.com/nspcc-dev/neofs-api-go/pkg/object/test" @@ -38,11 +39,11 @@ func TestResult(t *testing.T) { r.SetRetries(retries) require.Equal(t, retries, r.Retries()) - passSG := []*object.ID{objecttest.GenerateID(), objecttest.GenerateID()} + passSG := []*object.ID{objecttest.ID(), objecttest.ID()} r.SetPassSG(passSG) require.Equal(t, passSG, r.PassSG()) - failSG := []*object.ID{objecttest.GenerateID(), objecttest.GenerateID()} + failSG := []*object.ID{objecttest.ID(), objecttest.ID()} r.SetFailSG(failSG) require.Equal(t, failSG, r.FailSG()) @@ -68,19 +69,7 @@ func TestResult(t *testing.T) { } func TestStorageGroupEncoding(t *testing.T) { - r := audit.NewResult() - r.SetAuditEpoch(13) - r.SetContainerID(cidtest.Generate()) - r.SetPublicKey([]byte{1, 2, 3}) - r.SetPassSG([]*object.ID{objecttest.GenerateID(), objecttest.GenerateID()}) - r.SetFailSG([]*object.ID{objecttest.GenerateID(), objecttest.GenerateID()}) - r.SetRequests(3) - r.SetRetries(2) - r.SetHit(1) - r.SetMiss(2) - r.SetFail(3) - r.SetPassNodes([][]byte{{1}, {2}}) - r.SetFailNodes([][]byte{{3}, {4}}) + r := audittest.Generate() t.Run("binary", func(t *testing.T) { data, err := r.Marshal() diff --git a/pkg/audit/test/generate.go b/pkg/audit/test/generate.go new file mode 100644 index 00000000..84b2f8ff --- /dev/null +++ b/pkg/audit/test/generate.go @@ -0,0 +1,37 @@ +package audittest + +import ( + "github.com/nspcc-dev/neofs-api-go/pkg/audit" + cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" + "github.com/nspcc-dev/neofs-api-go/pkg/object" + objecttest "github.com/nspcc-dev/neofs-api-go/pkg/object/test" + refstest "github.com/nspcc-dev/neofs-api-go/pkg/test" +) + +// Generate returns random audit.Result. +func Generate() *audit.Result { + x := audit.NewResult() + + x.SetVersion(refstest.Version()) + x.SetContainerID(cidtest.Generate()) + x.SetPublicKey([]byte("key")) + x.SetComplete(true) + x.SetAuditEpoch(44) + x.SetHit(55) + x.SetMiss(66) + x.SetFail(77) + x.SetRetries(88) + x.SetRequests(99) + x.SetFailNodes([][]byte{ + []byte("node1"), + []byte("node2"), + }) + x.SetPassNodes([][]byte{ + []byte("node3"), + []byte("node4"), + }) + x.SetPassSG([]*object.ID{objecttest.ID(), objecttest.ID()}) + x.SetFailSG([]*object.ID{objecttest.ID(), objecttest.ID()}) + + return x +}