forked from cerc-io/plugeth
Fixed tests to reflect log changes
This commit is contained in:
parent
f08e9cbe42
commit
a7750c929b
@ -176,23 +176,23 @@ func RunVmTest(r io.Reader) (failed int) {
|
|||||||
failed = 1
|
failed = 1
|
||||||
} else {
|
} else {
|
||||||
for i, log := range test.Logs {
|
for i, log := range test.Logs {
|
||||||
if common.HexToAddress(log.AddressF) != logs[i].Address() {
|
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())
|
helper.Log.Infof("'%s' log address failed. Expected %v got %x", name, log.AddressF, logs[i].Address)
|
||||||
failed = 1
|
failed = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(logs[i].Data(), helper.FromHex(log.DataF)) {
|
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())
|
helper.Log.Infof("'%s' log data failed. Expected %v got %x", name, log.DataF, logs[i].Data)
|
||||||
failed = 1
|
failed = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(log.TopicsF) != len(logs[i].Topics()) {
|
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())
|
helper.Log.Infof("'%s' log topics length failed. Expected %d got %d", name, len(log.TopicsF), logs[i].Topics)
|
||||||
failed = 1
|
failed = 1
|
||||||
} else {
|
} else {
|
||||||
for j, topic := range log.TopicsF {
|
for j, topic := range log.TopicsF {
|
||||||
if common.HexToHash(topic) != logs[i].Topics()[j] {
|
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])
|
helper.Log.Infof("'%s' log topic[%d] failed. Expected %v got %x", name, j, topic, logs[i].Topics[j])
|
||||||
failed = 1
|
failed = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func (self *VMEnv) GetHash(n uint64) common.Hash {
|
|||||||
}
|
}
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
}
|
}
|
||||||
func (self *VMEnv) AddLog(log state.Log) {
|
func (self *VMEnv) AddLog(log *state.Log) {
|
||||||
self.state.AddLog(log)
|
self.state.AddLog(log)
|
||||||
}
|
}
|
||||||
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
||||||
|
@ -217,7 +217,7 @@ func TestNewLogRes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewLogsRes(t *testing.T) {
|
func TestNewLogsRes(t *testing.T) {
|
||||||
logs := make([]state.Log, 3)
|
logs := make([]*state.Log, 3)
|
||||||
logs[0] = makeStateLog(1)
|
logs[0] = makeStateLog(1)
|
||||||
logs[1] = makeStateLog(2)
|
logs[1] = makeStateLog(2)
|
||||||
logs[2] = makeStateLog(3)
|
logs[2] = makeStateLog(3)
|
||||||
@ -235,7 +235,7 @@ func TestNewLogsRes(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeStateLog(num int) state.Log {
|
func makeStateLog(num int) *state.Log {
|
||||||
address := common.HexToAddress("0x0")
|
address := common.HexToAddress("0x0")
|
||||||
data := []byte{1, 2, 3}
|
data := []byte{1, 2, 3}
|
||||||
number := uint64(num)
|
number := uint64(num)
|
||||||
|
@ -66,7 +66,7 @@ func (self *Env) VmType() vm.Type { return vm.StdVmTy }
|
|||||||
func (self *Env) GetHash(n uint64) common.Hash {
|
func (self *Env) GetHash(n uint64) common.Hash {
|
||||||
return common.BytesToHash(crypto.Sha3([]byte(big.NewInt(int64(n)).String())))
|
return common.BytesToHash(crypto.Sha3([]byte(big.NewInt(int64(n)).String())))
|
||||||
}
|
}
|
||||||
func (self *Env) AddLog(log state.Log) {
|
func (self *Env) AddLog(log *state.Log) {
|
||||||
self.logs = append(self.logs, log)
|
self.logs = append(self.logs, log)
|
||||||
}
|
}
|
||||||
func (self *Env) Depth() int { return self.depth }
|
func (self *Env) Depth() int { return self.depth }
|
||||||
|
@ -9,10 +9,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"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/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/logger/glog"
|
|
||||||
"github.com/ethereum/go-ethereum/tests/helper"
|
"github.com/ethereum/go-ethereum/tests/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,13 +80,15 @@ func RunVmTest(p string, t *testing.T) {
|
|||||||
tests := make(map[string]VmTest)
|
tests := make(map[string]VmTest)
|
||||||
helper.CreateFileTests(t, p, &tests)
|
helper.CreateFileTests(t, p, &tests)
|
||||||
|
|
||||||
|
for name, test := range tests {
|
||||||
|
/*
|
||||||
vm.Debug = true
|
vm.Debug = true
|
||||||
glog.SetV(4)
|
glog.SetV(4)
|
||||||
glog.SetToStderr(true)
|
glog.SetToStderr(true)
|
||||||
for name, test := range tests {
|
|
||||||
if name != "stackLimitPush32_1024" {
|
if name != "stackLimitPush32_1024" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
db, _ := ethdb.NewMemDatabase()
|
db, _ := ethdb.NewMemDatabase()
|
||||||
statedb := state.New(common.Hash{}, db)
|
statedb := state.New(common.Hash{}, db)
|
||||||
for addr, account := range test.Pre {
|
for addr, account := range test.Pre {
|
||||||
@ -182,20 +182,20 @@ func RunVmTest(p string, t *testing.T) {
|
|||||||
t.Errorf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
|
t.Errorf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
|
||||||
} else {
|
} else {
|
||||||
for i, log := range test.Logs {
|
for i, log := range test.Logs {
|
||||||
if common.HexToAddress(log.AddressF) != logs[i].Address() {
|
if common.HexToAddress(log.AddressF) != logs[i].Address {
|
||||||
t.Errorf("'%s' log address expected %v got %x", name, log.AddressF, logs[i].Address())
|
t.Errorf("'%s' log address expected %v got %x", name, log.AddressF, logs[i].Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(logs[i].Data(), helper.FromHex(log.DataF)) {
|
if !bytes.Equal(logs[i].Data, helper.FromHex(log.DataF)) {
|
||||||
t.Errorf("'%s' log data expected %v got %x", name, log.DataF, logs[i].Data())
|
t.Errorf("'%s' log data expected %v got %x", name, log.DataF, logs[i].Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(log.TopicsF) != len(logs[i].Topics()) {
|
if len(log.TopicsF) != len(logs[i].Topics) {
|
||||||
t.Errorf("'%s' log topics length expected %d got %d", name, len(log.TopicsF), logs[i].Topics())
|
t.Errorf("'%s' log topics length expected %d got %d", name, len(log.TopicsF), logs[i].Topics)
|
||||||
} else {
|
} else {
|
||||||
for j, topic := range log.TopicsF {
|
for j, topic := range log.TopicsF {
|
||||||
if common.HexToHash(topic) != logs[i].Topics()[j] {
|
if common.HexToHash(topic) != logs[i].Topics[j] {
|
||||||
t.Errorf("'%s' log topic[%d] expected %v got %x", name, j, topic, logs[i].Topics()[j])
|
t.Errorf("'%s' log topic[%d] expected %v got %x", name, j, topic, logs[i].Topics[j])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user