tmmirrortest

package
v0.0.0-...-506a26f Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fixture

type Fixture struct {
	Log *slog.Logger

	Fx *tmconsensustest.StandardFixture

	// These channels are bidirectional in the fixture,
	// because they are write-only in the config.
	StateMachineRoundViewOut chan tmeil.StateMachineRoundView

	GossipStrategyOut chan tmelink.NetworkViewUpdate
	LagStateOut       chan tmelink.LagState

	StateMachineRoundEntranceIn chan tmeil.StateMachineRoundEntrance
	ReplayedHeadersIn           chan tmelink.ReplayedHeaderRequest

	Cfg tmmirror.MirrorConfig

	WatchdogCtx context.Context
}

Fixture is a helper type to create a tmmirror.Mirror and its required inputs for tests involving a Mirror.

func NewFixture

func NewFixture(ctx context.Context, t *testing.T, nVals int) *Fixture

func (*Fixture) CommitInitialHeight

func (f *Fixture) CommitInitialHeight(
	ctx context.Context,
	initialAppStateHash []byte,
	initialProposerIndex int,
	committerIdxs []int,
)

CommitInitialHeight updates the round store, the network store, and the consensus fixture to have a commit at the initial height at round zero.

If the mirror is started after this call, / it is as though the mirror handled the expected sequence of messages to advance past the initial height and round.

func (*Fixture) NewMirror

func (f *Fixture) NewMirror() *tmmirror.Mirror

func (*Fixture) Precommitter

func (f *Fixture) Precommitter(m *tmmirror.Mirror) Voter

Precommitter returns a Voter for precommits.

func (*Fixture) Prevoter

func (f *Fixture) Prevoter(m *tmmirror.Mirror) Voter

Prevoter returns a Voter for prevotes.

func (*Fixture) Store

func (f *Fixture) Store() *tmmemstore.MirrorStore

func (*Fixture) UseMetrics

func (f *Fixture) UseMetrics(t *testing.T, ctx context.Context) <-chan tmemetrics.Metrics

func (*Fixture) ValidatorStore

func (f *Fixture) ValidatorStore() tmstore.ValidatorStore

type Voter

type Voter interface {
	HandleProofs(
		ctx context.Context,
		height uint64, round uint32,
		votes map[string][]int,
	) tmconsensus.HandleVoteProofsResult

	ProofsFromView(tmconsensus.RoundView) map[string]gcrypto.CommonMessageSignatureProof
	FullProofsFromRoundStateMaps(
		height uint64, round uint32,
		valSet tmconsensus.ValidatorSet,
		prevotes, precommits tmconsensus.SparseSignatureCollection,
	) map[string]gcrypto.CommonMessageSignatureProof
}

Voter is the interface returned from *Fixture.Prevoter and *Fixture.Precommitter to offer a consistent interface to handle prevote and precommit proofs, respectively.

This simplifies sets of mirror tests where the only difference is whether we are applying prevotes or precommits.

Jump to

Keyboard shortcuts

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