@@ -31,11 +31,12 @@ import (
3131 "github.com/ethereum/go-ethereum/core/vm"
3232 "github.com/ethereum/go-ethereum/ethdb"
3333 "github.com/ethereum/go-ethereum/event"
34+ "github.com/ethereum/go-ethereum/params"
3435 "golang.org/x/net/context"
3536)
3637
3738// Default chain configuration which sets homestead phase at block 0 (i.e. no frontier)
38- var chainConfig = & core .ChainConfig {HomesteadBlock : big .NewInt (0 )}
39+ var chainConfig = & params .ChainConfig {HomesteadBlock : big .NewInt (0 ), EIP150Block : new (big. Int ), EIP158Block : new (big. Int )}
3940
4041// This nil assignment ensures compile time that SimulatedBackend implements bind.ContractBackend.
4142var _ bind.ContractBackend = (* SimulatedBackend )(nil )
@@ -51,6 +52,8 @@ type SimulatedBackend struct {
5152 mu sync.Mutex
5253 pendingBlock * types.Block // Currently pending block that will be imported on request
5354 pendingState * state.StateDB // Currently pending state that will be the active on on request
55+
56+ config * params.ChainConfig
5457}
5558
5659// NewSimulatedBackend creates a new binding backend using a simulated blockchain
@@ -85,7 +88,7 @@ func (b *SimulatedBackend) Rollback() {
8588}
8689
8790func (b * SimulatedBackend ) rollback () {
88- blocks , _ := core .GenerateChain (nil , b .blockchain .CurrentBlock (), b .database , 1 , func (int , * core.BlockGen ) {})
91+ blocks , _ := core .GenerateChain (chainConfig , b .blockchain .CurrentBlock (), b .database , 1 , func (int , * core.BlockGen ) {})
8992 b .pendingBlock = blocks [0 ]
9093 b .pendingState , _ = state .New (b .pendingBlock .Root (), b .database )
9194}
@@ -234,7 +237,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
234237 b .mu .Lock ()
235238 defer b .mu .Unlock ()
236239
237- sender , err := tx . From ( )
240+ sender , err := types . Sender (types. HomesteadSigner {}, tx )
238241 if err != nil {
239242 panic (fmt .Errorf ("invalid transaction: %v" , err ))
240243 }
@@ -243,7 +246,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
243246 panic (fmt .Errorf ("invalid transaction nonce: got %d, want %d" , tx .Nonce (), nonce ))
244247 }
245248
246- blocks , _ := core .GenerateChain (nil , b .blockchain .CurrentBlock (), b .database , 1 , func (number int , block * core.BlockGen ) {
249+ blocks , _ := core .GenerateChain (chainConfig , b .blockchain .CurrentBlock (), b .database , 1 , func (number int , block * core.BlockGen ) {
247250 for _ , tx := range b .pendingBlock .Transactions () {
248251 block .AddTx (tx )
249252 }
@@ -259,12 +262,11 @@ type callmsg struct {
259262 ethereum.CallMsg
260263}
261264
262- func (m callmsg ) From () (common.Address , error ) { return m .CallMsg .From , nil }
263- func (m callmsg ) FromFrontier () (common.Address , error ) { return m .CallMsg .From , nil }
264- func (m callmsg ) Nonce () uint64 { return 0 }
265- func (m callmsg ) CheckNonce () bool { return false }
266- func (m callmsg ) To () * common.Address { return m .CallMsg .To }
267- func (m callmsg ) GasPrice () * big.Int { return m .CallMsg .GasPrice }
268- func (m callmsg ) Gas () * big.Int { return m .CallMsg .Gas }
269- func (m callmsg ) Value () * big.Int { return m .CallMsg .Value }
270- func (m callmsg ) Data () []byte { return m .CallMsg .Data }
265+ func (m callmsg ) From () common.Address { return m .CallMsg .From }
266+ func (m callmsg ) Nonce () uint64 { return 0 }
267+ func (m callmsg ) CheckNonce () bool { return false }
268+ func (m callmsg ) To () * common.Address { return m .CallMsg .To }
269+ func (m callmsg ) GasPrice () * big.Int { return m .CallMsg .GasPrice }
270+ func (m callmsg ) Gas () * big.Int { return m .CallMsg .Gas }
271+ func (m callmsg ) Value () * big.Int { return m .CallMsg .Value }
272+ func (m callmsg ) Data () []byte { return m .CallMsg .Data }
0 commit comments