utilstest

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SubnetEVMTestChainID = ids.GenerateTestID()

SubnetEVMTestChainID is a evm specific chain ID for testing

Functions

func NewTestConsensusContext added in v0.8.6

func NewTestConsensusContext(t testing.TB) *consensus.Context

NewTestConsensusContext returns a consensus.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) *consensus.Context

NewTestConsensusContextWithChainID returns a consensus.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() *validatorstest.State

@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

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