diff options
author | Felix Lange <fjl@twurst.com> | 2016-11-14 17:52:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 17:52:02 +0800 |
commit | ca73dea3b9bcdf3b5424b5c48c70817439e2e304 (patch) | |
tree | 670e2833878e72555644fbbd81db6c5a1b44493f /les/odr_test.go | |
parent | 21701190ac0a838e347f31b7a918bb0a60c1e8c1 (diff) | |
parent | 648bd22427000b6e20a5e1a9c397005aa1ad4f9b (diff) | |
download | dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.gz dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.bz2 dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.lz dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.xz dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.zst dexon-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.zip |
Merge pull request #3179 from obscuren/eip-158
EIP158 & 160 Hardfork
Diffstat (limited to 'les/odr_test.go')
-rw-r--r-- | les/odr_test.go | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/les/odr_test.go b/les/odr_test.go index 3c8ea8c3f..f1fa59ad8 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -26,17 +26,19 @@ import ( "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/ethdb" "github.com/ethereum/go-ethereum/light" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "golang.org/x/net/context" ) -type odrTestFn func(ctx context.Context, db ethdb.Database, config *core.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte +type odrTestFn func(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte func TestOdrGetBlockLes1(t *testing.T) { testOdr(t, 1, 1, odrGetBlock) } -func odrGetBlock(ctx context.Context, db ethdb.Database, config *core.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrGetBlock(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { var block *types.Block if bc != nil { block = bc.GetBlockByHash(bhash) @@ -52,7 +54,7 @@ func odrGetBlock(ctx context.Context, db ethdb.Database, config *core.ChainConfi func TestOdrGetReceiptsLes1(t *testing.T) { testOdr(t, 1, 1, odrGetReceipts) } -func odrGetReceipts(ctx context.Context, db ethdb.Database, config *core.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrGetReceipts(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { var receipts types.Receipts if bc != nil { receipts = core.GetBlockReceipts(db, bhash, core.GetBlockNumber(db, bhash)) @@ -68,7 +70,7 @@ func odrGetReceipts(ctx context.Context, db ethdb.Database, config *core.ChainCo func TestOdrAccountsLes1(t *testing.T) { testOdr(t, 1, 1, odrAccounts) } -func odrAccounts(ctx context.Context, db ethdb.Database, config *core.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrAccounts(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { dummyAddr := common.HexToAddress("1234567812345678123456781234567812345678") acc := []common.Address{testBankAddress, acc1Addr, acc2Addr, dummyAddr} @@ -98,47 +100,13 @@ func odrAccounts(ctx context.Context, db ethdb.Database, config *core.ChainConfi func TestOdrContractCallLes1(t *testing.T) { testOdr(t, 1, 2, odrContractCall) } -// fullcallmsg is the message type used for call transations. -type fullcallmsg struct { - from *state.StateObject - to *common.Address - gas, gasPrice *big.Int - value *big.Int - data []byte +type callmsg struct { + types.Message } -// accessor boilerplate to implement core.Message -func (m fullcallmsg) From() (common.Address, error) { return m.from.Address(), nil } -func (m fullcallmsg) FromFrontier() (common.Address, error) { return m.from.Address(), nil } -func (m fullcallmsg) Nonce() uint64 { return 0 } -func (m fullcallmsg) CheckNonce() bool { return false } -func (m fullcallmsg) To() *common.Address { return m.to } -func (m fullcallmsg) GasPrice() *big.Int { return m.gasPrice } -func (m fullcallmsg) Gas() *big.Int { return m.gas } -func (m fullcallmsg) Value() *big.Int { return m.value } -func (m fullcallmsg) Data() []byte { return m.data } - -// callmsg is the message type used for call transations. -type lightcallmsg struct { - from *light.StateObject - to *common.Address - gas, gasPrice *big.Int - value *big.Int - data []byte -} +func (callmsg) CheckNonce() bool { return false } -// accessor boilerplate to implement core.Message -func (m lightcallmsg) From() (common.Address, error) { return m.from.Address(), nil } -func (m lightcallmsg) FromFrontier() (common.Address, error) { return m.from.Address(), nil } -func (m lightcallmsg) Nonce() uint64 { return 0 } -func (m lightcallmsg) CheckNonce() bool { return false } -func (m lightcallmsg) To() *common.Address { return m.to } -func (m lightcallmsg) GasPrice() *big.Int { return m.gasPrice } -func (m lightcallmsg) Gas() *big.Int { return m.gas } -func (m lightcallmsg) Value() *big.Int { return m.value } -func (m lightcallmsg) Data() []byte { return m.data } - -func odrContractCall(ctx context.Context, db ethdb.Database, config *core.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrContractCall(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { data := common.Hex2Bytes("60CD26850000000000000000000000000000000000000000000000000000000000000000") var res []byte @@ -151,16 +119,8 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *core.ChainC from := statedb.GetOrNewStateObject(testBankAddress) from.SetBalance(common.MaxBig) - msg := fullcallmsg{ - from: from, - gas: big.NewInt(100000), - gasPrice: big.NewInt(0), - value: big.NewInt(0), - data: data, - to: &testContractAddr, - } - - vmenv := core.NewEnv(statedb, config, bc, msg, header, config.VmConfig) + msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), big.NewInt(100000), new(big.Int), data)} + vmenv := core.NewEnv(statedb, config, bc, msg, header, vm.Config{}) gp := new(core.GasPool).AddGas(common.MaxBig) ret, _, _ := core.ApplyMessage(vmenv, msg, gp) res = append(res, ret...) @@ -172,16 +132,9 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *core.ChainC if err == nil { from.SetBalance(common.MaxBig) - msg := lightcallmsg{ - from: from, - gas: big.NewInt(100000), - gasPrice: big.NewInt(0), - value: big.NewInt(0), - data: data, - to: &testContractAddr, - } + msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), big.NewInt(100000), new(big.Int), data)} - vmenv := light.NewEnv(ctx, state, config, lc, msg, header, config.VmConfig) + vmenv := light.NewEnv(ctx, state, config, lc, msg, header, vm.Config{}) gp := new(core.GasPool).AddGas(common.MaxBig) ret, _, _ := core.ApplyMessage(vmenv, msg, gp) if vmenv.Error() == nil { |