Skip to content

Commit

Permalink
tests: update to latest tests (ethereum#22290)
Browse files Browse the repository at this point in the history
This updates the consensus tests to commit 31d6630 and
adds support for access list transactions in the test runner.

Co-authored-by: Martin Holst Swende <martin@swende.se>
  • Loading branch information
MariusVanDerWijden and holiman authored Mar 3, 2021
1 parent 5a81dd9 commit cd316d7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 41 deletions.
14 changes: 5 additions & 9 deletions tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ func TestBlockchain(t *testing.T) {

bt := new(testMatcher)
// General state tests are 'exported' as blockchain tests, but we can run them natively.
bt.skipLoad(`^GeneralStateTests/`)
// For speedier CI-runs, the line below can be uncommented, so those are skipped.
// For now, in hardfork-times (Berlin), we run the tests both as StateTests and
// as blockchain tests, since the latter also covers things like receipt root
//bt.skipLoad(`^GeneralStateTests/`)

// Skip random failures due to selfish mining test
bt.skipLoad(`.*bcForgedTest/bcForkUncle\.json`)

Expand All @@ -43,15 +47,7 @@ func TestBlockchain(t *testing.T) {
// test takes a lot for time and goes easily OOM because of sha3 calculation on a huge range,
// using 4.6 TGas
bt.skipLoad(`.*randomStatetest94.json.*`)

bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
if test.json.Network == "Berlin" {
// Our current berlin-tests were generated using YOLOv2 rules, hence a lot of them
// fail when berlin is defined as YOLOv3. We skip those, until they've been
// regenerated and re-imported
// TODO (@holiman)
return
}
if err := bt.checkFailure(t, name+"/trie", test.Run(false)); err != nil {
t.Errorf("test without snapshotter failed: %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions tests/gen_stenv.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions tests/gen_sttransaction.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/gen_vmexec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions tests/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ func TestState(t *testing.T) {
} {
st.walk(t, dir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() {
if subtest.Fork == "Berlin" {
// Our current berlin-tests were generated using YOLOv2 rules, hence a lot of them
// fail when berlin is defined as YOLOv3. We skip those, until they've been
// regenerated and re-imported
// TODO (@holiman)
continue
}

subtest := subtest
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
name := name + "/" + key
Expand Down
22 changes: 13 additions & 9 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ type stEnvMarshaling struct {
//go:generate gencodec -type stTransaction -field-override stTransactionMarshaling -out gen_sttransaction.go

type stTransaction struct {
GasPrice *big.Int `json:"gasPrice"`
Nonce uint64 `json:"nonce"`
To string `json:"to"`
Data []string `json:"data"`
GasLimit []uint64 `json:"gasLimit"`
Value []string `json:"value"`
PrivateKey []byte `json:"secretKey"`
GasPrice *big.Int `json:"gasPrice"`
Nonce uint64 `json:"nonce"`
To string `json:"to"`
Data []string `json:"data"`
AccessLists []*types.AccessList `json:"accessLists,omitempty"`
GasLimit []uint64 `json:"gasLimit"`
Value []string `json:"value"`
PrivateKey []byte `json:"secretKey"`
}

type stTransactionMarshaling struct {
Expand Down Expand Up @@ -292,8 +293,11 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
if err != nil {
return nil, fmt.Errorf("invalid tx data %q", dataHex)
}

msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, nil, true)
var accessList types.AccessList
if tx.AccessLists != nil && tx.AccessLists[ps.Indexes.Data] != nil {
accessList = *tx.AccessLists[ps.Indexes.Data]
}
msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, accessList, true)
return msg, nil
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testdata
Submodule testdata updated 4583 files

0 comments on commit cd316d7

Please sign in to comment.