Documentation ¶
Overview ¶
Package testblock provides helper functions for constructing real (e.g. localnet) and mock BlockClient objects with pre-configured and/or parameterized call arguments, return value(s), and/or expectations thereof. Intended for use in tests.
Index ¶
- func NewAnyTimeLastBlockBlockClient(t *testing.T, blockHash []byte, blockHeight int64) *mockclient.MockBlockClient
- func NewAnyTimesBlock(t *testing.T, blockHash []byte, blockHeight int64) *mockclient.MockBlock
- func NewAnyTimesCommittedBlocksSequenceBlockClient(t *testing.T, blockHash []byte, blocksObs observable.Observable[client.Block]) *mockclient.MockBlockClient
- func NewLocalnetClient(ctx context.Context, t *testing.T) client.BlockClient
- func NewOneTimeCommittedBlocksSequenceBlockClient(t *testing.T, blocksPublishCh chan client.Block) *mockclient.MockBlockClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnyTimeLastBlockBlockClient ¶
func NewAnyTimeLastBlockBlockClient( t *testing.T, blockHash []byte, blockHeight int64, ) *mockclient.MockBlockClient
NewAnyTimeLastBlockBlockClient creates a mock BlockClient that expects calls to the LastBlock method any number of times. When the LastBlock method is called, it returns a mock Block with the provided hash and height.
func NewAnyTimesBlock ¶
NewAnyTimesBlock creates a mock Block that expects calls to Height and Hash methods any number of times. When the methods are called, they return the provided height and hash respectively.
func NewAnyTimesCommittedBlocksSequenceBlockClient ¶
func NewAnyTimesCommittedBlocksSequenceBlockClient( t *testing.T, blockHash []byte, blocksObs observable.Observable[client.Block], ) *mockclient.MockBlockClient
NewAnyTimesCommittedBlocksSequenceBlockClient creates a new mock BlockClient. This mock BlockClient will expect any number of calls to CommittedBlocksSequence, and when that call is made, it returns the given EventsObservable[Block].
func NewLocalnetClient ¶
NewLocalnetClient creates and returns a new BlockClient that's configured for use with the LocalNet validator.
func NewOneTimeCommittedBlocksSequenceBlockClient ¶
func NewOneTimeCommittedBlocksSequenceBlockClient( t *testing.T, blocksPublishCh chan client.Block, ) *mockclient.MockBlockClient
NewOneTimeCommittedBlocksSequenceBlockClient creates a new mock BlockClient. This mock BlockClient will expect a call to CommittedBlocksSequence, and when that call is made, it returns a new BlocksObservable that is notified of blocks sent on the given blocksPublishCh. blocksPublishCh is the channel the caller can use to publish blocks the observable.
Types ¶
This section is empty.