diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-07 17:55:33 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-07 17:55:33 +0800 |
commit | e5fba8fd7025bb45a88a19c1bbef80db5bd3b688 (patch) | |
tree | b17726c936fcb695e26b2a145b5d423b8556871b /tests/state_test_util.go | |
parent | 916d1554675974adb92af4046e1b04ad3b26dca3 (diff) | |
parent | 37c1a8f69de44827a60296342189b6719a49dbc3 (diff) | |
download | dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.gz dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.bz2 dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.lz dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.xz dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.zst dexon-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.zip |
Merge pull request #1428 from obscuren/coinbase-fixes
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) |