frostfs-sdk-go/object/id/test/generate.go
Leonard Lyubich 3bbf7ee15d [#252] object/id: Fix typos in docs
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-05-27 12:41:35 +03:00

37 lines
639 B
Go

package oidtest
import (
"crypto/sha256"
"math/rand"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
// ID returns random oid.ID.
func ID() oid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
return idWithChecksum(checksum)
}
// idWithChecksum returns oid.ID initialized
// with specified checksum.
func idWithChecksum(cs [sha256.Size]byte) oid.ID {
var id oid.ID
id.SetSHA256(cs)
return id
}
// Address returns random oid.Address.
func Address() oid.Address {
var x oid.Address
x.SetContainer(cidtest.ID())
x.SetObject(ID())
return x
}