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"
"fmt"
"math/big"
"strconv"
"strings"
"github.com/ethereum/go-ethereum/common"
@ -115,22 +116,21 @@ type stTransactionMarshaling struct {
// - 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, "+")
eipStrings []string
ok bool
splitForks = strings.Split(forkString, "+")
ok bool
baseName, eipsStrings = splitForks[0], splitForks[1:]
)
baseName, eipsStrings = splitForks[0], splitForks[1:]
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 {
return nil, fmt.Errorf("syntax error, invalid eip number %v", eipNum)
return nil, nil, fmt.Errorf("syntax error, invalid eip number %v", eipNum)
} else {
eips = append(eips, eipNum)
}
}
return baseConfig, eips
return baseConfig, eips, nil
}
// Subtests returns all valid subtests of the test.
@ -146,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, eips, ok := getVMConfig(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)