mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
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
|
|
}
|