@@ -397,50 +397,79 @@ func TestTransactionDropping(t *testing.T) {
397397 var (
398398 tx0 = transaction (0 , big .NewInt (100 ), key )
399399 tx1 = transaction (1 , big .NewInt (200 ), key )
400+ tx2 = transaction (2 , big .NewInt (300 ), key )
400401 tx10 = transaction (10 , big .NewInt (100 ), key )
401402 tx11 = transaction (11 , big .NewInt (200 ), key )
403+ tx12 = transaction (12 , big .NewInt (300 ), key )
402404 )
403405 pool .promoteTx (account , tx0 .Hash (), tx0 )
404406 pool .promoteTx (account , tx1 .Hash (), tx1 )
407+ pool .promoteTx (account , tx1 .Hash (), tx2 )
405408 pool .enqueueTx (tx10 .Hash (), tx10 )
406409 pool .enqueueTx (tx11 .Hash (), tx11 )
410+ pool .enqueueTx (tx11 .Hash (), tx12 )
407411
408412 // Check that pre and post validations leave the pool as is
409- if pool .pending [account ].Len () != 2 {
410- t .Errorf ("pending transaction mismatch: have %d, want %d" , pool .pending [account ].Len (), 2 )
413+ if pool .pending [account ].Len () != 3 {
414+ t .Errorf ("pending transaction mismatch: have %d, want %d" , pool .pending [account ].Len (), 3 )
411415 }
412- if pool .queue [account ].Len () != 2 {
413- t .Errorf ("queued transaction mismatch: have %d, want %d" , pool .queue [account ].Len (), 2 )
416+ if pool .queue [account ].Len () != 3 {
417+ t .Errorf ("queued transaction mismatch: have %d, want %d" , pool .queue [account ].Len (), 3 )
414418 }
415419 if len (pool .all ) != 4 {
416420 t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 4 )
417421 }
418422 pool .resetState ()
419- if pool .pending [account ].Len () != 2 {
420- t .Errorf ("pending transaction mismatch: have %d, want %d" , pool .pending [account ].Len (), 2 )
423+ if pool .pending [account ].Len () != 3 {
424+ t .Errorf ("pending transaction mismatch: have %d, want %d" , pool .pending [account ].Len (), 3 )
421425 }
422- if pool .queue [account ].Len () != 2 {
423- t .Errorf ("queued transaction mismatch: have %d, want %d" , pool .queue [account ].Len (), 2 )
426+ if pool .queue [account ].Len () != 3 {
427+ t .Errorf ("queued transaction mismatch: have %d, want %d" , pool .queue [account ].Len (), 3 )
424428 }
425429 if len (pool .all ) != 4 {
426430 t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 4 )
427431 }
428432 // Reduce the balance of the account, and check that invalidated transactions are dropped
429- state .AddBalance (account , big .NewInt (- 750 ))
433+ state .AddBalance (account , big .NewInt (- 650 ))
430434 pool .resetState ()
431435
432436 if _ , ok := pool .pending [account ].txs .items [tx0 .Nonce ()]; ! ok {
433437 t .Errorf ("funded pending transaction missing: %v" , tx0 )
434438 }
435- if _ , ok := pool .pending [account ].txs .items [tx1 .Nonce ()]; ok {
439+ if _ , ok := pool .pending [account ].txs .items [tx1 .Nonce ()]; ! ok {
440+ t .Errorf ("funded pending transaction missing: %v" , tx0 )
441+ }
442+ if _ , ok := pool .pending [account ].txs .items [tx2 .Nonce ()]; ok {
436443 t .Errorf ("out-of-fund pending transaction present: %v" , tx1 )
437444 }
438445 if _ , ok := pool .queue [account ].txs .items [tx10 .Nonce ()]; ! ok {
439446 t .Errorf ("funded queued transaction missing: %v" , tx10 )
440447 }
441- if _ , ok := pool .queue [account ].txs .items [tx11 .Nonce ()]; ok {
448+ if _ , ok := pool .queue [account ].txs .items [tx11 .Nonce ()]; ! ok {
449+ t .Errorf ("funded queued transaction missing: %v" , tx10 )
450+ }
451+ if _ , ok := pool .queue [account ].txs .items [tx12 .Nonce ()]; ok {
442452 t .Errorf ("out-of-fund queued transaction present: %v" , tx11 )
443453 }
454+ if len (pool .all ) != 4 {
455+ t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 4 )
456+ }
457+ // Reduce the block gas limit, check that invalidated transactions are dropped
458+ pool .gasLimit = func () * big.Int { return big .NewInt (100 ) }
459+ pool .resetState ()
460+
461+ if _ , ok := pool .pending [account ].txs .items [tx0 .Nonce ()]; ! ok {
462+ t .Errorf ("funded pending transaction missing: %v" , tx0 )
463+ }
464+ if _ , ok := pool .pending [account ].txs .items [tx1 .Nonce ()]; ok {
465+ t .Errorf ("over-gased pending transaction present: %v" , tx1 )
466+ }
467+ if _ , ok := pool .queue [account ].txs .items [tx10 .Nonce ()]; ! ok {
468+ t .Errorf ("funded queued transaction missing: %v" , tx10 )
469+ }
470+ if _ , ok := pool .queue [account ].txs .items [tx11 .Nonce ()]; ok {
471+ t .Errorf ("over-gased queued transaction present: %v" , tx11 )
472+ }
444473 if len (pool .all ) != 2 {
445474 t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 2 )
446475 }
0 commit comments