Skip to content

Commit

Permalink
tests: update tests/testdata to v9.0.4 (london) (ethereum#23279)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden authored Jul 29, 2021
1 parent 5c13012 commit fb8ea59
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
18 changes: 9 additions & 9 deletions tests/block_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ type btHeader struct {
GasLimit uint64
GasUsed uint64
Timestamp uint64
BaseFee *big.Int
BaseFeePerGas *big.Int
}

type btHeaderMarshaling struct {
ExtraData hexutil.Bytes
Number *math.HexOrDecimal256
Difficulty *math.HexOrDecimal256
GasLimit math.HexOrDecimal64
GasUsed math.HexOrDecimal64
Timestamp math.HexOrDecimal64
BaseFee *math.HexOrDecimal256
ExtraData hexutil.Bytes
Number *math.HexOrDecimal256
Difficulty *math.HexOrDecimal256
GasLimit math.HexOrDecimal64
GasUsed math.HexOrDecimal64
Timestamp math.HexOrDecimal64
BaseFeePerGas *math.HexOrDecimal256
}

func (t *BlockTest) Run(snapshotter bool) error {
Expand Down Expand Up @@ -170,7 +170,7 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
Mixhash: t.json.Genesis.MixHash,
Coinbase: t.json.Genesis.Coinbase,
Alloc: t.json.Pre,
BaseFee: t.json.Genesis.BaseFee,
BaseFee: t.json.Genesis.BaseFeePerGas,
}
}

Expand Down
10 changes: 5 additions & 5 deletions tests/gen_btheader.go

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

8 changes: 8 additions & 0 deletions tests/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func TestState(t *testing.T) {
t.Run(key+"/trie", func(t *testing.T) {
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
_, _, err := test.Run(subtest, vmconfig, false)
if err != nil && len(test.json.Post[subtest.Fork][subtest.Index].ExpectException) > 0 {
// Ignore expected errors (TODO MariusVanDerWijden check error string)
return nil
}
return st.checkFailure(t, err)
})
})
Expand All @@ -79,6 +83,10 @@ func TestState(t *testing.T) {
return err
}
}
if err != nil && len(test.json.Post[subtest.Fork][subtest.Index].ExpectException) > 0 {
// Ignore expected errors (TODO MariusVanDerWijden check error string)
return nil
}
return st.checkFailure(t, err)
})
})
Expand Down
21 changes: 18 additions & 3 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ type stJSON struct {
}

type stPostState struct {
Root common.UnprefixedHash `json:"hash"`
Logs common.UnprefixedHash `json:"logs"`
Indexes struct {
Root common.UnprefixedHash `json:"hash"`
Logs common.UnprefixedHash `json:"logs"`
TxBytes hexutil.Bytes `json:"txbytes"`
ExpectException string `json:"expectException"`
Indexes struct {
Data int `json:"data"`
Gas int `json:"gas"`
Value int `json:"value"`
Expand Down Expand Up @@ -198,6 +200,19 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
return nil, nil, common.Hash{}, err
}

// Try to recover tx with current signer
if len(post.TxBytes) != 0 {
var ttx types.Transaction
err := ttx.UnmarshalBinary(post.TxBytes)
if err != nil {
return nil, nil, common.Hash{}, err
}

if _, err := types.Sender(types.LatestSigner(config), &ttx); err != nil {
return nil, nil, common.Hash{}, err
}
}

// Prepare the EVM.
txContext := core.NewEVMTxContext(msg)
context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase)
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata

0 comments on commit fb8ea59

Please sign in to comment.