utilstest

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SubnetEVMTestChainID = ids.GenerateTestID()

SubnetEVMTestChainID is a subnet-evm specific chain ID for testing

Functions

func NewTestSnowContext

func NewTestSnowContext(t testing.TB) *snow.Context

NewTestSnowContext returns a snow.Context with validator state properly configured for testing. This wraps snowtest.Context and sets the validator state to avoid the missing GetValidatorSetF issue.

Usage example:

// Instead of:
// snowCtx := utilstest.NewTestSnowContext(t, snowtest.CChainID)
// validatorState := utils.NewTestValidatorState()
// snowCtx.ValidatorState = validatorState

// Use:
snowCtx := utils.NewTestSnowContext(t)

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

func NewTestSnowContextWithChainID

func NewTestSnowContextWithChainID(t testing.TB, chainID ids.ID) *snow.Context

NewTestSnowContextWithChainID returns a snow.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

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 added in v0.7.7

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 added in v0.7.7

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