@@ -1492,6 +1492,50 @@ func TestRepricing(t *testing.T) {
1492
1492
}
1493
1493
}
1494
1494
1495
+ func TestMinGasPriceEnforced (t * testing.T ) {
1496
+ t .Parallel ()
1497
+
1498
+ // Create the pool to test the pricing enforcement with
1499
+ statedb , _ := state .New (types .EmptyRootHash , state .NewDatabase (rawdb .NewMemoryDatabase ()), nil )
1500
+ blockchain := newTestBlockChain (eip1559Config , 10000000 , statedb , new (event.Feed ))
1501
+
1502
+ txPoolConfig := DefaultConfig
1503
+ txPoolConfig .NoLocals = true
1504
+ pool := New (txPoolConfig , blockchain )
1505
+ pool .Init (new (big.Int ).SetUint64 (txPoolConfig .PriceLimit ), blockchain .CurrentBlock (), makeAddressReserver ())
1506
+ defer pool .Close ()
1507
+
1508
+ key , _ := crypto .GenerateKey ()
1509
+ testAddBalance (pool , crypto .PubkeyToAddress (key .PublicKey ), big .NewInt (1000000 ))
1510
+
1511
+ tx := pricedTransaction (0 , 100000 , big .NewInt (2 ), key )
1512
+ pool .SetGasTip (big .NewInt (tx .GasPrice ().Int64 () + 1 ))
1513
+
1514
+ if err := pool .addLocal (tx ); ! errors .Is (err , txpool .ErrUnderpriced ) {
1515
+ t .Fatalf ("Min tip not enforced" )
1516
+ }
1517
+
1518
+ if err := pool .Add ([]* types.Transaction {tx }, true , false )[0 ]; ! errors .Is (err , txpool .ErrUnderpriced ) {
1519
+ t .Fatalf ("Min tip not enforced" )
1520
+ }
1521
+
1522
+ tx = dynamicFeeTx (0 , 100000 , big .NewInt (3 ), big .NewInt (2 ), key )
1523
+ pool .SetGasTip (big .NewInt (tx .GasTipCap ().Int64 () + 1 ))
1524
+
1525
+ if err := pool .addLocal (tx ); ! errors .Is (err , txpool .ErrUnderpriced ) {
1526
+ t .Fatalf ("Min tip not enforced" )
1527
+ }
1528
+
1529
+ if err := pool .Add ([]* types.Transaction {tx }, true , false )[0 ]; ! errors .Is (err , txpool .ErrUnderpriced ) {
1530
+ t .Fatalf ("Min tip not enforced" )
1531
+ }
1532
+ // Make sure the tx is accepted if locals are enabled
1533
+ pool .config .NoLocals = false
1534
+ if err := pool .Add ([]* types.Transaction {tx }, true , false )[0 ]; err != nil {
1535
+ t .Fatalf ("Min tip enforced with locals enabled, error: %v" , err )
1536
+ }
1537
+ }
1538
+
1495
1539
// Tests that setting the transaction pool gas price to a higher value correctly
1496
1540
// discards everything cheaper (legacy & dynamic fee) than that and moves any
1497
1541
// gapped transactions back from the pending pool to the queue.
0 commit comments