diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-09 07:04:30 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-09 07:04:30 +0800 |
commit | 81ceac1b96bdd61b9f2f80359607e451061fc02f (patch) | |
tree | 0ff9da730feb4bfcb7f450ded29922bea39a2331 /core | |
parent | 55b7c14554bc4faabc14aac6410b75f97c55cd4e (diff) | |
parent | 5245bd7b20192071cac5477168dc6735abd35c6c (diff) | |
download | dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.tar dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.tar.gz dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.tar.bz2 dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.tar.lz dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.tar.xz dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.tar.zst dexon-81ceac1b96bdd61b9f2f80359607e451061fc02f.zip |
Merge pull request #1209 from obscuren/txpool_test_and_pending_fix
core: added a test for missing nonces
Diffstat (limited to 'core')
-rw-r--r-- | core/transaction_pool.go | 2 | ||||
-rw-r--r-- | core/transaction_pool_test.go | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 27dc1b0d1..77744f8f7 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -331,7 +331,7 @@ func (pool *TxPool) checkQueue() { // current account nonce. sort.Sort(addq) for _, e := range addq { - if e.AccountNonce > curnonce+1 { + if e.AccountNonce > curnonce { break } delete(txs, e.hash) diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index ac297d266..b8bf78f00 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -201,3 +201,26 @@ func TestTransactionDoubleNonce(t *testing.T) { 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])) + } +} |