diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/state_test_util.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 0b78f26ed..c6341e524 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -21,6 +21,7 @@ import ( "encoding/json" "fmt" "math/big" + "strconv" "strings" "github.com/ethereum/go-ethereum/common" @@ -109,6 +110,29 @@ type stTransactionMarshaling struct { PrivateKey hexutil.Bytes } +// getVMConfig takes a fork definition and returns a chain config. +// The fork definition can be +// - a plain forkname, e.g. `Byzantium`, +// - a fork basename, and a list of EIPs to enable; e.g. `Byzantium+1884+1283`. +func getVMConfig(forkString string) (baseConfig *params.ChainConfig, eips []int, err error) { + var ( + splitForks = strings.Split(forkString, "+") + ok bool + baseName, eipsStrings = splitForks[0], splitForks[1:] + ) + if baseConfig, ok = Forks[baseName]; !ok { + return nil, nil, UnsupportedForkError{baseName} + } + for _, eip := range eipsStrings { + if eipNum, err := strconv.Atoi(eip); err != nil { + return nil, nil, fmt.Errorf("syntax error, invalid eip number %v", eipNum) + } else { + eips = append(eips, eipNum) + } + } + return baseConfig, eips, nil +} + // Subtests returns all valid subtests of the test. func (t *StateTest) Subtests() []StateSubtest { var sub []StateSubtest @@ -122,10 +146,11 @@ func (t *StateTest) Subtests() []StateSubtest { // Run executes a specific subtest. func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateDB, error) { - config, ok := Forks[subtest.Fork] - if !ok { + config, eips, err := getVMConfig(subtest.Fork) + if err != nil { return nil, UnsupportedForkError{subtest.Fork} } + vmconfig.ExtraEips = eips block := t.genesis(config).ToBlock(nil) statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre) |