@@ -108,6 +108,19 @@ func (env *testEnv) makeTx(nonce uint64, gasPrice *big.Int) *types.Transaction {
108
108
return tx
109
109
}
110
110
111
+ func (env * testEnv ) makeTxs (n int ) []* types.Transaction {
112
+ head := env .chain .CurrentHeader ()
113
+ state , _ := env .chain .StateAt (head .Root )
114
+ nonce := state .GetNonce (address )
115
+
116
+ var txs []* types.Transaction
117
+ for i := 0 ; i < n ; i ++ {
118
+ tx , _ := types .SignTx (types .NewTransaction (nonce + uint64 (i ), common.Address {0x00 }, big .NewInt (1000 ), params .TxGas , big .NewInt (params .GWei ), nil ), signer , key )
119
+ txs = append (txs , tx )
120
+ }
121
+ return txs
122
+ }
123
+
111
124
func (env * testEnv ) commit () {
112
125
head := env .chain .CurrentBlock ()
113
126
block := env .chain .GetBlock (head .Hash (), head .Number .Uint64 ())
@@ -177,3 +190,29 @@ func TestRejectInvalids(t *testing.T) {
177
190
}
178
191
}
179
192
}
193
+
194
+ func TestResubmit (t * testing.T ) {
195
+ env := newTestEnv (t , 10 , 0 , "" )
196
+ defer env .close ()
197
+
198
+ txs := env .makeTxs (10 )
199
+ txsA := txs [:len (txs )/ 2 ]
200
+ txsB := txs [len (txs )/ 2 :]
201
+ env .pool .Add (txsA , true )
202
+ pending , queued := env .pool .ContentFrom (address )
203
+ if len (pending ) != len (txsA ) || len (queued ) != 0 {
204
+ t .Fatalf ("Unexpected txpool content: %d, %d" , len (pending ), len (queued ))
205
+ }
206
+ env .tracker .TrackAll (txs )
207
+
208
+ resubmit , all := env .tracker .recheck (true )
209
+ if len (resubmit ) != len (txsB ) {
210
+ t .Fatalf ("Unexpected transactions to resubmit, got: %d, want: %d" , len (resubmit ), len (txsB ))
211
+ }
212
+ if len (all ) == 0 || len (all [address ]) == 0 {
213
+ t .Fatalf ("Unexpected transactions being tracked, got: %d, want: %d" , 0 , len (txs ))
214
+ }
215
+ if len (all [address ]) != len (txs ) {
216
+ t .Fatalf ("Unexpected transactions being tracked, got: %d, want: %d" , len (all [address ]), len (txs ))
217
+ }
218
+ }
0 commit comments