aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-16 18:27:38 +0800
committerobscuren <geffobscura@gmail.com>2015-03-16 18:27:38 +0800
commitb5234413611ce5984292f85a01de1f56c045b490 (patch)
treee6e0c6f7fe8358a2dc63cdea11ac66b4f59397f5 /tests
parent0b8f66ed9ef177dc72442dd7ba337c6733e30344 (diff)
downloaddexon-b5234413611ce5984292f85a01de1f56c045b490.tar
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.gz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.bz2
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.lz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.xz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.zst
dexon-b5234413611ce5984292f85a01de1f56c045b490.zip
Moved ethutil => common
Diffstat (limited to 'tests')
-rw-r--r--tests/blocktest.go4
-rw-r--r--tests/helper/common.go6
-rw-r--r--tests/helper/vm.go32
-rw-r--r--tests/vm/gh_test.go36
4 files changed, 39 insertions, 39 deletions
diff --git a/tests/blocktest.go b/tests/blocktest.go
index 6a9cf5f6d..0b923f08b 100644
--- a/tests/blocktest.go
+++ b/tests/blocktest.go
@@ -13,7 +13,7 @@ import (
"strings"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/state"
)
@@ -97,7 +97,7 @@ func LoadBlockTests(file string) (map[string]*BlockTest, error) {
// InsertPreState populates the given database with the genesis
// accounts defined by the test.
-func (t *BlockTest) InsertPreState(db ethutil.Database) error {
+func (t *BlockTest) InsertPreState(db common.Database) error {
statedb := state.New(nil, db)
for addrString, acct := range t.preAccounts {
// XXX: is is worth it checking for errors here?
diff --git a/tests/helper/common.go b/tests/helper/common.go
index 6a071968d..21ea2261f 100644
--- a/tests/helper/common.go
+++ b/tests/helper/common.go
@@ -1,11 +1,11 @@
package helper
-import "github.com/ethereum/go-ethereum/ethutil"
+import "github.com/ethereum/go-ethereum/common"
func FromHex(h string) []byte {
- if ethutil.IsHex(h) {
+ if common.IsHex(h) {
h = h[2:]
}
- return ethutil.Hex2Bytes(h)
+ return common.Hex2Bytes(h)
}
diff --git a/tests/helper/vm.go b/tests/helper/vm.go
index f1aaf74b8..a7fd98696 100644
--- a/tests/helper/vm.go
+++ b/tests/helper/vm.go
@@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
)
@@ -41,13 +41,13 @@ func NewEnv(state *state.StateDB) *Env {
func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues map[string]string) *Env {
env := NewEnv(state)
- env.origin = ethutil.Hex2Bytes(exeValues["caller"])
- env.parent = ethutil.Hex2Bytes(envValues["previousHash"])
- env.coinbase = ethutil.Hex2Bytes(envValues["currentCoinbase"])
- env.number = ethutil.Big(envValues["currentNumber"])
- env.time = ethutil.Big(envValues["currentTimestamp"]).Int64()
- env.difficulty = ethutil.Big(envValues["currentDifficulty"])
- env.gasLimit = ethutil.Big(envValues["currentGasLimit"])
+ env.origin = common.Hex2Bytes(exeValues["caller"])
+ env.parent = common.Hex2Bytes(envValues["previousHash"])
+ env.coinbase = common.Hex2Bytes(envValues["currentCoinbase"])
+ env.number = common.Big(envValues["currentNumber"])
+ env.time = common.Big(envValues["currentTimestamp"]).Int64()
+ env.difficulty = common.Big(envValues["currentDifficulty"])
+ env.gasLimit = common.Big(envValues["currentGasLimit"])
env.Gas = new(big.Int)
return env
@@ -135,9 +135,9 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
to = FromHex(exec["address"])
from = FromHex(exec["caller"])
data = FromHex(exec["data"])
- gas = ethutil.Big(exec["gas"])
- price = ethutil.Big(exec["gasPrice"])
- value = ethutil.Big(exec["value"])
+ gas = common.Big(exec["gas"])
+ price = common.Big(exec["gasPrice"])
+ value = common.Big(exec["value"])
)
// Reset the pre-compiled contracts for VM tests.
vm.Precompiled = make(map[string]*vm.PrecompiledAccount)
@@ -155,12 +155,12 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.Logs, *big.Int, error) {
var (
- keyPair, _ = crypto.NewKeyPairFromSec([]byte(ethutil.Hex2Bytes(tx["secretKey"])))
+ keyPair, _ = crypto.NewKeyPairFromSec([]byte(common.Hex2Bytes(tx["secretKey"])))
to = FromHex(tx["to"])
data = FromHex(tx["data"])
- gas = ethutil.Big(tx["gasLimit"])
- price = ethutil.Big(tx["gasPrice"])
- value = ethutil.Big(tx["value"])
+ gas = common.Big(tx["gasLimit"])
+ price = common.Big(tx["gasPrice"])
+ value = common.Big(tx["value"])
caddr = FromHex(env["currentCoinbase"])
)
@@ -169,7 +169,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
snapshot := statedb.Copy()
coinbase := statedb.GetOrNewStateObject(caddr)
- coinbase.SetGasPool(ethutil.Big(env["currentGasLimit"]))
+ coinbase.SetGasPool(common.Big(env["currentGasLimit"]))
message := NewMessage(keyPair.Address(), to, data, value, gas, price)
vmenv := NewEnvFromMap(statedb, env, tx)
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go
index 1e8cd5b51..24718de7b 100644
--- a/tests/vm/gh_test.go
+++ b/tests/vm/gh_test.go
@@ -7,7 +7,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
@@ -27,26 +27,26 @@ type Log struct {
BloomF string `json:"bloom"`
}
-func (self Log) Address() []byte { return ethutil.Hex2Bytes(self.AddressF) }
-func (self Log) Data() []byte { return ethutil.Hex2Bytes(self.DataF) }
+func (self Log) Address() []byte { return common.Hex2Bytes(self.AddressF) }
+func (self Log) Data() []byte { return common.Hex2Bytes(self.DataF) }
func (self Log) RlpData() interface{} { return nil }
func (self Log) Topics() [][]byte {
t := make([][]byte, len(self.TopicsF))
for i, topic := range self.TopicsF {
- t[i] = ethutil.Hex2Bytes(topic)
+ t[i] = common.Hex2Bytes(topic)
}
return t
}
-func StateObjectFromAccount(db ethutil.Database, addr string, account Account) *state.StateObject {
- obj := state.NewStateObject(ethutil.Hex2Bytes(addr), db)
- obj.SetBalance(ethutil.Big(account.Balance))
+func StateObjectFromAccount(db common.Database, addr string, account Account) *state.StateObject {
+ obj := state.NewStateObject(common.Hex2Bytes(addr), db)
+ obj.SetBalance(common.Big(account.Balance))
- if ethutil.IsHex(account.Code) {
+ if common.IsHex(account.Code) {
account.Code = account.Code[2:]
}
- obj.SetCode(ethutil.Hex2Bytes(account.Code))
- obj.SetNonce(ethutil.Big(account.Nonce).Uint64())
+ obj.SetCode(common.Hex2Bytes(account.Code))
+ obj.SetNonce(common.Big(account.Nonce).Uint64())
return obj
}
@@ -86,7 +86,7 @@ func RunVmTest(p string, t *testing.T) {
obj := StateObjectFromAccount(db, addr, account)
statedb.SetStateObject(obj)
for a, v := range account.Storage {
- obj.SetState(helper.FromHex(a), ethutil.NewValue(helper.FromHex(v)))
+ obj.SetState(helper.FromHex(a), common.NewValue(helper.FromHex(v)))
}
}
@@ -126,7 +126,7 @@ func RunVmTest(p string, t *testing.T) {
if len(test.Gas) == 0 && err == nil {
t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull", name)
} else {
- gexp := ethutil.Big(test.Gas)
+ gexp := common.Big(test.Gas)
if gexp.Cmp(gas) != 0 {
t.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas)
}
@@ -140,8 +140,8 @@ func RunVmTest(p string, t *testing.T) {
}
if len(test.Exec) == 0 {
- if obj.Balance().Cmp(ethutil.Big(account.Balance)) != 0 {
- t.Errorf("%s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(ethutil.Big(account.Balance), obj.Balance()))
+ if obj.Balance().Cmp(common.Big(account.Balance)) != 0 {
+ t.Errorf("%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()))
}
}
@@ -150,14 +150,14 @@ func RunVmTest(p string, t *testing.T) {
vexp := helper.FromHex(value)
if bytes.Compare(v, vexp) != 0 {
- t.Errorf("%s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address()[0:4], addr, vexp, v, ethutil.BigD(vexp), ethutil.BigD(v))
+ t.Errorf("%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))
}
}
}
if !isVmTest {
statedb.Sync()
- if !bytes.Equal(ethutil.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
+ if !bytes.Equal(common.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
t.Errorf("%s's : Post state root error. Expected %s, got %x", name, test.PostStateRoot, statedb.Root())
}
}
@@ -170,8 +170,8 @@ func RunVmTest(p string, t *testing.T) {
fmt.Println("A", test.Logs)
fmt.Println("B", logs)
for i, log := range test.Logs {
- genBloom := ethutil.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
- if !bytes.Equal(genBloom, ethutil.Hex2Bytes(log.BloomF)) {
+ genBloom := common.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
+ if !bytes.Equal(genBloom, common.Hex2Bytes(log.BloomF)) {
t.Errorf("bloom mismatch")
}
}