mirror of
https://github.com/luxfi/evmgpu.git
synced 2026-10-30 16:57:11 +00:00
params, utilstest, allowlisttest and warp each carried a test file written against an API that has since moved, so `go vet ./...` reported four build failures and those packages ran no tests at all. - utilstest: validator state comes from the runtime context, not consensus, and GetValidatorSet takes a context now. - params: DurangoTimestamp lives on extras.ChainConfig; the geth ChainConfig literal no longer has the field. The test already sets it on extras. - allowlisttest: contract.Configurator gained MakeGenesisConfig. - warp: the runtime import is used under the name context; block.Context is reached as chain.Context; the validator wrapper had the pre-context GetValidatorSet signature; runtime has no WithIDs, and the test helper NewTestConsensusContextWithChainID already does what it was reaching for. Also stop range-copying types.Block in core/rlp_import_test.go: it carries an atomic.Pointer that must not be copied. vet flagged it. go build ./... and go vet ./... now both exit 0. Co-authored-by: Hanzo Dev <[email protected]>
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package utilstest
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/runtime"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewTestConsensusContext(t *testing.T) {
|
|
// Test that NewTestConsensusContext creates a context with validator state
|
|
consensusCtx := NewTestConsensusContext(t)
|
|
|
|
// Extract validator state through the runtime context used in production.
|
|
validatorState := runtime.GetValidatorState(consensusCtx)
|
|
require.NotNil(t, validatorState)
|
|
|
|
// Test that we can call GetValidatorSet without panicking
|
|
validators, err := validatorState.GetValidatorSet(context.Background(), 0, ids.Empty)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, validators)
|
|
|
|
// Test GetCurrentHeight
|
|
height, err := validatorState.GetCurrentHeight(context.Background())
|
|
require.NoError(t, err)
|
|
require.Equal(t, uint64(0), height)
|
|
|
|
// Test GetChainID
|
|
chainID, err := validatorState.GetChainID(EVMTestChainID)
|
|
require.NoError(t, err)
|
|
require.Equal(t, ids.Empty, chainID) // Default returns empty ID
|
|
}
|