[#293] pkg: Implement and use generators of the messages

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-08 14:34:44 +03:00 committed by Alex Vanin
parent dd0a883637
commit 075003c4f1
2 changed files with 54 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import (
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test"
sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test"
refstest "github.com/nspcc-dev/neofs-api-go/pkg/test"
)
// Target returns random eacl.Target.
@ -40,6 +41,8 @@ func Table() *eacl.Table {
x.SetSessionToken(sessiontest.Generate())
x.AddRecord(Record())
x.AddRecord(Record())
x.SetVersion(*refstest.Version())
x.SetSignature(refstest.Signature())
return x
}

51
pkg/test/generate.go Normal file
View file

@ -0,0 +1,51 @@
package refstest
import (
"crypto/sha256"
"math/rand"
"github.com/nspcc-dev/neofs-api-go/pkg"
)
// Checksum returns random pkg.Checksum.
func Checksum() *pkg.Checksum {
var cs [sha256.Size]byte
rand.Read(cs[:])
x := pkg.NewChecksum()
x.SetSHA256(cs)
return x
}
// Signature returns random pkg.Signature.
func Signature() *pkg.Signature {
x := pkg.NewSignature()
x.SetKey([]byte("key"))
x.SetSign([]byte("sign"))
return x
}
// Version returns random pkg.Version.
func Version() *pkg.Version {
x := pkg.NewVersion()
x.SetMajor(2)
x.SetMinor(1)
return x
}
// XHeader returns random pkg.XHeader.
func XHeader() *pkg.XHeader {
x := pkg.NewXHeader()
x.SetKey("key")
x.SetValue("value")
return x
}