Documentation
¶
Overview ¶
Package random provides functionality to generate pseudo-random test data.
All random numbers and data are created deterministically using a pseudo-random number generator. This generator's output is determined by the value a seed that us set using the current time, or set explicitly.
Index ¶
- func AddrInfos(numPeers, numAddrs int) []peer.AddrInfo
- func Addrs(n int) []string
- func BlocksOfSize(n int, size int) []blocks.Block
- func Bytes(n int) []byte
- func Cids(n int) []cid.Cid
- func DnsAddrInfos(numPeers, numAddrs int) []peer.AddrInfo
- func DnsAddrs(n int) []string
- func DnsMultiaddrs(n int) []multiaddr.Multiaddr
- func HttpAddrInfos(numPeers, numAddrs int) []peer.AddrInfo
- func HttpDnsAddrInfos(numPeers, numAddrs int) []peer.AddrInfo
- func HttpDnsMultiaddrs(n int) []multiaddr.Multiaddr
- func HttpMultiaddrs(n int) []multiaddr.Multiaddr
- func Identity() (peer.ID, crypto.PrivKey, crypto.PubKey)
- func Multiaddrs(n int) []multiaddr.Multiaddr
- func Multihashes(n int) []multihash.Multihash
- func NewRand() *rand.Rand
- func NewSeededRand(seed int64) *rand.Rand
- func Peers(n int) []peer.ID
- func Seed() int64
- func Sequence(n int) []uint64
- func SequenceNext() uint64
- func SetSeed(seed int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddrInfos ¶ added in v0.3.0
AddrInfos returns a slice AddrInfo with numPeers elements. Each AddrInfo element will have a unique ID and numAddrs Addresses. The multiaddrs will be ipv4 addresses.
func BlocksOfSize ¶
BlocksOfSize generates a slice of blocks of the specified byte size.
func DnsAddrInfos ¶ added in v0.3.0
AddrInfos returns a slice AddrInfo with numPeers elements. Each AddrInfo element will have a unique ID and numAddrs Addresses. The multiaddrs will be dns addresses.
func DnsAddrs ¶ added in v0.3.0
DnsAddrs returns a slice of n random unique DNS addresses in the format "xxxxxxxx.example.com:port".
func DnsMultiaddrs ¶ added in v0.3.0
DnsMultiaddrs returns a slice of n random unique Multiaddrs with DNS addresses.
func HttpAddrInfos ¶ added in v0.3.0
AddrInfos returns a slice AddrInfo with numPeers elements. Each AddrInfo element will have a unique ID and numAddrs Addresses. The multiaddrs will be ipv4 addresses with http.
func HttpDnsAddrInfos ¶ added in v0.3.0
AddrInfos returns a slice AddrInfo with numPeers elements. Each AddrInfo element will have a unique ID and numAddrs Addresses. The multiaddrs will be dns addresses with http.
func HttpDnsMultiaddrs ¶ added in v0.3.0
HttpDnsMultiaddrs returns a slice of n random unique Multiaddrs with DNS addresses.
func HttpMultiaddrs ¶
HttpMultiaddrs returns a slice of n random unique Multiaddrs.
func Multiaddrs ¶
Multiaddrs returns a slice of n random unique Multiaddrs with IPv4 addresses.
func Multihashes ¶
Multihashes returns a slice of n random unique Multihashes.
func NewRand ¶ added in v0.0.4
NewRand returns a new pseudo-random number source, seeded with the next value of a global sequence.
func NewSeededRand ¶ added in v0.0.4
NewSeededRand returns a new pseudo-random number source seeded with the specified value.
func Seed ¶
func Seed() int64
Returns the initial seed used for the pseudo-random number generator, or the most recent value set by SetSeed.
func Sequence ¶ added in v0.0.3
Sequence returns a series of monotonically increasing numbers, starting at the next unique global sequence value. Any current calls to Sequence will not generate any overlapping values.
The sequence numbers themselves are not random, only the global starting value of the sequence numbers is random. This ensures that all sequences generated within a test are unique, assuming < 2^64 values are generated, but start out at a random value.
func SequenceNext ¶ added in v0.0.3
func SequenceNext() uint64
SequenceNext returns the next unique global sequence value. This is equivalent to Sequence(1)[0].
Types ¶
This section is empty.