[#64] object/test: reuse checksum and signature generators

These were missing from #53.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-11-08 13:04:45 +03:00 committed by Alex Vanin
parent 39d3317ef6
commit d6b72453fc
3 changed files with 41 additions and 6 deletions

21
checksum/test/generate.go Normal file
View file

@ -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
}

View file

@ -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())

View file

@ -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
}