diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-05-30 05:31:37 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-05-30 05:31:37 +0800 |
commit | 280609c99bc4daeed179aab75e9ee4c5721b2a9e (patch) | |
tree | 909cf4b6433c37e33a5564e15861ad632bf3b9f5 /core/tx_pool_test.go | |
parent | dd06c8584368316c8fb388384b0723d8c7e543f0 (diff) | |
download | go-tangerine-280609c99bc4daeed179aab75e9ee4c5721b2a9e.tar.gz go-tangerine-280609c99bc4daeed179aab75e9ee4c5721b2a9e.tar.zst go-tangerine-280609c99bc4daeed179aab75e9ee4c5721b2a9e.zip |
core: check for gas limit exceeding txs too on new block
Diffstat (limited to 'core/tx_pool_test.go')
-rw-r--r-- | core/tx_pool_test.go | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 63e0144bd..c12bd20a1 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -397,50 +397,79 @@ func TestTransactionDropping(t *testing.T) { var ( tx0 = transaction(0, big.NewInt(100), key) tx1 = transaction(1, big.NewInt(200), key) + tx2 = transaction(2, big.NewInt(300), key) tx10 = transaction(10, big.NewInt(100), key) tx11 = transaction(11, big.NewInt(200), key) + tx12 = transaction(12, big.NewInt(300), key) ) pool.promoteTx(account, tx0.Hash(), tx0) pool.promoteTx(account, tx1.Hash(), tx1) + pool.promoteTx(account, tx1.Hash(), tx2) pool.enqueueTx(tx10.Hash(), tx10) pool.enqueueTx(tx11.Hash(), tx11) + pool.enqueueTx(tx11.Hash(), tx12) // Check that pre and post validations leave the pool as is - if pool.pending[account].Len() != 2 { - t.Errorf("pending transaction mismatch: have %d, want %d", pool.pending[account].Len(), 2) + if pool.pending[account].Len() != 3 { + t.Errorf("pending transaction mismatch: have %d, want %d", pool.pending[account].Len(), 3) } - if pool.queue[account].Len() != 2 { - t.Errorf("queued transaction mismatch: have %d, want %d", pool.queue[account].Len(), 2) + if pool.queue[account].Len() != 3 { + t.Errorf("queued transaction mismatch: have %d, want %d", pool.queue[account].Len(), 3) } if len(pool.all) != 4 { t.Errorf("total transaction mismatch: have %d, want %d", len(pool.all), 4) } pool.resetState() - if pool.pending[account].Len() != 2 { - t.Errorf("pending transaction mismatch: have %d, want %d", pool.pending[account].Len(), 2) + if pool.pending[account].Len() != 3 { + t.Errorf("pending transaction mismatch: have %d, want %d", pool.pending[account].Len(), 3) } - if pool.queue[account].Len() != 2 { - t.Errorf("queued transaction mismatch: have %d, want %d", pool.queue[account].Len(), 2) + if pool.queue[account].Len() != 3 { + t.Errorf("queued transaction mismatch: have %d, want %d", pool.queue[account].Len(), 3) } if len(pool.all) != 4 { t.Errorf("total transaction mismatch: have %d, want %d", len(pool.all), 4) } // Reduce the balance of the account, and check that invalidated transactions are dropped - state.AddBalance(account, big.NewInt(-750)) + state.AddBalance(account, big.NewInt(-650)) pool.resetState() if _, ok := pool.pending[account].txs.items[tx0.Nonce()]; !ok { t.Errorf("funded pending transaction missing: %v", tx0) } - if _, ok := pool.pending[account].txs.items[tx1.Nonce()]; ok { + if _, ok := pool.pending[account].txs.items[tx1.Nonce()]; !ok { + t.Errorf("funded pending transaction missing: %v", tx0) + } + if _, ok := pool.pending[account].txs.items[tx2.Nonce()]; ok { t.Errorf("out-of-fund pending transaction present: %v", tx1) } if _, ok := pool.queue[account].txs.items[tx10.Nonce()]; !ok { t.Errorf("funded queued transaction missing: %v", tx10) } - if _, ok := pool.queue[account].txs.items[tx11.Nonce()]; ok { + if _, ok := pool.queue[account].txs.items[tx11.Nonce()]; !ok { + t.Errorf("funded queued transaction missing: %v", tx10) + } + if _, ok := pool.queue[account].txs.items[tx12.Nonce()]; ok { t.Errorf("out-of-fund queued transaction present: %v", tx11) } + if len(pool.all) != 4 { + t.Errorf("total transaction mismatch: have %d, want %d", len(pool.all), 4) + } + // Reduce the block gas limit, check that invalidated transactions are dropped + pool.gasLimit = func() *big.Int { return big.NewInt(100) } + pool.resetState() + + if _, ok := pool.pending[account].txs.items[tx0.Nonce()]; !ok { + t.Errorf("funded pending transaction missing: %v", tx0) + } + if _, ok := pool.pending[account].txs.items[tx1.Nonce()]; ok { + t.Errorf("over-gased pending transaction present: %v", tx1) + } + if _, ok := pool.queue[account].txs.items[tx10.Nonce()]; !ok { + t.Errorf("funded queued transaction missing: %v", tx10) + } + if _, ok := pool.queue[account].txs.items[tx11.Nonce()]; ok { + t.Errorf("over-gased queued transaction present: %v", tx11) + } if len(pool.all) != 2 { t.Errorf("total transaction mismatch: have %d, want %d", len(pool.all), 2) } |