tests: fix statetests

This commit is contained in:
Martin Holst Swende 2019-08-06 16:01:01 +02:00
parent acbb531492
commit 7fd83d01f2
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -21,6 +21,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"math/big" "math/big"
"strconv"
"strings" "strings"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -116,21 +117,20 @@ type stTransactionMarshaling struct {
func getVMConfig(forkString string) (baseConfig *params.ChainConfig, eips []int, err error) { func getVMConfig(forkString string) (baseConfig *params.ChainConfig, eips []int, err error) {
var ( var (
splitForks = strings.Split(forkString, "+") splitForks = strings.Split(forkString, "+")
eipStrings []string
ok bool ok bool
)
baseName, eipsStrings = splitForks[0], splitForks[1:] baseName, eipsStrings = splitForks[0], splitForks[1:]
)
if baseConfig, ok = Forks[baseName]; !ok { if baseConfig, ok = Forks[baseName]; !ok {
return nil, UnsupportedForkError{subtest.Fork} return nil, nil, UnsupportedForkError{baseName}
} }
for _, eip := range eips { for _, eip := range eipsStrings {
if eipNum, err := strconv.Atoi(eip); err != nil { if eipNum, err := strconv.Atoi(eip); err != nil {
return nil, fmt.Errorf("syntax error, invalid eip number %v", eipNum) return nil, nil, fmt.Errorf("syntax error, invalid eip number %v", eipNum)
} else { } else {
eips = append(eips, eipNum) eips = append(eips, eipNum)
} }
} }
return baseConfig, eips return baseConfig, eips, nil
} }
// Subtests returns all valid subtests of the test. // Subtests returns all valid subtests of the test.
@ -146,10 +146,11 @@ func (t *StateTest) Subtests() []StateSubtest {
// Run executes a specific subtest. // Run executes a specific subtest.
func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateDB, error) { func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateDB, error) {
config, eips, ok := getVMConfig(subtest.Fork) config, eips, err := getVMConfig(subtest.Fork)
if !ok { if err != nil {
return nil, UnsupportedForkError{subtest.Fork} return nil, UnsupportedForkError{subtest.Fork}
} }
vmconfig.ExtraEips = eips
block := t.genesis(config).ToBlock(nil) block := t.genesis(config).ToBlock(nil)
statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre) statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre)