aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-19 22:21:49 +0800
committerFelix Lange <fjl@twurst.com>2015-03-19 22:21:49 +0800
commitce063e8d9c2d26dd283a43b097903628225179ea (patch)
tree3bf88d349fd799285d75926f4486cb13f3cc7c70 /cmd
parente80dda605130479086bed363e395a102a89a574a (diff)
parent797bbce15ecf9ec76f6375a328c63eb9abcc3b5a (diff)
downloadgo-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.gz
go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.zst
go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.zip
Merge remote-tracking branch 'ethereum/conversion' into conversion
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ethtest/main.go64
1 files changed, 45 insertions, 19 deletions
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
index 23ae9e525..ee6bcc540 100644
--- a/cmd/ethtest/main.go
+++ b/cmd/ethtest/main.go
@@ -33,8 +33,9 @@ import (
"strconv"
"strings"
- "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
@@ -67,7 +68,7 @@ type Account struct {
}
func StateObjectFromAccount(db common.Database, addr string, account Account) *state.StateObject {
- obj := state.NewStateObject(common.Hex2Bytes(addr), db)
+ obj := state.NewStateObject(common.HexToAddress(addr), db)
obj.SetBalance(common.Big(account.Balance))
if common.IsHex(account.Code) {
@@ -113,7 +114,7 @@ func RunVmTest(r io.Reader) (failed int) {
for name, test := range tests {
db, _ := ethdb.NewMemDatabase()
- statedb := state.New(nil, db)
+ statedb := state.New(common.Hash{}, db)
for addr, account := range test.Pre {
obj := StateObjectFromAccount(db, addr, account)
statedb.SetStateObject(obj)
@@ -136,57 +137,82 @@ func RunVmTest(r io.Reader) (failed int) {
rexp := helper.FromHex(test.Out)
if bytes.Compare(rexp, ret) != 0 {
- fmt.Printf("FAIL: %s's return failed. Expected %x, got %x\n", name, rexp, ret)
+ helper.Log.Infof("%s's return failed. Expected %x, got %x\n", name, rexp, ret)
failed = 1
}
for addr, account := range test.Post {
- obj := statedb.GetStateObject(helper.FromHex(addr))
+ obj := statedb.GetStateObject(common.HexToAddress(addr))
if obj == nil {
continue
}
if len(test.Exec) == 0 {
if obj.Balance().Cmp(common.Big(account.Balance)) != 0 {
- fmt.Printf("FAIL: %s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(common.Big(account.Balance), obj.Balance()))
+ helper.Log.Infof("%s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address().Bytes()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(common.Big(account.Balance), obj.Balance()))
failed = 1
}
}
for addr, value := range account.Storage {
- v := obj.GetState(helper.FromHex(addr)).Bytes()
+ v := obj.GetState(common.HexToHash(addr)).Bytes()
vexp := helper.FromHex(value)
if bytes.Compare(v, vexp) != 0 {
- fmt.Printf("FAIL: %s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address()[0:4], addr, vexp, v, common.BigD(vexp), common.BigD(v))
+ helper.Log.Infof("%s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address().Bytes()[0:4], addr, vexp, v, common.BigD(vexp), common.BigD(v))
failed = 1
}
}
}
- if !bytes.Equal(common.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
- fmt.Printf("FAIL: %s's : Post state root error. Expected %s, got %x\n", name, test.PostStateRoot, statedb.Root())
+ statedb.Sync()
+ //if !bytes.Equal(common.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
+ if common.HexToHash(test.PostStateRoot) != statedb.Root() {
+ helper.Log.Infof("%s's : Post state root failed. Expected %s, got %x", name, test.PostStateRoot, statedb.Root())
failed = 1
}
if len(test.Logs) > 0 {
if len(test.Logs) != len(logs) {
- fmt.Printf("FAIL: log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
+ helper.Log.Infof("log length failed. Expected %d, got %d", len(test.Logs), len(logs))
failed = 1
} else {
- /*
- fmt.Println("A", test.Logs)
- fmt.Println("B", logs)
- for i, log := range test.Logs {
- genBloom := common.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
- if !bytes.Equal(genBloom, common.Hex2Bytes(log.BloomF)) {
- t.Errorf("bloom mismatch")
+ for i, log := range test.Logs {
+ if common.HexToAddress(log.AddressF) != logs[i].Address() {
+ helper.Log.Infof("'%s' log address failed. Expected %v got %x", name, log.AddressF, logs[i].Address())
+ failed = 1
+ }
+
+ if !bytes.Equal(logs[i].Data(), helper.FromHex(log.DataF)) {
+ helper.Log.Infof("'%s' log data failed. Expected %v got %x", name, log.DataF, logs[i].Data())
+ failed = 1
+ }
+
+ if len(log.TopicsF) != len(logs[i].Topics()) {
+ helper.Log.Infof("'%s' log topics length failed. Expected %d got %d", name, len(log.TopicsF), logs[i].Topics())
+ failed = 1
+ } else {
+ for j, topic := range log.TopicsF {
+ if common.HexToHash(topic) != logs[i].Topics()[j] {
+ helper.Log.Infof("'%s' log topic[%d] failed. Expected %v got %x", name, j, topic, logs[i].Topics()[j])
+ failed = 1
}
}
- */
+ }
+ genBloom := common.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
+
+ if !bytes.Equal(genBloom, common.Hex2Bytes(log.BloomF)) {
+ helper.Log.Infof("'%s' bloom failed.", name)
+ failed = 1
+ }
+ }
}
}
+ if failed == 1 {
+ fmt.Println(string(statedb.Dump()))
+ }
+
logger.Flush()
}