@@ -37,21 +37,21 @@ func TestInvalidTransactions(t *testing.T) {
3737 }
3838
3939 from , _ := tx .From ()
40- pool .state .AddBalance (from , big .NewInt (1 ))
40+ pool .currentState () .AddBalance (from , big .NewInt (1 ))
4141 err = pool .Add (tx )
4242 if err != ErrInsufficientFunds {
4343 t .Error ("expected" , ErrInsufficientFunds )
4444 }
4545
4646 balance := new (big.Int ).Add (tx .Value (), new (big.Int ).Mul (tx .Gas (), tx .GasPrice ()))
47- pool .state .AddBalance (from , balance )
47+ pool .currentState () .AddBalance (from , balance )
4848 err = pool .Add (tx )
4949 if err != ErrIntrinsicGas {
5050 t .Error ("expected" , ErrIntrinsicGas , "got" , err )
5151 }
5252
53- pool .state .SetNonce (from , 1 )
54- pool .state .AddBalance (from , big .NewInt (0xffffffffffffff ))
53+ pool .currentState () .SetNonce (from , 1 )
54+ pool .currentState () .AddBalance (from , big .NewInt (0xffffffffffffff ))
5555 tx .GasLimit = big .NewInt (100000 )
5656 tx .Price = big .NewInt (1 )
5757 tx .SignECDSA (key )
@@ -67,7 +67,7 @@ func TestTransactionQueue(t *testing.T) {
6767 tx := transaction ()
6868 tx .SignECDSA (key )
6969 from , _ := tx .From ()
70- pool .state .AddBalance (from , big .NewInt (1 ))
70+ pool .currentState () .AddBalance (from , big .NewInt (1 ))
7171 pool .queueTx (tx .Hash (), tx )
7272
7373 pool .checkQueue ()
@@ -79,7 +79,7 @@ func TestTransactionQueue(t *testing.T) {
7979 tx .SetNonce (1 )
8080 tx .SignECDSA (key )
8181 from , _ = tx .From ()
82- pool .state .SetNonce (from , 2 )
82+ pool .currentState () .SetNonce (from , 2 )
8383 pool .queueTx (tx .Hash (), tx )
8484 pool .checkQueue ()
8585 if _ , ok := pool .pending [tx .Hash ()]; ok {
@@ -117,7 +117,7 @@ func TestRemoveTx(t *testing.T) {
117117 tx := transaction ()
118118 tx .SignECDSA (key )
119119 from , _ := tx .From ()
120- pool .state .AddBalance (from , big .NewInt (1 ))
120+ pool .currentState () .AddBalance (from , big .NewInt (1 ))
121121 pool .queueTx (tx .Hash (), tx )
122122 pool .addTx (tx .Hash (), from , tx )
123123 if len (pool .queue ) != 1 {
@@ -146,7 +146,7 @@ func TestNegativeValue(t *testing.T) {
146146 tx .Value ().Set (big .NewInt (- 1 ))
147147 tx .SignECDSA (key )
148148 from , _ := tx .From ()
149- pool .state .AddBalance (from , big .NewInt (1 ))
149+ pool .currentState () .AddBalance (from , big .NewInt (1 ))
150150 err := pool .Add (tx )
151151 if err != ErrNegativeValue {
152152 t .Error ("expected" , ErrNegativeValue , "got" , err )
@@ -156,7 +156,15 @@ func TestNegativeValue(t *testing.T) {
156156func TestTransactionChainFork (t * testing.T ) {
157157 pool , key := setupTxPool ()
158158 addr := crypto .PubkeyToAddress (key .PublicKey )
159- pool .currentState ().AddBalance (addr , big .NewInt (100000000000000 ))
159+ resetState := func () {
160+ db , _ := ethdb .NewMemDatabase ()
161+ statedb := state .New (common.Hash {}, db )
162+ pool .currentState = func () * state.StateDB { return statedb }
163+ pool .currentState ().AddBalance (addr , big .NewInt (100000000000000 ))
164+ pool .resetState ()
165+ }
166+ resetState ()
167+
160168 tx := transaction ()
161169 tx .GasLimit = big .NewInt (100000 )
162170 tx .SignECDSA (key )
@@ -168,7 +176,7 @@ func TestTransactionChainFork(t *testing.T) {
168176 pool .RemoveTransactions ([]* types.Transaction {tx })
169177
170178 // reset the pool's internal state
171- pool . resetState ()
179+ resetState ()
172180 err = pool .add (tx )
173181 if err != nil {
174182 t .Error ("didn't expect error" , err )
@@ -178,7 +186,15 @@ func TestTransactionChainFork(t *testing.T) {
178186func TestTransactionDoubleNonce (t * testing.T ) {
179187 pool , key := setupTxPool ()
180188 addr := crypto .PubkeyToAddress (key .PublicKey )
181- pool .currentState ().AddBalance (addr , big .NewInt (100000000000000 ))
189+ resetState := func () {
190+ db , _ := ethdb .NewMemDatabase ()
191+ statedb := state .New (common.Hash {}, db )
192+ pool .currentState = func () * state.StateDB { return statedb }
193+ pool .currentState ().AddBalance (addr , big .NewInt (100000000000000 ))
194+ pool .resetState ()
195+ }
196+ resetState ()
197+
182198 tx := transaction ()
183199 tx .GasLimit = big .NewInt (100000 )
184200 tx .SignECDSA (key )
0 commit comments