Skip to content

Commit e3853e9

Browse files
authored
tests: update ethereum/tests to v17.0 (ethereum#31381)
Get the re-filled tests (plus removal of outdated EIP-2537 tests)
1 parent 475e87c commit e3853e9

File tree

5 files changed

+57
-52
lines changed

5 files changed

+57
-52
lines changed

tests/block_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func TestBlockchain(t *testing.T) {
6363
// With chain history removal, TDs become unavailable, this transition tests based on TTD are unrunnable
6464
bt.skipLoad(`.*bcArrowGlacierToParis/powToPosBlockRejection.json`)
6565

66+
// This directory contains no test.
67+
bt.skipLoad(`.*\.meta/.*`)
68+
6669
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
6770
execBlockTest(t, bt, test)
6871
})

tests/state_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,9 @@ func initMatcher(st *testMatcher) {
5454
// Uses 1GB RAM per tested fork
5555
st.skipLoad(`^stStaticCall/static_Call1MB`)
5656

57-
// Out-of-date EIP-2537 tests
58-
// TODO (@s1na) reenable in the future
59-
st.skipLoad(`^stEIP2537/`)
60-
6157
// Broken tests:
6258
// EOF is not part of cancun
6359
st.skipLoad(`^stEOF/`)
64-
65-
// The tests under Pyspecs are the ones that are published as execution-spec tests.
66-
// We run these tests separately, no need to _also_ run them as part of the
67-
// reference tests.
68-
st.skipLoad(`^Pyspecs/`)
6960
}
7061

7162
func TestState(t *testing.T) {

tests/testdata

tests/transaction_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"testing"
2121

2222
"github.com/ethereum/go-ethereum/common"
23-
"github.com/ethereum/go-ethereum/params"
2423
)
2524

2625
func TestTransaction(t *testing.T) {
@@ -58,8 +57,7 @@ func TestTransaction(t *testing.T) {
5857
txt.skipLoad("^ttEIP1559/GasLimitPriceProductOverflow.json")
5958

6059
txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
61-
cfg := params.MainnetChainConfig
62-
if err := txt.checkFailure(t, test.Run(cfg)); err != nil {
60+
if err := txt.checkFailure(t, test.Run()); err != nil {
6361
t.Error(err)
6462
}
6563
})
@@ -75,8 +73,7 @@ func TestExecutionSpecTransaction(t *testing.T) {
7573
st.skipLoad("^prague/eip7702_set_code_tx/invalid_tx/empty_authorization_list.json")
7674

7775
st.walk(t, executionSpecTransactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
78-
cfg := params.MainnetChainConfig
79-
if err := st.checkFailure(t, test.Run(cfg)); err != nil {
76+
if err := st.checkFailure(t, test.Run()); err != nil {
8077
t.Error(err)
8178
}
8279
})

tests/transaction_test_util.go

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package tests
1818

1919
import (
2020
"fmt"
21+
"math/big"
2122

2223
"github.com/ethereum/go-ethereum/common"
2324
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -65,11 +66,11 @@ func (tt *TransactionTest) validateFork(fork *ttFork) error {
6566
return nil
6667
}
6768

68-
func (tt *TransactionTest) Run(config *params.ChainConfig) error {
69+
func (tt *TransactionTest) Run() error {
6970
if err := tt.validate(); err != nil {
7071
return err
7172
}
72-
validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead, isIstanbul, isShanghai bool) (sender common.Address, hash common.Hash, requiredGas uint64, err error) {
73+
validateTx := func(rlpData hexutil.Bytes, signer types.Signer, rules *params.Rules) (sender common.Address, hash common.Hash, requiredGas uint64, err error) {
7374
tx := new(types.Transaction)
7475
if err = tx.UnmarshalBinary(rlpData); err != nil {
7576
return
@@ -79,62 +80,75 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
7980
return
8081
}
8182
// Intrinsic gas
82-
requiredGas, err = core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, isHomestead, isIstanbul, isShanghai)
83+
requiredGas, err = core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
8384
if err != nil {
8485
return
8586
}
8687
if requiredGas > tx.Gas() {
8788
return sender, hash, 0, fmt.Errorf("insufficient gas ( %d < %d )", tx.Gas(), requiredGas)
8889
}
90+
91+
if rules.IsPrague {
92+
var floorDataGas uint64
93+
floorDataGas, err = core.FloorDataGas(tx.Data())
94+
if err != nil {
95+
return
96+
}
97+
if tx.Gas() < floorDataGas {
98+
return sender, hash, 0, fmt.Errorf("%w: have %d, want %d", core.ErrFloorDataGas, tx.Gas(), floorDataGas)
99+
}
100+
}
89101
hash = tx.Hash()
90102
return sender, hash, requiredGas, nil
91103
}
92104
for _, testcase := range []struct {
93-
name string
94-
signer types.Signer
95-
fork *ttFork
96-
isHomestead bool
97-
isIstanbul bool
98-
isShanghai bool
105+
name string
106+
isMerge bool
99107
}{
100-
{"Frontier", types.FrontierSigner{}, tt.Result["Frontier"], false, false, false},
101-
{"Homestead", types.HomesteadSigner{}, tt.Result["Homestead"], true, false, false},
102-
{"EIP150", types.HomesteadSigner{}, tt.Result["EIP150"], true, false, false},
103-
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.Result["EIP158"], true, false, false},
104-
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Result["Byzantium"], true, false, false},
105-
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Result["Constantinople"], true, false, false},
106-
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Result["Istanbul"], true, true, false},
107-
{"Berlin", types.NewEIP2930Signer(config.ChainID), tt.Result["Berlin"], true, true, false},
108-
{"London", types.NewLondonSigner(config.ChainID), tt.Result["London"], true, true, false},
109-
{"Paris", types.NewLondonSigner(config.ChainID), tt.Result["Paris"], true, true, false},
110-
{"Shanghai", types.NewLondonSigner(config.ChainID), tt.Result["Shanghai"], true, true, true},
111-
{"Cancun", types.NewCancunSigner(config.ChainID), tt.Result["Cancun"], true, true, true},
112-
{"Prague", types.NewPragueSigner(config.ChainID), tt.Result["Prague"], true, true, true},
108+
{"Frontier", false},
109+
{"Homestead", false},
110+
{"EIP150", false},
111+
{"EIP158", false},
112+
{"Byzantium", false},
113+
{"Constantinople", false},
114+
{"Istanbul", false},
115+
{"Berlin", false},
116+
{"London", false},
117+
{"Paris", true},
118+
{"Shanghai", true},
119+
{"Cancun", true},
120+
{"Prague", true},
113121
} {
114-
if testcase.fork == nil {
122+
expected := tt.Result[testcase.name]
123+
if expected == nil {
115124
continue
116125
}
117-
sender, hash, gas, err := validateTx(tt.Txbytes, testcase.signer, testcase.isHomestead, testcase.isIstanbul, testcase.isShanghai)
126+
config, ok := Forks[testcase.name]
127+
if !ok || config == nil {
128+
return UnsupportedForkError{Name: testcase.name}
129+
}
130+
var (
131+
rules = config.Rules(new(big.Int), testcase.isMerge, 0)
132+
signer = types.MakeSigner(config, new(big.Int), 0)
133+
)
134+
sender, hash, gas, err := validateTx(tt.Txbytes, signer, &rules)
118135
if err != nil {
119-
if testcase.fork.Hash != nil {
120-
return fmt.Errorf("unexpected error: %v", err)
136+
if expected.Hash != nil {
137+
return fmt.Errorf("unexpected error fork %s: %v", testcase.name, err)
121138
}
122139
continue
123140
}
124-
if testcase.fork.Exception != nil {
125-
return fmt.Errorf("expected error %v, got none (%v)", *testcase.fork.Exception, err)
126-
}
127-
if common.Hash(*testcase.fork.Hash) != hash {
128-
return fmt.Errorf("hash mismatch: got %x, want %x", hash, common.Hash(*testcase.fork.Hash))
141+
if expected.Exception != nil {
142+
return fmt.Errorf("expected error %v, got none (%v), fork %s", *expected.Exception, err, testcase.name)
129143
}
130-
if common.Address(*testcase.fork.Sender) != sender {
131-
return fmt.Errorf("sender mismatch: got %x, want %x", sender, testcase.fork.Sender)
144+
if common.Hash(*expected.Hash) != hash {
145+
return fmt.Errorf("hash mismatch: got %x, want %x", hash, common.Hash(*expected.Hash))
132146
}
133-
if hash != common.Hash(*testcase.fork.Hash) {
134-
return fmt.Errorf("hash mismatch: got %x, want %x", hash, testcase.fork.Hash)
147+
if common.Address(*expected.Sender) != sender {
148+
return fmt.Errorf("sender mismatch: got %x, want %x", sender, expected.Sender)
135149
}
136-
if uint64(testcase.fork.IntrinsicGas) != gas {
137-
return fmt.Errorf("intrinsic gas mismatch: got %d, want %d", gas, uint64(testcase.fork.IntrinsicGas))
150+
if uint64(expected.IntrinsicGas) != gas {
151+
return fmt.Errorf("intrinsic gas mismatch: got %d, want %d", gas, uint64(expected.IntrinsicGas))
138152
}
139153
}
140154
return nil

0 commit comments

Comments
 (0)