consensustest

package
v1.22.65 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

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

Block status constants

Variables

View Source
var (
	PChainID   = ids.GenerateTestID()
	XChainID   = ids.GenerateTestID()
	CChainID   = ids.GenerateTestID()
	LUXAssetID = ids.GenerateTestID()
)

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) GetChainID

func (s *SimpleValidatorState) GetChainID(chainID ids.ID) (ids.ID, error)

func (*SimpleValidatorState) GetCurrentHeight

func (s *SimpleValidatorState) GetCurrentHeight() (uint64, error)

func (*SimpleValidatorState) GetMinimumHeight

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

func (*SimpleValidatorState) GetNetID

func (s *SimpleValidatorState) GetNetID(chainID ids.ID) (ids.ID, error)

func (*SimpleValidatorState) GetSubnetID

func (s *SimpleValidatorState) GetSubnetID(chainID ids.ID) (ids.ID, error)

func (*SimpleValidatorState) GetValidatorSet

func (s *SimpleValidatorState) GetValidatorSet(height uint64, subnetID ids.ID) (map[ids.NodeID]uint64, error)

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