forked from TrueCloudLab/frostfs-api-go
[#293] pkg: Implement and use generators of the messages
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
dd0a883637
commit
075003c4f1
2 changed files with 54 additions and 0 deletions
51
pkg/test/generate.go
Normal file
51
pkg/test/generate.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue