@@ -397,50 +397,79 @@ func TestTransactionDropping(t *testing.T) {
397
397
var (
398
398
tx0 = transaction (0 , big .NewInt (100 ), key )
399
399
tx1 = transaction (1 , big .NewInt (200 ), key )
400
+ tx2 = transaction (2 , big .NewInt (300 ), key )
400
401
tx10 = transaction (10 , big .NewInt (100 ), key )
401
402
tx11 = transaction (11 , big .NewInt (200 ), key )
403
+ tx12 = transaction (12 , big .NewInt (300 ), key )
402
404
)
403
405
pool .promoteTx (account , tx0 .Hash (), tx0 )
404
406
pool .promoteTx (account , tx1 .Hash (), tx1 )
407
+ pool .promoteTx (account , tx1 .Hash (), tx2 )
405
408
pool .enqueueTx (tx10 .Hash (), tx10 )
406
409
pool .enqueueTx (tx11 .Hash (), tx11 )
410
+ pool .enqueueTx (tx11 .Hash (), tx12 )
407
411
408
412
// 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 )
411
415
}
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 )
414
418
}
415
419
if len (pool .all ) != 4 {
416
420
t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 4 )
417
421
}
418
422
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 )
421
425
}
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 )
424
428
}
425
429
if len (pool .all ) != 4 {
426
430
t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 4 )
427
431
}
428
432
// 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 ))
430
434
pool .resetState ()
431
435
432
436
if _ , ok := pool .pending [account ].txs .items [tx0 .Nonce ()]; ! ok {
433
437
t .Errorf ("funded pending transaction missing: %v" , tx0 )
434
438
}
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 {
436
443
t .Errorf ("out-of-fund pending transaction present: %v" , tx1 )
437
444
}
438
445
if _ , ok := pool .queue [account ].txs .items [tx10 .Nonce ()]; ! ok {
439
446
t .Errorf ("funded queued transaction missing: %v" , tx10 )
440
447
}
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 {
442
452
t .Errorf ("out-of-fund queued transaction present: %v" , tx11 )
443
453
}
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
+ }
444
473
if len (pool .all ) != 2 {
445
474
t .Errorf ("total transaction mismatch: have %d, want %d" , len (pool .all ), 2 )
446
475
}
0 commit comments