diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-11-02 20:44:13 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-11-13 21:55:30 +0800 |
commit | 4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188 (patch) | |
tree | 5c55a3088c944ddf517aa4d7c85c5dc7f02d00e4 /tests | |
parent | 5cd86443ee071b5e3abe4995c777ce467c29f2c5 (diff) | |
download | dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.gz dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.bz2 dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.lz dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.xz dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.zst dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.zip |
core/types, params: EIP#155
Diffstat (limited to 'tests')
-rw-r--r-- | tests/state_test_util.go | 3 | ||||
-rw-r--r-- | tests/transaction_test_util.go | 13 | ||||
-rw-r--r-- | tests/util.go | 23 | ||||
-rw-r--r-- | tests/vm_test_util.go | 7 |
4 files changed, 12 insertions, 34 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index c8899392a..c08398321 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" @@ -225,7 +226,7 @@ func RunState(chainConfig *params.ChainConfig, statedb *state.StateDB, env, tx m key, _ := hex.DecodeString(tx["secretKey"]) addr := crypto.PubkeyToAddress(crypto.ToECDSA(key).PublicKey) - message := NewMessage(addr, to, data, value, gas, price, nonce) + message := types.NewMessage(addr, to, nonce, value, gas, price, data) vmenv := NewEnvFromMap(chainConfig, statedb, env, tx) vmenv.origin = addr diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index be3514737..184bdee2a 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -159,16 +159,11 @@ func verifyTxFields(txTest TransactionTest, decodedTx *types.Transaction) (err e } }() - var ( - decodedSender common.Address - ) + var decodedSender common.Address chainConfig := ¶ms.ChainConfig{HomesteadBlock: params.MainNetHomesteadBlock} - if chainConfig.IsHomestead(common.String2Big(txTest.Blocknumber)) { - decodedSender, err = decodedTx.From() - } else { - decodedSender, err = decodedTx.FromFrontier() - } + signer := types.MakeSigner(chainConfig, common.String2Big(txTest.Blocknumber)) + decodedSender, err = types.Sender(signer, decodedTx) if err != nil { return err } @@ -198,7 +193,7 @@ func verifyTxFields(txTest TransactionTest, decodedTx *types.Transaction) (err e return fmt.Errorf("Nonce mismatch: %v %v", expectedNonce, decodedTx.Nonce()) } - v, r, s := decodedTx.SignatureValues() + v, r, s := types.SignatureValues(signer, decodedTx) expectedR := mustConvertBigInt(txTest.Transaction.R, 16) if r.Cmp(expectedR) != 0 { return fmt.Errorf("R mismatch: %v %v", expectedR, r) diff --git a/tests/util.go b/tests/util.go index 5296bb54b..53955a47f 100644 --- a/tests/util.go +++ b/tests/util.go @@ -282,26 +282,3 @@ func (self *Env) Create(caller vm.ContractRef, data []byte, gas, price, value *b return core.Create(self, caller, data, gas, price, value) } } - -type Message struct { - from common.Address - to *common.Address - value, gas, price *big.Int - data []byte - nonce uint64 -} - -func NewMessage(from common.Address, to *common.Address, data []byte, value, gas, price *big.Int, nonce uint64) Message { - return Message{from, to, value, gas, price, data, nonce} -} - -func (self Message) Hash() []byte { return nil } -func (self Message) From() (common.Address, error) { return self.from, nil } -func (self Message) FromFrontier() (common.Address, error) { return self.from, nil } -func (self Message) To() *common.Address { return self.to } -func (self Message) GasPrice() *big.Int { return self.price } -func (self Message) Gas() *big.Int { return self.gas } -func (self Message) Value() *big.Int { return self.value } -func (self Message) Nonce() uint64 { return self.nonce } -func (self Message) CheckNonce() bool { return true } -func (self Message) Data() []byte { return self.data } diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index f00af87b9..50660134b 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -225,7 +225,12 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, vm.Logs, caller := state.GetOrNewStateObject(from) - vmenv := NewEnvFromMap(¶ms.ChainConfig{params.MainNetHomesteadBlock, params.MainNetDAOForkBlock, true, nil, common.Hash{}, nil}, state, env, exec) + chainConfig := ¶ms.ChainConfig{ + HomesteadBlock: params.MainNetHomesteadBlock, + DAOForkBlock: params.MainNetDAOForkBlock, + DAOForkSupport: true, + } + vmenv := NewEnvFromMap(chainConfig, state, env, exec) vmenv.vmTest = true vmenv.skipTransfer = true vmenv.initial = true |