aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/block_test_util.go24
-rw-r--r--tests/gen_btheader.go20
-rw-r--r--tests/gen_stenv.go8
-rw-r--r--tests/gen_sttransaction.go4
-rw-r--r--tests/gen_tttransaction.go12
-rw-r--r--tests/gen_vmexec.go8
-rw-r--r--tests/state_test.go13
-rw-r--r--tests/state_test_util.go18
m---------tests/testdata0
-rw-r--r--tests/transaction_test_util.go8
-rw-r--r--tests/vm_test_util.go2
11 files changed, 57 insertions, 60 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index a789e6d88..beba48483 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -77,8 +77,8 @@ type btHeader struct {
UncleHash common.Hash
ExtraData []byte
Difficulty *big.Int
- GasLimit *big.Int
- GasUsed *big.Int
+ GasLimit uint64
+ GasUsed uint64
Timestamp *big.Int
}
@@ -86,8 +86,8 @@ type btHeaderMarshaling struct {
ExtraData hexutil.Bytes
Number *math.HexOrDecimal256
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
- GasUsed *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
+ GasUsed math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
@@ -110,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(), vm.Config{})
+ chain, err := core.NewBlockChain(db, nil, config, ethash.NewShared(), vm.Config{})
if err != nil {
return err
}
@@ -120,7 +120,7 @@ func (t *BlockTest) Run() error {
if err != nil {
return err
}
- cmlast := chain.LastBlockHash()
+ cmlast := chain.CurrentBlock().Hash()
if common.Hash(t.json.BestBlock) != cmlast {
return fmt.Errorf("last block hash validation mismatch: want: %x, have: %x", t.json.BestBlock, cmlast)
}
@@ -141,8 +141,8 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
Timestamp: t.json.Genesis.Timestamp.Uint64(),
ParentHash: t.json.Genesis.ParentHash,
ExtraData: t.json.Genesis.ExtraData,
- GasLimit: t.json.Genesis.GasLimit.Uint64(),
- GasUsed: t.json.Genesis.GasUsed.Uint64(),
+ GasLimit: t.json.Genesis.GasLimit,
+ GasUsed: t.json.Genesis.GasUsed,
Difficulty: t.json.Genesis.Difficulty,
Mixhash: t.json.Genesis.MixHash,
Coinbase: t.json.Genesis.Coinbase,
@@ -234,11 +234,11 @@ func validateHeader(h *btHeader, h2 *types.Header) error {
if h.Difficulty.Cmp(h2.Difficulty) != 0 {
return fmt.Errorf("Difficulty: want: %v have: %v", h.Difficulty, h2.Difficulty)
}
- if h.GasLimit.Cmp(h2.GasLimit) != 0 {
- return fmt.Errorf("GasLimit: want: %v have: %v", h.GasLimit, h2.GasLimit)
+ if h.GasLimit != h2.GasLimit {
+ return fmt.Errorf("GasLimit: want: %d have: %d", h.GasLimit, h2.GasLimit)
}
- if h.GasUsed.Cmp(h2.GasUsed) != 0 {
- return fmt.Errorf("GasUsed: want: %v have: %v", h.GasUsed, h2.GasUsed)
+ if h.GasUsed != h2.GasUsed {
+ return fmt.Errorf("GasUsed: want: %d have: %d", h.GasUsed, h2.GasUsed)
}
if h.Timestamp.Cmp(h2.Time) != 0 {
return fmt.Errorf("Timestamp: want: %v have: %v", h.Timestamp, h2.Time)
diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go
index 5d65e0dbc..5cfd4bd0a 100644
--- a/tests/gen_btheader.go
+++ b/tests/gen_btheader.go
@@ -29,8 +29,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
UncleHash common.Hash
ExtraData hexutil.Bytes
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
- GasUsed *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
+ GasUsed math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
var enc btHeader
@@ -47,8 +47,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
enc.UncleHash = b.UncleHash
enc.ExtraData = b.ExtraData
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
- enc.GasLimit = (*math.HexOrDecimal256)(b.GasLimit)
- enc.GasUsed = (*math.HexOrDecimal256)(b.GasUsed)
+ enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
+ enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
return json.Marshal(&enc)
}
@@ -66,10 +66,10 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
StateRoot *common.Hash
TransactionsTrie *common.Hash
UncleHash *common.Hash
- ExtraData hexutil.Bytes
+ ExtraData *hexutil.Bytes
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
- GasUsed *math.HexOrDecimal256
+ GasLimit *math.HexOrDecimal64
+ GasUsed *math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
var dec btHeader
@@ -110,16 +110,16 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
b.UncleHash = *dec.UncleHash
}
if dec.ExtraData != nil {
- b.ExtraData = dec.ExtraData
+ b.ExtraData = *dec.ExtraData
}
if dec.Difficulty != nil {
b.Difficulty = (*big.Int)(dec.Difficulty)
}
if dec.GasLimit != nil {
- b.GasLimit = (*big.Int)(dec.GasLimit)
+ b.GasLimit = uint64(*dec.GasLimit)
}
if dec.GasUsed != nil {
- b.GasUsed = (*big.Int)(dec.GasUsed)
+ b.GasUsed = uint64(*dec.GasUsed)
}
if dec.Timestamp != nil {
b.Timestamp = (*big.Int)(dec.Timestamp)
diff --git a/tests/gen_stenv.go b/tests/gen_stenv.go
index c780524bc..1d4baf2fd 100644
--- a/tests/gen_stenv.go
+++ b/tests/gen_stenv.go
@@ -17,14 +17,14 @@ func (s stEnv) MarshalJSON() ([]byte, error) {
type stEnv struct {
Coinbase common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"`
Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `json:"currentGasLimit" gencodec:"required"`
+ GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"`
Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"`
Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"`
}
var enc stEnv
enc.Coinbase = common.UnprefixedAddress(s.Coinbase)
enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty)
- enc.GasLimit = (*math.HexOrDecimal256)(s.GasLimit)
+ enc.GasLimit = math.HexOrDecimal64(s.GasLimit)
enc.Number = math.HexOrDecimal64(s.Number)
enc.Timestamp = math.HexOrDecimal64(s.Timestamp)
return json.Marshal(&enc)
@@ -34,7 +34,7 @@ func (s *stEnv) UnmarshalJSON(input []byte) error {
type stEnv struct {
Coinbase *common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"`
Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `json:"currentGasLimit" gencodec:"required"`
+ GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"`
Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"`
Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"`
}
@@ -53,7 +53,7 @@ func (s *stEnv) UnmarshalJSON(input []byte) error {
if dec.GasLimit == nil {
return errors.New("missing required field 'currentGasLimit' for stEnv")
}
- s.GasLimit = (*big.Int)(dec.GasLimit)
+ s.GasLimit = uint64(*dec.GasLimit)
if dec.Number == nil {
return errors.New("missing required field 'currentNumber' for stEnv")
}
diff --git a/tests/gen_sttransaction.go b/tests/gen_sttransaction.go
index 5a489d00b..451ffcbf4 100644
--- a/tests/gen_sttransaction.go
+++ b/tests/gen_sttransaction.go
@@ -46,7 +46,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
Data []string `json:"data"`
GasLimit []math.HexOrDecimal64 `json:"gasLimit"`
Value []string `json:"value"`
- PrivateKey hexutil.Bytes `json:"secretKey"`
+ PrivateKey *hexutil.Bytes `json:"secretKey"`
}
var dec stTransaction
if err := json.Unmarshal(input, &dec); err != nil {
@@ -74,7 +74,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
s.Value = dec.Value
}
if dec.PrivateKey != nil {
- s.PrivateKey = dec.PrivateKey
+ s.PrivateKey = *dec.PrivateKey
}
return nil
}
diff --git a/tests/gen_tttransaction.go b/tests/gen_tttransaction.go
index b6759be91..2948842d9 100644
--- a/tests/gen_tttransaction.go
+++ b/tests/gen_tttransaction.go
@@ -17,7 +17,7 @@ var _ = (*ttTransactionMarshaling)(nil)
func (t ttTransaction) MarshalJSON() ([]byte, error) {
type ttTransaction struct {
Data hexutil.Bytes `gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `gencodec:"required"`
+ GasLimit math.HexOrDecimal64 `gencodec:"required"`
GasPrice *math.HexOrDecimal256 `gencodec:"required"`
Nonce math.HexOrDecimal64 `gencodec:"required"`
Value *math.HexOrDecimal256 `gencodec:"required"`
@@ -28,7 +28,7 @@ func (t ttTransaction) MarshalJSON() ([]byte, error) {
}
var enc ttTransaction
enc.Data = t.Data
- enc.GasLimit = (*math.HexOrDecimal256)(t.GasLimit)
+ enc.GasLimit = math.HexOrDecimal64(t.GasLimit)
enc.GasPrice = (*math.HexOrDecimal256)(t.GasPrice)
enc.Nonce = math.HexOrDecimal64(t.Nonce)
enc.Value = (*math.HexOrDecimal256)(t.Value)
@@ -41,8 +41,8 @@ func (t ttTransaction) MarshalJSON() ([]byte, error) {
func (t *ttTransaction) UnmarshalJSON(input []byte) error {
type ttTransaction struct {
- Data hexutil.Bytes `gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `gencodec:"required"`
+ Data *hexutil.Bytes `gencodec:"required"`
+ GasLimit *math.HexOrDecimal64 `gencodec:"required"`
GasPrice *math.HexOrDecimal256 `gencodec:"required"`
Nonce *math.HexOrDecimal64 `gencodec:"required"`
Value *math.HexOrDecimal256 `gencodec:"required"`
@@ -58,11 +58,11 @@ func (t *ttTransaction) UnmarshalJSON(input []byte) error {
if dec.Data == nil {
return errors.New("missing required field 'data' for ttTransaction")
}
- t.Data = dec.Data
+ t.Data = *dec.Data
if dec.GasLimit == nil {
return errors.New("missing required field 'gasLimit' for ttTransaction")
}
- t.GasLimit = (*big.Int)(dec.GasLimit)
+ t.GasLimit = uint64(*dec.GasLimit)
if dec.GasPrice == nil {
return errors.New("missing required field 'gasPrice' for ttTransaction")
}
diff --git a/tests/gen_vmexec.go b/tests/gen_vmexec.go
index dd2d3d94e..a5f01cf45 100644
--- a/tests/gen_vmexec.go
+++ b/tests/gen_vmexec.go
@@ -42,8 +42,8 @@ func (v *vmExec) UnmarshalJSON(input []byte) error {
Address *common.UnprefixedAddress `json:"address" gencodec:"required"`
Caller *common.UnprefixedAddress `json:"caller" gencodec:"required"`
Origin *common.UnprefixedAddress `json:"origin" gencodec:"required"`
- Code hexutil.Bytes `json:"code" gencodec:"required"`
- Data hexutil.Bytes `json:"data" gencodec:"required"`
+ Code *hexutil.Bytes `json:"code" gencodec:"required"`
+ Data *hexutil.Bytes `json:"data" gencodec:"required"`
Value *math.HexOrDecimal256 `json:"value" gencodec:"required"`
GasLimit *math.HexOrDecimal64 `json:"gas" gencodec:"required"`
GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"`
@@ -67,11 +67,11 @@ func (v *vmExec) UnmarshalJSON(input []byte) error {
if dec.Code == nil {
return errors.New("missing required field 'code' for vmExec")
}
- v.Code = dec.Code
+ v.Code = *dec.Code
if dec.Data == nil {
return errors.New("missing required field 'data' for vmExec")
}
- v.Data = dec.Data
+ v.Data = *dec.Data
if dec.Value == nil {
return errors.New("missing required field 'value' for vmExec")
}
diff --git a/tests/state_test.go b/tests/state_test.go
index 5a67b290d..100c776c1 100644
--- a/tests/state_test.go
+++ b/tests/state_test.go
@@ -39,16 +39,12 @@ func TestState(t *testing.T) {
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.fails(`^stRandom/randomStatetest645\.json/EIP150/.*`, "known bug #15119")
- st.fails(`^stRandom/randomStatetest645\.json/Frontier/.*`, "known bug #15119")
- st.fails(`^stRandom/randomStatetest645\.json/Homestead/.*`, "known bug #15119")
- st.fails(`^stRandom/randomStatetest644\.json/EIP150/.*`, "known bug #15119")
- st.fails(`^stRandom/randomStatetest644\.json/Frontier/.*`, "known bug #15119")
- st.fails(`^stRandom/randomStatetest644\.json/Homestead/.*`, "known bug #15119")
+ st.fails(`^stRandom2/randomStatetest64[45]\.json/(EIP150|Frontier|Homestead)/.*`, "known bug #15119")
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/EIP158/2`, "known bug ")
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/EIP158/3`, "known bug ")
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/Byzantium/2`, "known bug ")
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/Byzantium/3`, "known bug ")
+
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() {
subtest := subtest
@@ -68,8 +64,7 @@ func TestState(t *testing.T) {
}
// Transactions with gasLimit above this value will not get a VM trace on failure.
-//const traceErrorLimit = 400000
-const traceErrorLimit = 0
+const traceErrorLimit = 400000
func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
err := test(vm.Config{})
@@ -93,4 +88,6 @@ func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
} else {
t.Log("EVM operation log:\n" + buf.String())
}
+ t.Logf("EVM output: 0x%x", tracer.Output())
+ t.Logf("EVM error: %v", tracer.Error())
}
diff --git a/tests/state_test_util.go b/tests/state_test_util.go
index 352f840d9..18280d2a4 100644
--- a/tests/state_test_util.go
+++ b/tests/state_test_util.go
@@ -76,7 +76,7 @@ type stPostState struct {
type stEnv struct {
Coinbase common.Address `json:"currentCoinbase" gencodec:"required"`
Difficulty *big.Int `json:"currentDifficulty" gencodec:"required"`
- GasLimit *big.Int `json:"currentGasLimit" gencodec:"required"`
+ GasLimit uint64 `json:"currentGasLimit" gencodec:"required"`
Number uint64 `json:"currentNumber" gencodec:"required"`
Timestamp uint64 `json:"currentTimestamp" gencodec:"required"`
}
@@ -84,7 +84,7 @@ type stEnv struct {
type stEnvMarshaling struct {
Coinbase common.UnprefixedAddress
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
Number math.HexOrDecimal64
Timestamp math.HexOrDecimal64
}
@@ -125,9 +125,9 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
if !ok {
return nil, UnsupportedForkError{subtest.Fork}
}
- block, _ := t.genesis(config).ToBlock()
+ block := t.genesis(config).ToBlock(nil)
db, _ := ethdb.NewMemDatabase()
- statedb := makePreState(db, t.json.Pre)
+ statedb := MakePreState(db, t.json.Pre)
post := t.json.Post[subtest.Fork][subtest.Index]
msg, err := t.json.Tx.toMessage(post)
@@ -147,7 +147,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
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()))
+ root, _ := statedb.Commit(config.IsEIP158(block.Number()))
if root != common.Hash(post.Root) {
return statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
}
@@ -158,7 +158,7 @@ func (t *StateTest) gasLimit(subtest StateSubtest) uint64 {
return t.json.Tx.GasLimit[t.json.Post[subtest.Fork][subtest.Index].Indexes.Gas]
}
-func makePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB {
+func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB {
sdb := state.NewDatabase(db)
statedb, _ := state.New(common.Hash{}, sdb)
for addr, a := range accounts {
@@ -170,7 +170,7 @@ func makePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB
}
}
// Commit and re-open to start with a clean state.
- root, _ := statedb.CommitTo(db, false)
+ root, _ := statedb.Commit(false)
statedb, _ = state.New(root, sdb)
return statedb
}
@@ -180,7 +180,7 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
Config: config,
Coinbase: t.json.Env.Coinbase,
Difficulty: t.json.Env.Difficulty,
- GasLimit: t.json.Env.GasLimit.Uint64(),
+ GasLimit: t.json.Env.GasLimit,
Number: t.json.Env.Number,
Timestamp: t.json.Env.Timestamp,
Alloc: t.json.Pre,
@@ -233,7 +233,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
return nil, fmt.Errorf("invalid tx data %q", dataHex)
}
- msg := types.NewMessage(from, to, tx.Nonce, value, new(big.Int).SetUint64(gasLimit), tx.GasPrice, data, true)
+ msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true)
return msg, nil
}
diff --git a/tests/testdata b/tests/testdata
-Subproject 37f555fbc091fbf761aa6f02227132fb31f0681
+Subproject 2bb0c3da3bbb15c528bcef2a7e5ac4bd73f81f8
diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go
index 472b3d6f2..2028d2a27 100644
--- a/tests/transaction_test_util.go
+++ b/tests/transaction_test_util.go
@@ -46,7 +46,7 @@ type ttJSON struct {
type ttTransaction struct {
Data []byte `gencodec:"required"`
- GasLimit *big.Int `gencodec:"required"`
+ GasLimit uint64 `gencodec:"required"`
GasPrice *big.Int `gencodec:"required"`
Nonce uint64 `gencodec:"required"`
Value *big.Int `gencodec:"required"`
@@ -58,7 +58,7 @@ type ttTransaction struct {
type ttTransactionMarshaling struct {
Data hexutil.Bytes
- GasLimit *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
GasPrice *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Value *math.HexOrDecimal256
@@ -100,8 +100,8 @@ func (tt *ttTransaction) verify(signer types.Signer, tx *types.Transaction) erro
if !bytes.Equal(tx.Data(), tt.Data) {
return fmt.Errorf("Tx input data mismatch: got %x want %x", tx.Data(), tt.Data)
}
- if tx.Gas().Cmp(tt.GasLimit) != 0 {
- return fmt.Errorf("GasLimit mismatch: got %v, want %v", tx.Gas(), tt.GasLimit)
+ if tx.Gas() != tt.GasLimit {
+ return fmt.Errorf("GasLimit mismatch: got %d, want %d", tx.Gas(), tt.GasLimit)
}
if tx.GasPrice().Cmp(tt.GasPrice) != 0 {
return fmt.Errorf("GasPrice mismatch: got %v, want %v", tx.GasPrice(), tt.GasPrice)
diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go
index 0aa37955c..b365167a6 100644
--- a/tests/vm_test_util.go
+++ b/tests/vm_test_util.go
@@ -80,7 +80,7 @@ type vmExecMarshaling struct {
func (t *VMTest) Run(vmconfig vm.Config) error {
db, _ := ethdb.NewMemDatabase()
- statedb := makePreState(db, t.json.Pre)
+ statedb := MakePreState(db, t.json.Pre)
ret, gasRemaining, err := t.exec(statedb, vmconfig)
if t.json.GasRemaining == nil {