Skip to content

Commit 4379e3f

Browse files
committed
Effective gas price can be lower than the maxFeePerGas
1 parent b8e4abc commit 4379e3f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

web3/_utils/module_testing/eth_module.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ async def test_eth_send_transaction(
500500
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
501501
"maxPriorityFeePerGas": async_w3.to_wei(1, "gwei"),
502502
}
503+
503504
txn_hash = await async_w3.eth.send_transaction(txn_params)
504505
txn = await async_w3.eth.get_transaction(txn_hash)
505506

@@ -509,7 +510,7 @@ async def test_eth_send_transaction(
509510
assert txn["gas"] == 21000
510511
assert txn["maxFeePerGas"] == txn_params["maxFeePerGas"]
511512
assert txn["maxPriorityFeePerGas"] == txn_params["maxPriorityFeePerGas"]
512-
assert txn["gasPrice"] == txn_params["maxFeePerGas"]
513+
assert txn["gasPrice"] <= txn["maxFeePerGas"] # effective gas price
513514

514515
@pytest.mark.asyncio
515516
async def test_eth_send_transaction_default_fees(
@@ -523,6 +524,7 @@ async def test_eth_send_transaction_default_fees(
523524
"value": Wei(1),
524525
"gas": 21000,
525526
}
527+
526528
txn_hash = await async_w3.eth.send_transaction(txn_params)
527529
txn = await async_w3.eth.get_transaction(txn_hash)
528530

@@ -532,7 +534,7 @@ async def test_eth_send_transaction_default_fees(
532534
assert txn["gas"] == 21000
533535
assert is_integer(txn["maxPriorityFeePerGas"])
534536
assert is_integer(txn["maxFeePerGas"])
535-
assert txn["gasPrice"] == txn["maxFeePerGas"]
537+
assert txn["gasPrice"] <= txn["maxFeePerGas"] # effective gas price
536538

537539
@pytest.mark.asyncio
538540
async def test_eth_send_transaction_hex_fees(
@@ -809,7 +811,7 @@ def gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei:
809811
else 2 * latest_block["baseFeePerGas"] + max_priority_fee
810812
)
811813
assert txn["maxPriorityFeePerGas"] == max_priority_fee
812-
assert txn["gasPrice"] == txn["maxFeePerGas"]
814+
assert txn["gasPrice"] <= txn["maxFeePerGas"] # effective gas price
813815

814816
async_w3.eth.set_gas_price_strategy(None) # reset strategy
815817

@@ -3114,6 +3116,7 @@ def test_eth_send_transaction(
31143116
"maxFeePerGas": w3.to_wei(3, "gwei"),
31153117
"maxPriorityFeePerGas": w3.to_wei(1, "gwei"),
31163118
}
3119+
31173120
txn_hash = w3.eth.send_transaction(txn_params)
31183121
txn = w3.eth.get_transaction(txn_hash)
31193122

@@ -3123,7 +3126,7 @@ def test_eth_send_transaction(
31233126
assert txn["gas"] == 21000
31243127
assert txn["maxFeePerGas"] == txn_params["maxFeePerGas"]
31253128
assert txn["maxPriorityFeePerGas"] == txn_params["maxPriorityFeePerGas"]
3126-
assert txn["gasPrice"] == txn_params["maxFeePerGas"]
3129+
assert txn["gasPrice"] <= txn["maxFeePerGas"] # effective gas price
31273130

31283131
def test_eth_send_transaction_with_nonce(
31293132
self, w3: "Web3", keyfile_account_address: ChecksumAddress
@@ -3174,7 +3177,7 @@ def test_eth_send_transaction_default_fees(
31743177
assert txn["gas"] == 21000
31753178
assert is_integer(txn["maxPriorityFeePerGas"])
31763179
assert is_integer(txn["maxFeePerGas"])
3177-
assert txn["gasPrice"] == txn["maxFeePerGas"]
3180+
assert txn["gasPrice"] <= txn["maxFeePerGas"] # effective gas price
31783181

31793182
def test_eth_send_transaction_hex_fees(
31803183
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
@@ -3340,7 +3343,7 @@ def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> Wei:
33403343
else 2 * latest_block["baseFeePerGas"] + max_priority_fee
33413344
)
33423345
assert txn["maxPriorityFeePerGas"] == max_priority_fee
3343-
assert txn["gasPrice"] == txn["maxFeePerGas"]
3346+
assert txn["gasPrice"] <= txn["maxFeePerGas"] # effective gas price
33443347

33453348
w3.eth.set_gas_price_strategy(None) # reset strategy
33463349

0 commit comments

Comments
 (0)