diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-07 16:32:05 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-07 16:32:05 +0800 |
commit | 35cd355c14d9a5266a7d4b11127d25eb7f961494 (patch) | |
tree | 879c8d86b8865f733c73992e8c04c71d52152437 /tests/state_test_util.go | |
parent | d764bd058457cd9eb91d205d1ac187d40c4866d6 (diff) | |
download | go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.gz go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.zst go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.zip |
cmd,eth,rpc,tests: default coinbase
Diffstat (limited to 'tests/state_test_util.go')
-rw-r--r-- | tests/state_test_util.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 7f1a22ac0..dbbd08729 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -2,6 +2,7 @@ package tests import ( "bytes" + "encoding/hex" "fmt" "io" "math/big" @@ -147,13 +148,12 @@ func runStateTest(test VmTest) error { 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 = common.FromHex(tx["data"]) - gas = common.Big(tx["gasLimit"]) - price = common.Big(tx["gasPrice"]) - value = common.Big(tx["value"]) - nonce = common.Big(tx["nonce"]).Uint64() - caddr = common.HexToAddress(env["currentCoinbase"]) + data = common.FromHex(tx["data"]) + gas = common.Big(tx["gasLimit"]) + price = common.Big(tx["gasPrice"]) + value = common.Big(tx["value"]) + nonce = common.Big(tx["nonce"]).Uint64() + caddr = common.HexToAddress(env["currentCoinbase"]) ) var to *common.Address @@ -168,9 +168,11 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state. coinbase := statedb.GetOrNewStateObject(caddr) coinbase.SetGasLimit(common.Big(env["currentGasLimit"])) - message := NewMessage(common.BytesToAddress(keyPair.Address()), to, data, value, gas, price, nonce) + key, _ := hex.DecodeString(tx["secretKey"]) + addr := crypto.PubkeyToAddress(crypto.ToECDSA(key).PublicKey) + message := NewMessage(addr, to, data, value, gas, price, nonce) vmenv := NewEnvFromMap(statedb, env, tx) - vmenv.origin = common.BytesToAddress(keyPair.Address()) + vmenv.origin = addr ret, _, err := core.ApplyMessage(vmenv, message, coinbase) if core.IsNonceErr(err) || core.IsInvalidTxErr(err) || state.IsGasLimitErr(err) { statedb.Set(snapshot) |