consensustest

package
v1.22.46 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown    uint8 = 0
	Processing uint8 = 1
	Rejected   uint8 = 2
	Accepted   uint8 = 3
)

Block status constants (must match choices.Status enum)

Variables

View Source
var (
	PChainID = ids.GenerateTestID()
	XChainID = ids.GenerateTestID()
	CChainID = ids.GenerateTestID()
	// Use fixed asset ID to match genesistest.LUXAssetID for UTXO consistency
	XAssetID = ids.ID{'l', 'u', 'x', ' ', 'a', 's', 's', 'e', 't', ' ', 'i', 'd'}
)

Functions

func ConsensusContext

func ConsensusContext(ctx *consensus.Context) *consensus.Context

ConsensusContext updates a consensus context with default test values

func Context

func Context(tb testing.TB, chainID ids.ID) *consensus.Context

Context creates a new consensus context for testing with a specific chain ID

func NewContext

func NewContext(tb testing.TB) *consensus.Context

NewContext creates a new consensus context for testing This is a compatibility function that creates a context with a generated chain ID

Types

type Decidable

type Decidable struct {
	IDV     ids.ID
	StatusV choices.Status
}

Decidable is an embedded struct for test blocks

func (*Decidable) Accept

func (d *Decidable) Accept(context.Context) error

Accept marks this as accepted

func (*Decidable) ID

func (d *Decidable) ID() ids.ID

ID returns the ID of this decidable

func (*Decidable) Reject

func (d *Decidable) Reject(context.Context) error

Reject marks this as rejected

func (*Decidable) Status

func (d *Decidable) Status() choices.Status

Status returns the current status

type MockEngine

type MockEngine struct {
	StartCalled  bool
	StopCalled   bool
	Bootstrapped bool
}

MockEngine is a mock consensus engine

func (*MockEngine) HealthCheck

func (m *MockEngine) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck performs health check

func (*MockEngine) IsBootstrapped

func (m *MockEngine) IsBootstrapped() bool

IsBootstrapped returns bootstrap status

func (*MockEngine) Start

func (m *MockEngine) Start(ctx context.Context, requestID uint32) error

Start starts the engine

func (*MockEngine) Stop

func (m *MockEngine) Stop(ctx context.Context) error

Stop stops the engine

type SimpleValidatorState

type SimpleValidatorState struct{}

SimpleValidatorState is a minimal validator state for testing

func (*SimpleValidatorState) GetCurrentHeight

func (s *SimpleValidatorState) GetCurrentHeight(ctx context.Context) (uint64, error)

GetCurrentHeight returns height 0 for testing

func (*SimpleValidatorState) GetCurrentValidators added in v1.22.2

func (s *SimpleValidatorState) GetCurrentValidators(ctx context.Context, height uint64, netID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)

GetCurrentValidators returns an empty validator set for testing

func (*SimpleValidatorState) GetValidatorSet

func (s *SimpleValidatorState) GetValidatorSet(ctx context.Context, height uint64, netID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)

GetValidatorSet returns an empty validator set for testing

func (*SimpleValidatorState) GetWarpValidatorSet added in v1.22.2

func (s *SimpleValidatorState) GetWarpValidatorSet(ctx context.Context, height uint64, netID ids.ID) (*validators.WarpSet, error)

GetWarpValidatorSet returns an empty warp validator set for testing

func (*SimpleValidatorState) GetWarpValidatorSets added in v1.22.2

func (s *SimpleValidatorState) GetWarpValidatorSets(ctx context.Context, heights []uint64, netIDs []ids.ID) (map[ids.ID]map[uint64]*validators.WarpSet, error)

GetWarpValidatorSets returns empty warp validator sets for testing

type TestConfig

type TestConfig struct {
	NodeID    ids.NodeID
	NetworkID uint32
	ChainID   ids.ID
}

TestConfig provides test configuration

func NewTestConfig

func NewTestConfig(t *testing.T) *TestConfig

NewTestConfig creates a test config

Jump to

Keyboard shortcuts

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