Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access list state test format #22290

Merged
merged 11 commits into from
Mar 3, 2021
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 @@ -96,13 +96,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 @@ -293,8 +294,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