tmstatetest

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: 16 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

	// Exposed on the fixture explicitly as the MockConsensusStrategy type.
	CStrat *tmconsensustest.MockConsensusStrategy

	RoundTimer *MockRoundTimer

	RoundViewInCh         chan tmeil.StateMachineRoundView
	RoundEntranceOutCh    chan tmeil.StateMachineRoundEntrance
	FinalizeBlockRequests chan tmdriver.FinalizeBlockRequest
	BlockDataArrivalCh    chan tmelink.BlockDataArrival

	Cfg tmstate.StateMachineConfig

	WatchdogCtx context.Context
}

Fixture is a helper type to create a tmstate.StateMachine and its required inputs for tests involving a StateMachine.

func NewFixture

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

func (*Fixture) EmptyVRV

func (*Fixture) NewStateMachine

func (f *Fixture) NewStateMachine() *tmstate.StateMachine

type MockRoundTimer

type MockRoundTimer struct {
	// contains filtered or unexported fields
}

func (*MockRoundTimer) ActiveTimer

func (t *MockRoundTimer) ActiveTimer() (name string, h uint64, r uint32)

func (*MockRoundTimer) CommitWaitStartNotification

func (t *MockRoundTimer) CommitWaitStartNotification(h uint64, r uint32) <-chan struct{}

func (*MockRoundTimer) CommitWaitTimer

func (t *MockRoundTimer) CommitWaitTimer(_ context.Context, h uint64, r uint32) (<-chan struct{}, func())

func (*MockRoundTimer) ElapseCommitWaitTimer

func (t *MockRoundTimer) ElapseCommitWaitTimer(h uint64, r uint32) error

func (*MockRoundTimer) ElapsePrecommitDelayTimer

func (t *MockRoundTimer) ElapsePrecommitDelayTimer(h uint64, r uint32) error

func (*MockRoundTimer) ElapsePrevoteDelayTimer

func (t *MockRoundTimer) ElapsePrevoteDelayTimer(h uint64, r uint32) error

func (*MockRoundTimer) ElapseProposalTimer

func (t *MockRoundTimer) ElapseProposalTimer(h uint64, r uint32) error

func (*MockRoundTimer) PrecommitDelayStartNotification

func (t *MockRoundTimer) PrecommitDelayStartNotification(h uint64, r uint32) <-chan struct{}

func (*MockRoundTimer) PrecommitDelayTimer

func (t *MockRoundTimer) PrecommitDelayTimer(_ context.Context, h uint64, r uint32) (<-chan struct{}, func())

func (*MockRoundTimer) PrevoteDelayStartNotification

func (t *MockRoundTimer) PrevoteDelayStartNotification(h uint64, r uint32) <-chan struct{}

func (*MockRoundTimer) PrevoteDelayTimer

func (t *MockRoundTimer) PrevoteDelayTimer(_ context.Context, h uint64, r uint32) (<-chan struct{}, func())

func (*MockRoundTimer) ProposalStartNotification

func (t *MockRoundTimer) ProposalStartNotification(h uint64, r uint32) <-chan struct{}

func (*MockRoundTimer) ProposalTimer

func (t *MockRoundTimer) ProposalTimer(_ context.Context, h uint64, r uint32) (<-chan struct{}, func())

func (*MockRoundTimer) RequireActiveCommitWaitTimer

func (t *MockRoundTimer) RequireActiveCommitWaitTimer(tt *testing.T, height uint64, round uint32)

func (*MockRoundTimer) RequireActivePrecommitDelayTimer

func (t *MockRoundTimer) RequireActivePrecommitDelayTimer(tt *testing.T, height uint64, round uint32)

func (*MockRoundTimer) RequireActivePrevoteDelayTimer

func (t *MockRoundTimer) RequireActivePrevoteDelayTimer(tt *testing.T, height uint64, round uint32)

func (*MockRoundTimer) RequireActiveProposalTimer

func (t *MockRoundTimer) RequireActiveProposalTimer(tt *testing.T, height uint64, round uint32)

func (*MockRoundTimer) RequireNoActiveTimer

func (t *MockRoundTimer) RequireNoActiveTimer(tt *testing.T)

type ProposedHeaderMutator

type ProposedHeaderMutator struct {
	Name   string
	Mutate func(*tmconsensus.ProposedHeader)
}

ProposedHeaderMutator is returned by UnacceptableProposedHeaderMutations to be used in table-driven tests when modifying an otherwise good proposed header to be ignored by the state machine.

func UnacceptableProposedHeaderMutations

func UnacceptableProposedHeaderMutations(
	hs tmconsensus.HashScheme, nCurVals, nNextVals int,
) []ProposedHeaderMutator

UnacceptableProposedHeaderMutations returns a slice of mutators that can be used in table-driven tests to ensure that the state machine ignores certain invalid proposed headers.

The nCurVals and nNextVals arguments are used to determine an incorrect number of validators to set in the proposed header, in order to be ignored.

Jump to

Keyboard shortcuts

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