Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions plugin/evm/tx_gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ import (
func TestEthTxGossip(t *testing.T) {
require := require.New(t)
ctx := t.Context()
snowCtx := utilstest.NewTestSnowContext(t)
validatorState := utilstest.NewTestValidatorState()
snowCtx.ValidatorState = validatorState
snowCtx := utilstest.NewTestSnowContextWithValidatorState(t, validatorState)

responseSender := &enginetest.SenderStub{
SentAppResponse: make(chan []byte, 1),
Expand Down Expand Up @@ -70,7 +69,7 @@ func TestEthTxGossip(t *testing.T) {
validatorSet := p2p.NewValidators(
logging.NoLog{},
snowCtx.SubnetID,
validatorState,
snowCtx.ValidatorState,
0,
)
network, err := p2p.NewNetwork(
Expand Down
14 changes: 6 additions & 8 deletions utils/utilstest/context.go → utils/utilstest/snow.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ func NewTestValidatorState() *validatorstest.State {
// 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 NewTestSnowContext(t testing.TB) *snow.Context {
snowCtx := snowtest.Context(t, SubnetEVMTestChainID)
snowCtx.ValidatorState = NewTestValidatorState()
return snowCtx
return NewTestSnowContextWithValidatorState(t, NewTestValidatorState())
}

// 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 NewTestSnowContextWithChainID(t testing.TB, chainID ids.ID) *snow.Context {
snowCtx := snowtest.Context(t, chainID)
snowCtx.ValidatorState = NewTestValidatorState()
// NewTestSnowContextWithValidatorState returns a snow.Context with the provided validator state.
// This is useful when you need to customize the validator state behavior for specific tests.
func NewTestSnowContextWithValidatorState(t testing.TB, validatorState validators.State) *snow.Context {
snowCtx := snowtest.Context(t, SubnetEVMTestChainID)
snowCtx.ValidatorState = validatorState
return snowCtx
}
Loading