Skip to content

Commit

Permalink
fillers: add strict test for warm coinbase out of gas
Browse files Browse the repository at this point in the history
Additionally test that the contract call fails if call_exact_gas - 1 is specified instead of call_exact_gas.
  • Loading branch information
danceratopz committed Apr 28, 2023
1 parent a2ee7c9 commit 79ed2a2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions fillers/eips/eip3651.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@


@pytest.mark.parametrize(
"opcode,contract_under_test_code,call_gas",
"use_sufficient_gas",
[True, False],
ids=["sufficient_gas", "insufficient_gas"],
)
@pytest.mark.parametrize(
"opcode,contract_under_test_code,call_gas_exact",
[
(
"call",
Expand Down Expand Up @@ -60,7 +65,12 @@
ids=["CALL", "CALLCODE", "DELEGATECALL", "STATICCALL"],
)
def test_warm_coinbase_call_out_of_gas(
state_test, fork, opcode, contract_under_test_code, call_gas
state_test,
fork,
opcode,
contract_under_test_code,
call_gas_exact,
use_sufficient_gas,
):
"""
Test warm coinbase.
Expand All @@ -75,9 +85,12 @@ def test_warm_coinbase_call_out_of_gas(
caller_address = "0xcccccccccccccccccccccccccccccccccccccccc"
contract_under_test_address = 0x100

if not use_sufficient_gas:
call_gas_exact -= 1

caller_code = Op.SSTORE(
0,
Op.CALL(call_gas, contract_under_test_address, 0, 0, 0, 0, 0),
Op.CALL(call_gas_exact, contract_under_test_address, 0, 0, 0, 0, 0),
)

pre = {
Expand All @@ -100,7 +113,7 @@ def test_warm_coinbase_call_out_of_gas(

post = {}

if is_fork(fork=fork, which=Shanghai):
if use_sufficient_gas and is_fork(fork=fork, which=Shanghai):
post[caller_address] = Account(
storage={
# On shanghai and beyond, calls with only 100 gas to
Expand Down

0 comments on commit 79ed2a2

Please sign in to comment.