@@ -1492,6 +1492,50 @@ func TestRepricing(t *testing.T) {
14921492 }
14931493}
14941494
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+
14951539// Tests that setting the transaction pool gas price to a higher value correctly
14961540// discards everything cheaper (legacy & dynamic fee) than that and moves any
14971541// gapped transactions back from the pending pool to the queue.
0 commit comments