Files
zeekayandHanzo Dev edd69068a3 test: restore the four test packages that no longer compiled
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]>
2026-08-28 23:24:57 -07:00

72 lines
1.9 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package allowlisttest
import (
"testing"
"github.com/luxfi/evmgpu/precompile/allowlist"
"github.com/luxfi/evmgpu/precompile/contract"
"github.com/luxfi/evmgpu/precompile/modules"
"github.com/luxfi/evmgpu/precompile/precompileconfig"
"github.com/luxfi/geth/common"
)
var (
_ precompileconfig.Config = (*dummyConfig)(nil)
_ contract.Configurator = (*dummyConfigurator)(nil)
dummyAddr = common.Address{1}
)
type dummyConfig struct {
precompileconfig.Upgrade
allowlist.AllowListConfig
}
func (d *dummyConfig) Key() string { return "dummy" }
func (d *dummyConfig) IsDisabled() bool { return false }
func (d *dummyConfig) Verify(chainConfig precompileconfig.ChainConfig) error {
return d.AllowListConfig.Verify(chainConfig, d.Upgrade)
}
func (d *dummyConfig) Equal(cfg precompileconfig.Config) bool {
other, ok := (cfg).(*dummyConfig)
if !ok {
return false
}
return d.AllowListConfig.Equal(&other.AllowListConfig)
}
type dummyConfigurator struct{}
func (d *dummyConfigurator) MakeConfig() precompileconfig.Config {
return &dummyConfig{}
}
func (d *dummyConfigurator) MakeGenesisConfig() precompileconfig.Config {
var zero uint64
return &dummyConfig{Upgrade: precompileconfig.Upgrade{BlockTimestamp: &zero}}
}
func (d *dummyConfigurator) Configure(
chainConfig precompileconfig.ChainConfig,
precompileConfig precompileconfig.Config,
state contract.StateDB,
blockContext contract.ConfigurationBlockContext,
) error {
cfg := precompileConfig.(*dummyConfig)
return cfg.Configure(chainConfig, dummyAddr, state, blockContext)
}
func TestAllowListRun(t *testing.T) {
dummyModule := modules.Module{
Address: dummyAddr,
Contract: allowlist.CreateAllowListPrecompile(dummyAddr),
Configurator: &dummyConfigurator{},
ConfigKey: "dummy",
}
RunPrecompileWithAllowListTests(t, dummyModule, nil)
}