@@ -367,8 +367,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
367
367
ctx , cancel := context .WithCancel (context .Background ())
368
368
defer cancel ()
369
369
370
- // gas estimated is 1 so we will use this and not fallback to gas wanted
371
- gasEstimated := int64 (1 )
370
+ gasEstimated := int64 (1 ) // gas estimated set to 1
372
371
client := abciclient .NewLocalClient (log .NewNopLogger (), & application {Application : kvstore .NewApplication (), gasEstimated : & gasEstimated })
373
372
if err := client .Start (ctx ); err != nil {
374
373
t .Fatal (err )
@@ -407,7 +406,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
407
406
wg .Add (1 )
408
407
go func () {
409
408
defer wg .Done ()
410
- reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 50 , 0 )
409
+ reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 50 , - 1 , 0 )
411
410
ensurePrioritized (reapedTxs )
412
411
require .Equal (t , len (tTxs ), txmp .Size ())
413
412
require .Equal (t , int64 (5690 ), txmp .SizeBytes ())
@@ -418,7 +417,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
418
417
wg .Add (1 )
419
418
go func () {
420
419
defer wg .Done ()
421
- reapedTxs := txmp .ReapMaxBytesMaxGas (1000 , - 1 , 0 )
420
+ reapedTxs := txmp .ReapMaxBytesMaxGas (1000 , - 1 , - 1 , 0 )
422
421
ensurePrioritized (reapedTxs )
423
422
require .Equal (t , len (tTxs ), txmp .Size ())
424
423
require .Equal (t , int64 (5690 ), txmp .SizeBytes ())
@@ -430,7 +429,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
430
429
wg .Add (1 )
431
430
go func () {
432
431
defer wg .Done ()
433
- reapedTxs := txmp .ReapMaxBytesMaxGas (1500 , 30 , 0 )
432
+ reapedTxs := txmp .ReapMaxBytesMaxGas (1500 , 30 , - 1 , 0 )
434
433
ensurePrioritized (reapedTxs )
435
434
require .Equal (t , len (tTxs ), txmp .Size ())
436
435
require .Equal (t , int64 (5690 ), txmp .SizeBytes ())
@@ -441,7 +440,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
441
440
wg .Add (1 )
442
441
go func () {
443
442
defer wg .Done ()
444
- reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 1 , 2 )
443
+ reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 1 , - 1 , 2 )
445
444
ensurePrioritized (reapedTxs )
446
445
require .Equal (t , len (tTxs ), txmp .Size ())
447
446
require .Len (t , reapedTxs , 2 )
@@ -451,21 +450,42 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
451
450
wg .Add (1 )
452
451
go func () {
453
452
defer wg .Done ()
454
- reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 50 , 0 )
453
+ reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , - 1 , 50 , 0 )
455
454
ensurePrioritized (reapedTxs )
456
455
require .Equal (t , len (tTxs ), txmp .Size ())
457
456
require .Len (t , reapedTxs , 50 )
458
457
}()
459
458
459
+ // Test that minTxsPerBlock is still used even when max gas esimated is exceeded
460
+ wg .Add (1 )
461
+ go func () {
462
+ defer wg .Done ()
463
+ // pull minTxsPerBlock even though max gas wanted is hit
464
+ reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , - 1 , 50 , 51 )
465
+ ensurePrioritized (reapedTxs )
466
+ require .Equal (t , len (tTxs ), txmp .Size ())
467
+ require .Len (t , reapedTxs , 51 )
468
+ }()
469
+
470
+ // Test that minTxsPerBlock is still used even when max gas wanted is exceeded
471
+ wg .Add (1 )
472
+ go func () {
473
+ defer wg .Done ()
474
+ // pull minTxsPerBlock even though max gas wanted is hit
475
+ reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 50 , - 1 , 51 )
476
+ ensurePrioritized (reapedTxs )
477
+ require .Equal (t , len (tTxs ), txmp .Size ())
478
+ require .Len (t , reapedTxs , 51 )
479
+ }()
480
+
460
481
wg .Wait ()
461
482
}
462
483
463
484
func TestTxMempool_ReapMaxBytesMaxGas_FallbackToGasWanted (t * testing.T ) {
464
485
ctx , cancel := context .WithCancel (context .Background ())
465
486
defer cancel ()
466
487
467
- // gas estimated is 0 so we will fallback to gas wanted
468
- gasEstimated := int64 (0 )
488
+ gasEstimated := int64 (0 ) // gas estimated not set so fallback to gas wanted
469
489
client := abciclient .NewLocalClient (log .NewNopLogger (), & application {Application : kvstore .NewApplication (), gasEstimated : & gasEstimated })
470
490
if err := client .Start (ctx ); err != nil {
471
491
t .Fatal (err )
@@ -501,7 +521,7 @@ func TestTxMempool_ReapMaxBytesMaxGas_FallbackToGasWanted(t *testing.T) {
501
521
wg .Add (1 )
502
522
go func () {
503
523
defer wg .Done ()
504
- reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , 50 , 0 )
524
+ reapedTxs := txmp .ReapMaxBytesMaxGas (- 1 , - 1 , 50 , 0 )
505
525
ensurePrioritized (reapedTxs )
506
526
require .Equal (t , len (tTxs ), txmp .Size ())
507
527
require .Len (t , reapedTxs , 50 )
0 commit comments