@@ -31,11 +31,12 @@ import (
31
31
"github.com/ethereum/go-ethereum/core/vm"
32
32
"github.com/ethereum/go-ethereum/ethdb"
33
33
"github.com/ethereum/go-ethereum/event"
34
+ "github.com/ethereum/go-ethereum/params"
34
35
"golang.org/x/net/context"
35
36
)
36
37
37
38
// 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 )}
39
40
40
41
// This nil assignment ensures compile time that SimulatedBackend implements bind.ContractBackend.
41
42
var _ bind.ContractBackend = (* SimulatedBackend )(nil )
@@ -51,6 +52,8 @@ type SimulatedBackend struct {
51
52
mu sync.Mutex
52
53
pendingBlock * types.Block // Currently pending block that will be imported on request
53
54
pendingState * state.StateDB // Currently pending state that will be the active on on request
55
+
56
+ config * params.ChainConfig
54
57
}
55
58
56
59
// NewSimulatedBackend creates a new binding backend using a simulated blockchain
@@ -85,7 +88,7 @@ func (b *SimulatedBackend) Rollback() {
85
88
}
86
89
87
90
func (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 ) {})
89
92
b .pendingBlock = blocks [0 ]
90
93
b .pendingState , _ = state .New (b .pendingBlock .Root (), b .database )
91
94
}
@@ -234,7 +237,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
234
237
b .mu .Lock ()
235
238
defer b .mu .Unlock ()
236
239
237
- sender , err := tx . From ( )
240
+ sender , err := types . Sender (types. HomesteadSigner {}, tx )
238
241
if err != nil {
239
242
panic (fmt .Errorf ("invalid transaction: %v" , err ))
240
243
}
@@ -243,7 +246,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
243
246
panic (fmt .Errorf ("invalid transaction nonce: got %d, want %d" , tx .Nonce (), nonce ))
244
247
}
245
248
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 ) {
247
250
for _ , tx := range b .pendingBlock .Transactions () {
248
251
block .AddTx (tx )
249
252
}
@@ -259,12 +262,11 @@ type callmsg struct {
259
262
ethereum.CallMsg
260
263
}
261
264
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