utilstest

package
v0.8.26 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: GPL-3.0, LGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EVMTestChainID = ids.GenerateTestID()

EVMTestChainID is a evm specific chain ID for testing

Functions

func NewTestConsensusContext added in v0.8.6

func NewTestConsensusContext(t testing.TB) context.Context

NewTestConsensusContext returns a context.Context with validator state properly configured for testing. This wraps consensustest.Context and sets the validator state to avoid the missing GetValidatorSetF issue.

Usage example:

// Instead of:
// consensusCtx := utilstest.NewTestConsensusContext(t, consensustest.CChainID)
// validatorState := utils.NewTestValidatorState()
// consensusCtx.ValidatorState = validatorState

// Use:
consensusCtx := utils.NewTestConsensusContext(t)

This function ensures that the consensus context has a properly configured validator state that includes the GetValidatorSetF function, which is required by many tests.

func NewTestConsensusContextWithChainID added in v0.8.6

func NewTestConsensusContextWithChainID(t testing.TB, chainID ids.ID) context.Context

NewTestConsensusContextWithChainID returns a context.Context with validator state properly configured for testing with a specific chain ID. This is provided for backward compatibility when a specific chain ID is needed.

func NewTestValidatorState added in v0.8.4

func NewTestValidatorState() consensuscontext.ValidatorState

@TODO: This should eventually be replaced by a more robust solution, or alternatively, the presence of nil validator states shouldn't be depended upon by tests

func NewTestValidatorStateFromBase added in v0.8.8

func NewTestValidatorStateFromBase(baseState *validatorstest.State) consensuscontext.ValidatorState

NewTestValidatorStateFromBase creates a testValidatorState that wraps an existing validatorstest.State This is useful when you need to use a specific validatorstest.State with custom functions but still implement the consensuscontext.ValidatorState interface.

Types

type Key

type Key struct {
	Address    common.Address
	PrivateKey *ecdsa.PrivateKey
}

Key contains an ecdsa private key field as well as an address field obtained from converting the ecdsa public key.

func NewKey

func NewKey(t *testing.T) *Key

NewKey generates a new key pair and returns a pointer to a Key.

Jump to

Keyboard shortcuts

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