aboutsummaryrefslogtreecommitdiffstats
path: root/core/transaction_pool_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-09 06:41:47 +0800
committerobscuren <geffobscura@gmail.com>2015-06-09 06:41:47 +0800
commit5245bd7b20192071cac5477168dc6735abd35c6c (patch)
tree0ff9da730feb4bfcb7f450ded29922bea39a2331 /core/transaction_pool_test.go
parent55b7c14554bc4faabc14aac6410b75f97c55cd4e (diff)
downloaddexon-5245bd7b20192071cac5477168dc6735abd35c6c.tar.gz
dexon-5245bd7b20192071cac5477168dc6735abd35c6c.tar.zst
dexon-5245bd7b20192071cac5477168dc6735abd35c6c.zip
core: added a test for missing nonces
This test showed the logic in the queue was slightly flawed sending out transactions to its peer it couldn't even resolve itself.
Diffstat (limited to 'core/transaction_pool_test.go')
-rw-r--r--core/transaction_pool_test.go23
1 files changed, 23 insertions, 0 deletions
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]))
+ }
+}