Skip to content

Commit 9eb4af7

Browse files
committed
fix(tests): Fix previous fork test fails
1 parent 027ea96 commit 9eb4af7

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

tests/cancun/create/test_create_oog_from_eoa_refunds.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,16 @@ def test_create_oog_from_eoa_refunds(
326326
)
327327
post[sender] = Account(nonce=1)
328328
else:
329-
# OOG case: contract not created, sender balance is fully consumed
329+
# OOG case: contract not created
330330
post[created_address] = Account.NONEXISTENT
331-
post[sender] = Account(
332-
nonce=1,
333-
balance=0,
334-
)
331+
if fork.is_eip_enabled(8037):
332+
# EIP-8037: execution state gas is returned to the
333+
# reservoir on top-level failure, so the sender retains
334+
# some balance (the refunded state gas × gas_price).
335+
post[sender] = Account(nonce=1)
336+
else:
337+
# Pre-EIP-8037: sender balance is fully consumed
338+
post[sender] = Account(nonce=1, balance=0)
335339

336340
if refund_type == RefundType.SELFDESTRUCT:
337341
selfdestruct_code = Op.SELFDESTRUCT(Op.ORIGIN) + Op.STOP

tests/cancun/eip5656_mcopy/test_mcopy_memory_expansion.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,22 @@ def tx( # noqa: D103
128128
initial_memory: bytes,
129129
tx_gas_limit: int,
130130
tx_access_list: List[AccessList],
131+
fork: Fork,
132+
successful: bool,
131133
) -> Transaction:
134+
# EIP-8037: on top-level OOG, execution state gas is returned to the
135+
# reservoir and not billed. The callee's SSTORE contributes state
136+
# gas that gets refunded on failure.
137+
expected_gas = tx_gas_limit
138+
if not successful and fork.is_eip_enabled(8037):
139+
expected_gas -= fork.sstore_state_gas()
132140
return Transaction(
133141
sender=sender,
134142
to=caller_address,
135143
access_list=tx_access_list,
136144
data=initial_memory,
137145
gas_limit=tx_gas_limit,
138-
expected_receipt=TransactionReceipt(cumulative_gas_used=tx_gas_limit),
146+
expected_receipt=TransactionReceipt(cumulative_gas_used=expected_gas),
139147
)
140148

141149

0 commit comments

Comments
 (0)