mirror of
https://github.com/status-im/op-geth.git
synced 2025-02-28 14:30:43 +00:00
Merge pull request #1209 from obscuren/txpool_test_and_pending_fix
core: added a test for missing nonces
This commit is contained in:
commit
81ceac1b96
@ -331,7 +331,7 @@ func (pool *TxPool) checkQueue() {
|
|||||||
// current account nonce.
|
// current account nonce.
|
||||||
sort.Sort(addq)
|
sort.Sort(addq)
|
||||||
for _, e := range addq {
|
for _, e := range addq {
|
||||||
if e.AccountNonce > curnonce+1 {
|
if e.AccountNonce > curnonce {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
delete(txs, e.hash)
|
delete(txs, e.hash)
|
||||||
|
@ -201,3 +201,26 @@ func TestTransactionDoubleNonce(t *testing.T) {
|
|||||||
t.Error("expected 2 pending txs. Got", len(pool.pending))
|
t.Error("expected 2 pending txs. Got", len(pool.pending))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMissingNonce(t *testing.T) {
|
||||||
|
pool, key := setupTxPool()
|
||||||
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
pool.currentState().AddBalance(addr, big.NewInt(100000000000000))
|
||||||
|
tx := transaction()
|
||||||
|
tx.AccountNonce = 1
|
||||||
|
tx.GasLimit = big.NewInt(100000)
|
||||||
|
tx.SignECDSA(key)
|
||||||
|
|
||||||
|
err := pool.add(tx)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("didn't expect error", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(pool.pending) != 0 {
|
||||||
|
t.Error("expected 0 pending transactions, got", len(pool.pending))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(pool.queue[addr]) != 1 {
|
||||||
|
t.Error("expected 1 queued transaction, got", len(pool.queue[addr]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user