Skip to content

Commit 8fe375e

Browse files
authored
new(tests): CALLF with truncated immediate bytes (ethereum#1114)
1 parent bd9c581 commit 8fe375e

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,59 @@ def test_eof_validity(
175175
eof_test(data=container)
176176

177177

178+
@pytest.mark.parametrize(
179+
"container",
180+
[
181+
Container(
182+
name="imm0",
183+
sections=[
184+
Section.Code(
185+
code=Op.CALLF,
186+
)
187+
],
188+
validity_error=EOFException.TRUNCATED_INSTRUCTION,
189+
),
190+
Container(
191+
name="imm1",
192+
sections=[
193+
Section.Code(
194+
code=Op.CALLF + Op.STOP,
195+
)
196+
],
197+
validity_error=EOFException.TRUNCATED_INSTRUCTION,
198+
),
199+
Container(
200+
name="imm_from_next_section",
201+
sections=[
202+
Section.Code(
203+
code=Op.PUSH0 + Op.PUSH0 + Op.CALLF[1] + Op.STOP,
204+
),
205+
Section.Code(
206+
code=Op.CALLF + Op.STOP, # would be valid with "02" + Op.RETF.
207+
code_inputs=2,
208+
code_outputs=1,
209+
max_stack_height=2,
210+
),
211+
Section.Code(
212+
code=Op.SUB + Op.RETF, # SUB (0x02) can be confused with CALLF[2].
213+
code_inputs=2,
214+
code_outputs=1,
215+
max_stack_height=2,
216+
),
217+
],
218+
validity_error=EOFException.TRUNCATED_INSTRUCTION,
219+
),
220+
],
221+
ids=container_name,
222+
)
223+
def test_callf_truncated_immediate(
224+
eof_test: EOFTestFiller,
225+
container: Container,
226+
):
227+
"""Test cases for CALLF instructions with truncated immediate bytes."""
228+
eof_test(data=container, expect_exception=EOFException.TRUNCATED_INSTRUCTION)
229+
230+
178231
@pytest.mark.parametrize(
179232
"container",
180233
[

osaka/eip7692_eof_v1/eof_tracker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151

152152
- [ ] Valid CALLFs (ethereum/tests: ./src/EOFTestsFiller/efExample/validInvalidFiller.yml)
153153
- [ ] CALLFs to non-existing sections (ethereum/tests: ./src/EOFTestsFiller/efExample/validInvalidFiller.yml src/EOFTestsFiller/efValidation/callf_invalid_code_section_index_Copier.json src/EOFTestsFiller/EIP4750/validInvalidFiller.yml)
154-
- [ ] Truncated CALLF immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_callf_truncated_Copier.json src/EOFTestsFiller/EIP4750/validInvalidFiller.yml)
154+
- [x] Truncated CALLF immediate ([`tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py::test_callf_truncated_immediate`](./eip4750_functions/test_code_validation/test_callf_truncated_immediate.md))
155155
- [ ] Unreachable code sections (ethereum/tests: src/EOFTestsFiller/efValidation/unreachable_code_sections_Copier.json)
156156
- [ ] Sections reachable from other sections, but not reachable from section 0 (ethereum/tests: src/EOFTestsFiller/efValidation/unreachable_code_sections_Copier.json)
157157
- [ ] Unreachable code section that calls itself with JUMPF

0 commit comments

Comments
 (0)