diff --git a/checksum/test/generate.go b/checksum/test/generate.go new file mode 100644 index 00000000..0df988d0 --- /dev/null +++ b/checksum/test/generate.go @@ -0,0 +1,21 @@ +package test + +import ( + "crypto/sha256" + "math/rand" + + "github.com/nspcc-dev/neofs-sdk-go/checksum" +) + +// Checksum returns random checksum.Checksum. +func Checksum() *checksum.Checksum { + var cs [sha256.Size]byte + + rand.Read(cs[:]) + + x := checksum.New() + + x.SetSHA256(cs) + + return x +} diff --git a/object/test/generate.go b/object/test/generate.go index 4e5e5bda..23eef70d 100644 --- a/object/test/generate.go +++ b/object/test/generate.go @@ -5,12 +5,12 @@ import ( "math/rand" "github.com/google/uuid" - "github.com/nspcc-dev/neofs-sdk-go/checksum" + checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" "github.com/nspcc-dev/neofs-sdk-go/object" ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test" sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test" - "github.com/nspcc-dev/neofs-sdk-go/signature" + sigtest "github.com/nspcc-dev/neofs-sdk-go/signature/test" "github.com/nspcc-dev/neofs-sdk-go/version" ) @@ -88,10 +88,9 @@ func generateRaw(withParent bool) *object.RawObject { x.SetChildren(ID(), ID()) x.SetAttributes(Attribute(), Attribute()) x.SetSplitID(SplitID()) - // TODO reuse generators - x.SetPayloadChecksum(checksum.New()) - x.SetPayloadHomomorphicHash(checksum.New()) - x.SetSignature(signature.New()) + x.SetPayloadChecksum(checksumtest.Checksum()) + x.SetPayloadHomomorphicHash(checksumtest.Checksum()) + x.SetSignature(sigtest.Signature()) if withParent { x.SetParent(generateRaw(false).Object()) diff --git a/signature/test/generate.go b/signature/test/generate.go new file mode 100644 index 00000000..90e56cb1 --- /dev/null +++ b/signature/test/generate.go @@ -0,0 +1,15 @@ +package test + +import ( + "github.com/nspcc-dev/neofs-sdk-go/signature" +) + +// Signature returns random pkg.Signature. +func Signature() *signature.Signature { + x := signature.New() + + x.SetKey([]byte("key")) + x.SetSign([]byte("sign")) + + return x +}