testblock

package
v0.0.0-...-3dee9c1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 11 Imported by: 0

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

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

func NewAnyTimesBlock(
	t *testing.T,
	blockHash []byte,
	blockHeight int64,
) *mockclient.MockBlock

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

func NewLocalnetClient(ctx context.Context, t *testing.T) client.BlockClient

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.

Jump to

Keyboard shortcuts

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