Skip to content

Commit 668fe7f

Browse files
committed
Clarify base gas fee tests, now parametrized
1 parent 57b5814 commit 668fe7f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/core/vm/test_london.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@pytest.fixture(params=MAINNET_VMS[9:])
1717
def london_plus_miner(request, base_db, genesis_state):
1818
klass = MiningChain.configure(
19-
__name__='CrossoverTestChain',
19+
__name__='LondonAt1',
2020
vm_configuration=(
2121
(
2222
constants.GENESIS_BLOCK_NUMBER,
@@ -33,8 +33,8 @@ def london_plus_miner(request, base_db, genesis_state):
3333
difficulty=1,
3434
gas_limit=21000 * 2, # block limit is hit with two transactions
3535
)
36-
# On the first London+ block, it will double the block limit so that the
37-
# block *target* is hit with 2 transactions
36+
# On the first London+ block, it will double the block limit so that it
37+
# can precisely hold 4 transactions.
3838
return klass.from_genesis(base_db, header_fields, genesis_state)
3939

4040

@@ -52,7 +52,8 @@ def london_plus_miner(request, base_db, genesis_state):
5252
def test_base_fee_evolution(
5353
london_plus_miner, funded_address, funded_address_private_key, num_txns, expected_base_fee):
5454
chain = london_plus_miner
55-
assert chain.header.gas_limit == 21000 * 4
55+
FOUR_TXN_GAS_LIMIT = 21000 * 4
56+
assert chain.header.gas_limit == FOUR_TXN_GAS_LIMIT
5657

5758
vm = chain.get_vm()
5859
txns = [
@@ -66,15 +67,15 @@ def test_base_fee_evolution(
6667
)
6768
for nonce in range(num_txns)
6869
]
69-
block_import, _, _ = chain.mine_all(txns, gas_limit=21000 * 4)
70+
block_import, _, _ = chain.mine_all(txns, gas_limit=FOUR_TXN_GAS_LIMIT)
7071
mined_header = block_import.imported_block.header
71-
assert mined_header.gas_limit == 21000 * 4
72+
assert mined_header.gas_limit == FOUR_TXN_GAS_LIMIT
7273
assert mined_header.gas_used == 21000 * num_txns
7374
assert mined_header.base_fee_per_gas == 10 ** 9 # Initialize at 1 gwei
7475

75-
# Next block should have an unchanged gas fee because usage was equal to target (half of limit)
76-
block_import, _, _ = chain.mine_all([], gas_limit=21000 * 4)
76+
block_import, _, _ = chain.mine_all([], gas_limit=FOUR_TXN_GAS_LIMIT)
7777
mined_header = block_import.imported_block.header
78-
assert mined_header.gas_limit == 21000 * 4
78+
assert mined_header.gas_limit == FOUR_TXN_GAS_LIMIT
7979
assert mined_header.gas_used == 0
80+
# Check that the base fee evolved correctly, depending on how much gas was used in the parent
8081
assert mined_header.base_fee_per_gas == expected_base_fee

0 commit comments

Comments
 (0)