aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-08-08 17:07:23 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-08-08 17:07:23 +0800
commit3e993ff64a9c2e9651fae11aaee55032cd6b0c3e (patch)
treea41e37be7f46f3fb2a3a7a0025587770d67f149e /tests
parentf3478f2899e80d59d15956ae408fab93cf26254d (diff)
downloadgo-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.tar
go-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.tar.gz
go-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.tar.bz2
go-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.tar.lz
go-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.tar.xz
go-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.tar.zst
go-tangerine-3e993ff64a9c2e9651fae11aaee55032cd6b0c3e.zip
Eip 1884 v3 (#19743)
* core/vm, tests: implement EIP 1884, add support for feature-tests * core/vm: 1884-changes to extcodehash, move selfbalance opcode * tests: fix statetests * core/vm: move constants, address review concerns * core/vm: word formatting Co-Authored-By: Péter Szilágyi <peterke@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/state_test_util.go29
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)