Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(tests): EOF - EIP-7069: Add tests #722

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,9 @@ def test_address_space_extension(
if ase_address and target_address[0] == b"00":
raise ValueError("Test instrumentation requires target addresses trim leading zeros")

match target_opcode:
case Op.CALL | Op.CALLCODE:
call_suffix = [0, 0, 0, 0, 0]
ase_ready_opcode = False
case Op.DELEGATECALL | Op.STATICCALL:
call_suffix = [0, 0, 0, 0]
ase_ready_opcode = False
case Op.EXTCALL:
call_suffix = [0, 0, 0]
ase_ready_opcode = True
case Op.EXTDELEGATECALL | Op.EXTSTATICCALL:
call_suffix = [0, 0]
ase_ready_opcode = True
case _:
raise ValueError("Unexpected opcode ", target_opcode)
ase_ready_opcode = (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, if I left this expression as a (simplified) match-case statement, mypy complained about the type of target_opcode not being callable in the target_opcode(address=Op.CALLDATALOAD(0)) below. I've searched for the reason and also tried upgrading mypy to 1.11 - to no avail. Have I missed sth or maybe it's worth to produce a reproducible example and report?

False if target_opcode in [Op.CALL, Op.CALLCODE, Op.DELEGATECALL, Op.STATICCALL] else True
)

sender = pre.fund_eoa()

Expand All @@ -100,7 +88,7 @@ def test_address_space_extension(
Section.Code(
code=Op.SSTORE(
slot_target_call_status,
target_opcode(Op.CALLDATALOAD(0), *call_suffix), # type: ignore
target_opcode(address=Op.CALLDATALOAD(0)),
)
+ Op.RETURNDATACOPY(0, 0, Op.RETURNDATASIZE)
+ Op.SSTORE(slot_target_returndata, Op.MLOAD(0))
Expand All @@ -112,7 +100,7 @@ def test_address_space_extension(
if ase_ready_opcode
else Op.SSTORE(
slot_target_call_status,
target_opcode(Op.GAS, Op.CALLDATALOAD(0), *call_suffix), # type: ignore
target_opcode(address=Op.CALLDATALOAD(0)),
)
+ Op.RETURNDATACOPY(0, 0, Op.RETURNDATASIZE)
+ Op.SSTORE(slot_target_returndata, Op.MLOAD(0))
Expand Down Expand Up @@ -221,8 +209,6 @@ def test_address_space_extension(
sender=sender,
to=address_entry_point,
gas_limit=50_000_000,
gas_price=10,
protected=False,
data="",
)

Expand Down
8 changes: 4 additions & 4 deletions tests/prague/eip7692_eof_v1/eip7069_extcall/test_calldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_extcalls_inputdata(
"""
env = Environment()

sender = pre.fund_eoa(10**18)
sender = pre.fund_eoa()

address_returner = pre.deploy_contract(
Container(
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_extdelegatecall_inputdata(
"""
env = Environment()

sender = pre.fund_eoa(10**18)
sender = pre.fund_eoa()

address_returner = pre.deploy_contract(
Container(
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_extstaticcall_inputdata(
"""
env = Environment()

sender = pre.fund_eoa(10**18)
sender = pre.fund_eoa()

address_returner = pre.deploy_contract(
Container(
Expand Down Expand Up @@ -316,7 +316,7 @@ def test_calldata_remains_after_subcall(
"""
env = Environment()

sender = pre.fund_eoa(10**18)
sender = pre.fund_eoa()

address_sub_called = pre.deploy_contract(
Container(
Expand Down
Loading