testutil

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2019 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectErrors

func CollectErrors(ctx context.Context, t *testing.T, errChan <-chan error) []error

CollectErrors is just a utility to convert an error channel into an array.

func CollectResponses

func CollectResponses(ctx context.Context, t *testing.T, responseChan <-chan graphsync.ResponseProgress) []graphsync.ResponseProgress

CollectResponses is just a utility to convert a graphsync response progress channel into an array.

func ContainsBlock

func ContainsBlock(blks []blocks.Block, block blocks.Block) bool

ContainsBlock returns true if a block is found n a list of blocks

func ContainsPeer

func ContainsPeer(peers []peer.ID, p peer.ID) bool

ContainsPeer returns true if a peer is found n a list of peers.

func GenerateBlocksOfSize

func GenerateBlocksOfSize(n int, size int64) []blocks.Block

GenerateBlocksOfSize generates a series of blocks of the given byte size

func GenerateCids

func GenerateCids(n int) []cid.Cid

GenerateCids produces n content identifiers.

func GeneratePeers

func GeneratePeers(n int) []peer.ID

GeneratePeers creates n peer ids.

func IndexOf

func IndexOf(blks []blocks.Block, c cid.Cid) int

IndexOf returns the index of a given cid in an array of blocks

func RandomBytes

func RandomBytes(n int64) []byte

RandomBytes returns a byte array of the given size with random values.

func ReadNResponses

func ReadNResponses(ctx context.Context, t *testing.T, responseChan <-chan graphsync.ResponseProgress, count int) []graphsync.ResponseProgress

ReadNResponses does a partial read from a ResponseProgress channel -- up to n values

func VerifyEmptyErrors

func VerifyEmptyErrors(ctx context.Context, t *testing.T, errChan <-chan error)

VerifyEmptyErrors verifies that no errors were sent over a channel before it was closed

func VerifyEmptyResponse

func VerifyEmptyResponse(ctx context.Context, t *testing.T, responseChan <-chan graphsync.ResponseProgress)

VerifyEmptyResponse verifies that no response progress happened before the channel was closed.

func VerifySingleTerminalError

func VerifySingleTerminalError(ctx context.Context, t *testing.T, errChan <-chan error)

VerifySingleTerminalError verifies that exactly one error was sent over a channel and then the channel was closed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL