diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-11 01:00:54 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-19 04:15:07 +0800 |
commit | 1b26d4f220689dac18d560a4c1ecb3b29d99deb0 (patch) | |
tree | 66bed6c2091770fc58476299691204bb30efb7a5 /tests | |
parent | e82100367f794856a8807b5fcfe9f0043902a294 (diff) | |
download | dexon-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.gz dexon-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.zst dexon-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.zip |
Flatten helper directory
Diffstat (limited to 'tests')
-rw-r--r-- | tests/helper/common.go | 11 | ||||
-rw-r--r-- | tests/helper/init.go | 16 | ||||
-rw-r--r-- | tests/helper/trie.go | 31 | ||||
-rw-r--r-- | tests/init.go (renamed from tests/helper/readers.go) | 13 | ||||
-rw-r--r-- | tests/vm.go (renamed from tests/helper/vm.go) | 6 | ||||
-rw-r--r-- | tests/vm_test_util.go | 15 |
6 files changed, 22 insertions, 70 deletions
diff --git a/tests/helper/common.go b/tests/helper/common.go deleted file mode 100644 index 21ea2261f..000000000 --- a/tests/helper/common.go +++ /dev/null @@ -1,11 +0,0 @@ -package helper - -import "github.com/ethereum/go-ethereum/common" - -func FromHex(h string) []byte { - if common.IsHex(h) { - h = h[2:] - } - - return common.Hex2Bytes(h) -} diff --git a/tests/helper/init.go b/tests/helper/init.go deleted file mode 100644 index 73d563e02..000000000 --- a/tests/helper/init.go +++ /dev/null @@ -1,16 +0,0 @@ -package helper - -import ( - "log" - "os" - - logpkg "github.com/ethereum/go-ethereum/logger" -) - -var Logger *logpkg.StdLogSystem -var Log = logpkg.NewLogger("TEST") - -func init() { - Logger = logpkg.NewStdLogSystem(os.Stdout, log.LstdFlags, logpkg.InfoLevel) - logpkg.AddLogSystem(Logger) -} diff --git a/tests/helper/trie.go b/tests/helper/trie.go deleted file mode 100644 index 9e666d333..000000000 --- a/tests/helper/trie.go +++ /dev/null @@ -1,31 +0,0 @@ -package helper - -import "github.com/ethereum/go-ethereum/trie" - -type MemDatabase struct { - db map[string][]byte -} - -func NewMemDatabase() (*MemDatabase, error) { - db := &MemDatabase{db: make(map[string][]byte)} - return db, nil -} -func (db *MemDatabase) Put(key []byte, value []byte) { - db.db[string(key)] = value -} -func (db *MemDatabase) Get(key []byte) ([]byte, error) { - return db.db[string(key)], nil -} -func (db *MemDatabase) Delete(key []byte) error { - delete(db.db, string(key)) - return nil -} -func (db *MemDatabase) Print() {} -func (db *MemDatabase) Close() {} -func (db *MemDatabase) LastKnownTD() []byte { return nil } - -func NewTrie() *trie.Trie { - db, _ := NewMemDatabase() - - return trie.New(nil, db) -} diff --git a/tests/helper/readers.go b/tests/init.go index 03313aeda..b487f81c3 100644 --- a/tests/helper/readers.go +++ b/tests/init.go @@ -1,14 +1,25 @@ -package helper +package tests import ( "encoding/json" "io" "io/ioutil" + // "log" "net/http" "os" "testing" + + // logpkg "github.com/ethereum/go-ethereum/logger" ) +// var Logger *logpkg.StdLogSystem +// var Log = logpkg.NewLogger("TEST") + +// func init() { +// Logger = logpkg.NewStdLogSystem(os.Stdout, log.LstdFlags, logpkg.InfoLevel) +// logpkg.AddLogSystem(Logger) +// } + func readJSON(t *testing.T, reader io.Reader, value interface{}) { data, err := ioutil.ReadAll(reader) err = json.Unmarshal(data, &value) diff --git a/tests/helper/vm.go b/tests/vm.go index e29a2d8ee..52e498ccc 100644 --- a/tests/helper/vm.go +++ b/tests/vm.go @@ -1,4 +1,4 @@ -package helper +package tests import ( "errors" @@ -144,7 +144,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log var ( to = common.HexToAddress(exec["address"]) from = common.HexToAddress(exec["caller"]) - data = FromHex(exec["data"]) + data = common.FromHex(exec["data"]) gas = common.Big(exec["gas"]) price = common.Big(exec["gasPrice"]) value = common.Big(exec["value"]) @@ -166,7 +166,7 @@ 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(common.Hex2Bytes(tx["secretKey"]))) - data = FromHex(tx["data"]) + data = common.FromHex(tx["data"]) gas = common.Big(tx["gasLimit"]) price = common.Big(tx["gasPrice"]) value = common.Big(tx["value"]) diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index f91070736..cf95db80f 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -11,7 +11,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/tests/helper" ) type Account struct { @@ -52,7 +51,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s return obj } -type Env struct { +type VmEnv struct { CurrentCoinbase string CurrentDifficulty string CurrentGasLimit string @@ -64,7 +63,7 @@ type Env struct { type VmTest struct { Callcreates interface{} //Env map[string]string - Env Env + Env VmEnv Exec map[string]string Transaction map[string]string Logs []Log @@ -78,7 +77,7 @@ type VmTest struct { func RunVmTest(p string, t *testing.T) { tests := make(map[string]VmTest) - helper.CreateFileTests(t, p, &tests) + CreateFileTests(t, p, &tests) for name, test := range tests { /* @@ -121,9 +120,9 @@ func RunVmTest(p string, t *testing.T) { isVmTest := len(test.Exec) > 0 if isVmTest { - ret, logs, gas, err = helper.RunVm(statedb, env, test.Exec) + ret, logs, gas, err = RunVm(statedb, env, test.Exec) } else { - ret, logs, gas, err = helper.RunState(statedb, env, test.Transaction) + ret, logs, gas, err = RunState(statedb, env, test.Transaction) } switch name { @@ -131,7 +130,7 @@ func RunVmTest(p string, t *testing.T) { // on 19 May 2015 decided to skip these tests their output. case "mload32bitBound_return", "mload32bitBound_return2": default: - rexp := helper.FromHex(test.Out) + rexp := common.FromHex(test.Out) if bytes.Compare(rexp, ret) != 0 { t.Errorf("%s's return failed. Expected %x, got %x\n", name, rexp, ret) } @@ -192,7 +191,7 @@ func RunVmTest(p string, t *testing.T) { 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, common.FromHex(log.DataF)) { t.Errorf("'%s' log data expected %v got %x", name, log.DataF, logs[i].Data) } |