aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/block_test.go6
-rw-r--r--tests/block_test_util.go3
-rw-r--r--tests/gen_stlog.go61
-rw-r--r--tests/state_test.go12
-rw-r--r--tests/state_test_util.go68
m---------tests/testdata0
-rw-r--r--tests/vm_test.go3
-rw-r--r--tests/vm_test_util.go21
8 files changed, 41 insertions, 133 deletions
diff --git a/tests/block_test.go b/tests/block_test.go
index 6fc66b17c..56e1e1e8d 100644
--- a/tests/block_test.go
+++ b/tests/block_test.go
@@ -33,10 +33,10 @@ func TestBlockchain(t *testing.T) {
// Constantinople is not implemented yet.
bt.skipLoad(`(?i)(constantinople)`)
// Expected failures:
- bt.fails("^TransitionTests/bcEIP158ToByzantium", "byzantium not supported")
bt.fails(`^TransitionTests/bcHomesteadToDao/DaoTransactions(|_UncleExtradata|_EmptyTransactionAndForkBlocksAhead)\.json`, "issue in test")
- bt.fails(`^bc(Exploit|Fork|Gas|Multi|Total|State|Random|Uncle|Valid|Wallet).*_Byzantium$`, "byzantium not supported")
- bt.fails(`^bcBlockGasLimitTest/(BlockGasLimit2p63m1|TransactionGasHigherThanLimit2p63m1|SuicideTransaction|GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideFirst|TransactionGasHigherThanLimit2p63m1_2).*_Byzantium$`, "byzantium not supported")
+
+ // Still failing tests
+ bt.skipLoad(`^bcWalletTest.*_Byzantium$`)
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
if err := bt.checkFailure(t, name, test.Run()); err != nil {
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index c1d433ff3..a789e6d88 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -33,7 +33,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -111,7 +110,7 @@ func (t *BlockTest) Run() error {
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.json.Genesis.StateRoot[:6])
}
- chain, err := core.NewBlockChain(db, config, ethash.NewShared(), new(event.TypeMux), vm.Config{})
+ chain, err := core.NewBlockChain(db, config, ethash.NewShared(), vm.Config{})
if err != nil {
return err
}
diff --git a/tests/gen_stlog.go b/tests/gen_stlog.go
deleted file mode 100644
index 4f7ebc966..000000000
--- a/tests/gen_stlog.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
-
-package tests
-
-import (
- "encoding/json"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
-)
-
-var _ = (*stLogMarshaling)(nil)
-
-func (s stLog) MarshalJSON() ([]byte, error) {
- type stLog struct {
- Address common.UnprefixedAddress `json:"address"`
- Data hexutil.Bytes `json:"data"`
- Topics []common.UnprefixedHash `json:"topics"`
- Bloom string `json:"bloom"`
- }
- var enc stLog
- enc.Address = common.UnprefixedAddress(s.Address)
- enc.Data = s.Data
- if s.Topics != nil {
- enc.Topics = make([]common.UnprefixedHash, len(s.Topics))
- for k, v := range s.Topics {
- enc.Topics[k] = common.UnprefixedHash(v)
- }
- }
- enc.Bloom = s.Bloom
- return json.Marshal(&enc)
-}
-
-func (s *stLog) UnmarshalJSON(input []byte) error {
- type stLog struct {
- Address *common.UnprefixedAddress `json:"address"`
- Data hexutil.Bytes `json:"data"`
- Topics []common.UnprefixedHash `json:"topics"`
- Bloom *string `json:"bloom"`
- }
- var dec stLog
- if err := json.Unmarshal(input, &dec); err != nil {
- return err
- }
- if dec.Address != nil {
- s.Address = common.Address(*dec.Address)
- }
- if dec.Data != nil {
- s.Data = dec.Data
- }
- if dec.Topics != nil {
- s.Topics = make([]common.Hash, len(dec.Topics))
- for k, v := range dec.Topics {
- s.Topics[k] = common.Hash(v)
- }
- }
- if dec.Bloom != nil {
- s.Bloom = *dec.Bloom
- }
- return nil
-}
diff --git a/tests/state_test.go b/tests/state_test.go
index ab6dc423f..1fb7f5908 100644
--- a/tests/state_test.go
+++ b/tests/state_test.go
@@ -35,11 +35,10 @@ func TestState(t *testing.T) {
st.skipLoad(`^stTransactionTest/OverflowGasRequire\.json`) // gasLimit > 256 bits
st.skipLoad(`^stTransactionTest/zeroSigTransa[^/]*\.json`) // EIP-86 is not supported yet
// Expected failures:
- st.fails(`^stCodeSizeLimit/codesizeOOGInvalidSize\.json/(Frontier|Homestead|EIP150)`,
- "code size limit implementation is not conditional on fork")
- st.fails(`^stRevertTest/RevertDepthCreateAddressCollision\.json/EIP15[08]/[67]`, "bug in test")
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/EIP158`, "bug in test")
st.fails(`^stRevertTest/RevertPrefoundEmptyOOG\.json/EIP158`, "bug in test")
+ st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/Byzantium`, "bug in test")
+ st.fails(`^stRevertTest/RevertPrefoundEmptyOOG\.json/Byzantium`, "bug in test")
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() {
@@ -47,11 +46,12 @@ func TestState(t *testing.T) {
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
name := name + "/" + key
t.Run(key, func(t *testing.T) {
- if subtest.Fork == "Constantinople" || subtest.Fork == "Byzantium" {
- t.Skip("constantinople, byzantium not supported yet")
+ if subtest.Fork == "Constantinople" {
+ t.Skip("constantinople not supported yet")
}
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
- return st.checkFailure(t, name, test.Run(subtest, vmconfig))
+ _, err := test.Run(subtest, vmconfig)
+ return st.checkFailure(t, name, err)
})
})
}
diff --git a/tests/state_test_util.go b/tests/state_test_util.go
index 2bf940bab..64bf09cb4 100644
--- a/tests/state_test_util.go
+++ b/tests/state_test_util.go
@@ -17,12 +17,10 @@
package tests
import (
- "bytes"
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
- "reflect"
"strings"
"github.com/ethereum/go-ethereum/common"
@@ -33,8 +31,10 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
+ "github.com/ethereum/go-ethereum/rlp"
)
// StateTest checks transaction processing without block context.
@@ -63,7 +63,7 @@ type stJSON struct {
type stPostState struct {
Root common.UnprefixedHash `json:"hash"`
- Logs *[]stLog `json:"logs"`
+ Logs common.UnprefixedHash `json:"logs"`
Indexes struct {
Data int `json:"data"`
Gas int `json:"gas"`
@@ -108,21 +108,6 @@ type stTransactionMarshaling struct {
PrivateKey hexutil.Bytes
}
-//go:generate gencodec -type stLog -field-override stLogMarshaling -out gen_stlog.go
-
-type stLog struct {
- Address common.Address `json:"address"`
- Data []byte `json:"data"`
- Topics []common.Hash `json:"topics"`
- Bloom string `json:"bloom"`
-}
-
-type stLogMarshaling struct {
- Address common.UnprefixedAddress
- Data hexutil.Bytes
- Topics []common.UnprefixedHash
-}
-
// Subtests returns all valid subtests of the test.
func (t *StateTest) Subtests() []StateSubtest {
var sub []StateSubtest
@@ -135,10 +120,10 @@ func (t *StateTest) Subtests() []StateSubtest {
}
// Run executes a specific subtest.
-func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) error {
+func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateDB, error) {
config, ok := Forks[subtest.Fork]
if !ok {
- return UnsupportedForkError{subtest.Fork}
+ return nil, UnsupportedForkError{subtest.Fork}
}
block, _ := t.genesis(config).ToBlock()
db, _ := ethdb.NewMemDatabase()
@@ -147,7 +132,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) error {
post := t.json.Post[subtest.Fork][subtest.Index]
msg, err := t.json.Tx.toMessage(post)
if err != nil {
- return err
+ return nil, err
}
context := core.NewEVMContext(msg, block.Header(), nil, &t.json.Env.Coinbase)
context.GetHash = vmTestBlockHash
@@ -156,19 +141,17 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) error {
gaspool := new(core.GasPool)
gaspool.AddGas(block.GasLimit())
snapshot := statedb.Snapshot()
- if _, _, err := core.ApplyMessage(evm, msg, gaspool); err != nil {
+ if _, _, _, err := core.ApplyMessage(evm, msg, gaspool); err != nil {
statedb.RevertToSnapshot(snapshot)
}
- if post.Logs != nil {
- if err := checkLogs(statedb.Logs(), *post.Logs); err != nil {
- return err
- }
+ if logs := rlpHash(statedb.Logs()); logs != common.Hash(post.Logs) {
+ return statedb, fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs)
}
root, _ := statedb.CommitTo(db, config.IsEIP158(block.Number()))
if root != common.Hash(post.Root) {
- return fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
+ return statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
}
- return nil
+ return statedb, nil
}
func (t *StateTest) gasLimit(subtest StateSubtest) uint64 {
@@ -254,28 +237,9 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
return msg, nil
}
-func checkLogs(have []*types.Log, want []stLog) error {
- if len(have) != len(want) {
- return fmt.Errorf("logs length mismatch: got %d, want %d", len(have), len(want))
- }
- for i := range have {
- if have[i].Address != want[i].Address {
- return fmt.Errorf("log address %d: got %x, want %x", i, have[i].Address, want[i].Address)
- }
- if !bytes.Equal(have[i].Data, want[i].Data) {
- return fmt.Errorf("log data %d: got %x, want %x", i, have[i].Data, want[i].Data)
- }
- if !reflect.DeepEqual(have[i].Topics, want[i].Topics) {
- return fmt.Errorf("log topics %d:\ngot %x\nwant %x", i, have[i].Topics, want[i].Topics)
- }
- genBloom := math.PaddedBigBytes(types.LogsBloom([]*types.Log{have[i]}), 256)
- var wantBloom types.Bloom
- if err := hexutil.UnmarshalFixedUnprefixedText("Bloom", []byte(want[i].Bloom), wantBloom[:]); err != nil {
- return fmt.Errorf("test log %d has invalid bloom: %v", i, err)
- }
- if !bytes.Equal(genBloom, wantBloom[:]) {
- return fmt.Errorf("bloom mismatch")
- }
- }
- return nil
+func rlpHash(x interface{}) (h common.Hash) {
+ hw := sha3.NewKeccak256()
+ rlp.Encode(hw, x)
+ hw.Sum(h[:0])
+ return h
}
diff --git a/tests/testdata b/tests/testdata
-Subproject 815151e4cea4e73328f8586b4e61c3d7e1e9e54
+Subproject 1d30b4795664f64b1b157971754e14a10cfd911
diff --git a/tests/vm_test.go b/tests/vm_test.go
index 5289ba355..c9f5e225e 100644
--- a/tests/vm_test.go
+++ b/tests/vm_test.go
@@ -26,6 +26,9 @@ func TestVM(t *testing.T) {
t.Parallel()
vmt := new(testMatcher)
vmt.fails("^vmSystemOperationsTest.json/createNameRegistrator$", "fails without parallel execution")
+
+ vmt.skipLoad(`^vmInputLimits(Light)?.json`) // log format broken
+
vmt.skipShortMode("^vmPerformanceTest.json")
vmt.skipShortMode("^vmInputLimits(Light)?.json")
diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go
index afdd896c3..0aa37955c 100644
--- a/tests/vm_test_util.go
+++ b/tests/vm_test_util.go
@@ -44,14 +44,14 @@ func (t *VMTest) UnmarshalJSON(data []byte) error {
}
type vmJSON struct {
- Env stEnv `json:"env"`
- Exec vmExec `json:"exec"`
- Logs []stLog `json:"logs"`
- GasRemaining *math.HexOrDecimal64 `json:"gas"`
- Out hexutil.Bytes `json:"out"`
- Pre core.GenesisAlloc `json:"pre"`
- Post core.GenesisAlloc `json:"post"`
- PostStateRoot common.Hash `json:"postStateRoot"`
+ Env stEnv `json:"env"`
+ Exec vmExec `json:"exec"`
+ Logs common.UnprefixedHash `json:"logs"`
+ GasRemaining *math.HexOrDecimal64 `json:"gas"`
+ Out hexutil.Bytes `json:"out"`
+ Pre core.GenesisAlloc `json:"pre"`
+ Post core.GenesisAlloc `json:"post"`
+ PostStateRoot common.Hash `json:"postStateRoot"`
}
//go:generate gencodec -type vmExec -field-override vmExecMarshaling -out gen_vmexec.go
@@ -109,7 +109,10 @@ func (t *VMTest) Run(vmconfig vm.Config) error {
// if root := statedb.IntermediateRoot(false); root != t.json.PostStateRoot {
// return fmt.Errorf("post state root mismatch, got %x, want %x", root, t.json.PostStateRoot)
// }
- return checkLogs(statedb.Logs(), t.json.Logs)
+ if logs := rlpHash(statedb.Logs()); logs != common.Hash(t.json.Logs) {
+ return fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, t.json.Logs)
+ }
+ return nil
}
func (t *VMTest) exec(statedb *state.StateDB, vmconfig vm.Config) ([]byte, uint64, error) {