Skip to content

Commit 31a65cd

Browse files
committed
chore(ruff): changes to tests/osaka/.
1 parent d726e33 commit 31a65cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+443
-730
lines changed

tests/osaka/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"""
2-
Test cases for EVM functionality introduced in Osaka, [EIP-7607: Hardfork Meta - Fusaka](https://eip.directory/eips/eip-7607).
3-
""" # noqa: E501
1+
"""Test cases for EVM functionality introduced in Osaka, [EIP-7607: Hardfork Meta - Fusaka](https://eip.directory/eips/eip-7607).""" # noqa: E501

tests/osaka/eip7692_eof_v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
abstract: Test cases for [EIP-7692: EVM Object Format (EOFv1) Meta](https://eips.ethereum.org/EIPS/eip-7692)
3-
Test cases for the EIPs included in [EIP-7692 EOFv1 Meta](https://eips.ethereum.org/EIPS/eip-7692):
3+
Test cases for the EIPs included in [EIP-7692 EOFv1 Meta](https://eips.ethereum.org/EIPS/eip-7692).
44
55
* [EIP-663: SWAPN, DUPN and EXCHANGE instructions](https://eips.ethereum.org/EIPS/eip-663).
66
* [EIP-3540: EOF - EVM Object Format v1](https://eips.ethereum.org/EIPS/eip-3540).

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/opcodes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
EOF Valid Opcodes
3-
"""
1+
"""EOF Valid Opcodes."""
42

53
from typing import List
64

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"""
2-
EOF V1 Constants used throughout all tests
3-
"""
1+
"""EOF V1 Constants used throughout all tests."""

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
"""
2-
EOF Container: check how every opcode behaves in the middle of the valid eof container code
3-
"""
1+
"""EOF Container: check how every opcode behaves in the middle of the valid eof container code."""
42
import itertools
53
from typing import Any, Dict, Generator, List, Tuple
64

75
import pytest
86

9-
from ethereum_test_tools import EOFException, EOFTestFiller, Opcode
7+
from ethereum_test_tools import EOFException, EOFTestFiller, Opcode, UndefinedOpcodes
108
from ethereum_test_tools import Opcodes as Op
11-
from ethereum_test_tools import UndefinedOpcodes
129
from ethereum_test_tools.eof.v1 import Container, ContainerKind, Section
1310
from ethereum_test_tools.eof.v1.constants import MAX_OPERAND_STACK_HEIGHT
1411
from ethereum_test_vm import Bytecode
@@ -76,7 +73,7 @@ def test_all_opcodes_in_container(
7673
):
7774
"""
7875
Test all opcodes inside valid container
79-
257 because 0x5B is duplicated
76+
257 because 0x5B is duplicated.
8077
"""
8178
data_portion = 1 if opcode == Op.CALLF else 0
8279
opcode_with_data_portion = opcode[data_portion] if opcode.has_data_portion() else opcode
@@ -135,9 +132,7 @@ def test_invalid_opcodes_after_stop(
135132
opcode: Opcode,
136133
terminating_opcode: Opcode,
137134
):
138-
"""
139-
Test that an invalid opcode placed after STOP (terminating instruction) invalidates EOF.
140-
"""
135+
"""Test that an invalid opcode placed after STOP (terminating instruction) invalidates EOF."""
141136
terminating_code = Bytecode(terminating_opcode)
142137
match terminating_opcode: # Enhance the code for complex opcodes.
143138
case Op.RETURNCONTRACT:
@@ -181,9 +176,7 @@ def test_all_invalid_terminating_opcodes(
181176
eof_test: EOFTestFiller,
182177
opcode: Opcode,
183178
):
184-
"""
185-
Test all opcodes that are invalid as the last opcode in a container
186-
"""
179+
"""Test all opcodes that are invalid as the last opcode in a container."""
187180
if opcode.has_data_portion():
188181
# Add the appropriate data portion to the opcode by using the get_item method.
189182
# On the CALLF opcode we need to reference the second code section, hence the [1] index.
@@ -225,9 +218,7 @@ def test_all_unreachable_terminating_opcodes_after_stop(
225218
eof_test: EOFTestFiller,
226219
opcode: Opcode,
227220
):
228-
"""
229-
Test all terminating opcodes after stop.
230-
"""
221+
"""Test all terminating opcodes after stop."""
231222
match opcode:
232223
case Op.STOP:
233224
sections = [Section.Code(code=Op.STOP + Op.STOP)]
@@ -278,9 +269,7 @@ def test_all_unreachable_terminating_opcodes_before_stop(
278269
eof_test: EOFTestFiller,
279270
opcode: Opcode,
280271
):
281-
"""
282-
Test all opcodes terminating opcodes before.
283-
"""
272+
"""Test all opcodes terminating opcodes before."""
284273
match opcode:
285274
case Op.RETF:
286275
sections = [
@@ -338,9 +327,7 @@ def test_all_opcodes_stack_underflow(
338327
eof_test: EOFTestFiller,
339328
opcode: Opcode,
340329
):
341-
"""
342-
Test stack underflow on all opcodes that require at least one item on the stack
343-
"""
330+
"""Test stack underflow on all opcodes that require at least one item on the stack."""
344331
sections: List[Section]
345332
if opcode == Op.EOFCREATE:
346333
sections = [
@@ -404,9 +391,7 @@ def test_all_opcodes_stack_overflow(
404391
opcode: Opcode,
405392
exception: EOFException,
406393
):
407-
"""
408-
Test stack overflow on all opcodes that push more items than they pop
409-
"""
394+
"""Test stack overflow on all opcodes that push more items than they pop."""
410395
opcode = opcode[0] if opcode.has_data_portion() else opcode
411396

412397
assert opcode.pushed_stack_items - opcode.popped_stack_items == 1
@@ -439,9 +424,7 @@ def valid_opcode_combinations(
439424
truncate_all_options: List[bool],
440425
opcodes: List[Opcode],
441426
) -> Generator[Tuple[bool, bool, Opcode], None, None]:
442-
"""
443-
Create valid parameter combinations for test_truncated_data_portion_opcodes().
444-
"""
427+
"""Create valid parameter combinations for test_truncated_data_portion_opcodes()."""
445428
for opcode, truncate_all, compute_max_stack_height in itertools.product(
446429
opcodes, truncate_all_options, compute_max_stack_height_options
447430
):

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_size.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
EOF validation tests for EIP-3540 container size
3-
"""
1+
"""EOF validation tests for EIP-3540 container size."""
42

53
import pytest
64

@@ -27,9 +25,7 @@ def test_max_size(
2725
eof_test: EOFTestFiller,
2826
over_limit: int,
2927
):
30-
"""
31-
Verify EOF container valid at maximum size, invalid above
32-
"""
28+
"""Verify EOF container valid at maximum size, invalid above."""
3329
# Expand the minimal EOF code by more noop code, reaching the desired target container size.
3430
code = Container(
3531
sections=[
@@ -54,9 +50,7 @@ def test_above_max_size_raw(
5450
eof_test: EOFTestFiller,
5551
size: int,
5652
):
57-
"""
58-
Verify EOF container invalid above maximum size, regardless of header contents
59-
"""
53+
"""Verify EOF container invalid above maximum size, regardless of header contents."""
6054
code = Op.INVALID * size
6155
eof_test(
6256
data=bytes(code),
@@ -105,9 +99,7 @@ def test_section_after_end_of_container(
10599
eof_test: EOFTestFiller,
106100
code: Container,
107101
):
108-
"""
109-
Verify EOF container is invalid if any of sections declares above container size
110-
"""
102+
"""Verify EOF container is invalid if any of sections declares above container size."""
111103
eof_test(
112104
data=bytes(code),
113105
expect_exception=EOFException.INVALID_SECTION_BODIES_SIZE,

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
EOF validation tests for EIP-3540 container format
3-
"""
1+
"""EOF validation tests for EIP-3540 container format."""
42

53

64
import pytest
@@ -1081,9 +1079,7 @@ def test_magic_validation(
10811079
magic_0: int,
10821080
magic_1: int,
10831081
):
1084-
"""
1085-
Verify EOF container 2-byte magic
1086-
"""
1082+
"""Verify EOF container 2-byte magic."""
10871083
if magic_0 == 0xEF and magic_1 == 0:
10881084
pytest.skip("Valid magic")
10891085
code = bytearray(bytes(VALID_CONTAINER))
@@ -1100,9 +1096,7 @@ def test_version_validation(
11001096
eof_test: EOFTestFiller,
11011097
version: int,
11021098
):
1103-
"""
1104-
Verify EOF container version
1105-
"""
1099+
"""Verify EOF container version."""
11061100
if version == 1:
11071101
pytest.skip("Valid version")
11081102
code = bytearray(bytes(VALID_CONTAINER))
@@ -1120,9 +1114,7 @@ def test_single_code_section(
11201114
plus_data: bool,
11211115
plus_container: bool,
11221116
):
1123-
"""
1124-
Verify EOF container maximum number of code sections
1125-
"""
1117+
"""Verify EOF container maximum number of code sections."""
11261118
sections = [Section.Code(Op.RETURNCONTRACT[0](0, 0) if plus_container else Op.STOP)]
11271119
if plus_container:
11281120
sections.append(
@@ -1153,9 +1145,7 @@ def test_max_code_sections(
11531145
plus_data: bool,
11541146
plus_container: bool,
11551147
):
1156-
"""
1157-
Verify EOF container maximum number of code sections
1158-
"""
1148+
"""Verify EOF container maximum number of code sections."""
11591149
if plus_container:
11601150
sections = [
11611151
Section.Code(

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_eof_example.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
EOF Classes example use
3-
"""
1+
"""EOF Classes example use."""
42

53
import pytest
64

@@ -17,9 +15,7 @@
1715

1816

1917
def test_eof_example(eof_test: EOFTestFiller):
20-
"""
21-
Example of python EOF classes
22-
"""
18+
"""Example of python EOF classes."""
2319
# Lets construct an EOF container code
2420
eof_code = Container(
2521
name="valid_container_example",
@@ -70,9 +66,7 @@ def test_eof_example(eof_test: EOFTestFiller):
7066

7167

7268
def test_eof_example_custom_fields(eof_test: EOFTestFiller):
73-
"""
74-
Example of python EOF container class tuning
75-
"""
69+
"""Example of python EOF container class tuning."""
7670
# if you need to overwrite certain structure bytes, you can use customization
7771
# this is useful for unit testing the eof structure format, you can reorganize sections
7872
# and overwrite the header bytes for testing purposes
@@ -135,9 +129,7 @@ def test_eof_example_parameters(
135129
code_section_code: Bytecode,
136130
exception: EOFException,
137131
):
138-
"""
139-
Example of python EOF classes
140-
"""
132+
"""Example of python EOF classes."""
141133
eof_code = Container(
142134
name="parametrized_eof_example",
143135
sections=[

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_execution.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Execution of basic EOF containers.
3-
"""
1+
"""Execution of basic EOF containers."""
42

53
import pytest
64

@@ -44,9 +42,7 @@ def test_eof_execution(
4442
pre: Alloc,
4543
container: Container,
4644
):
47-
"""
48-
Test simple contracts that are expected to succeed on call.
49-
"""
45+
"""Test simple contracts that are expected to succeed on call."""
5046
env = Environment()
5147

5248
storage = Storage()

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_execution_function.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Execution of CALLF, RETF opcodes within EOF V1 containers tests
3-
"""
1+
"""Execution of CALLF, RETF opcodes within EOF V1 containers tests."""
42

53
from typing import List
64

@@ -306,9 +304,7 @@ def test_eof_functions_contract_call_succeed(
306304
pre: Alloc,
307305
container: Container,
308306
):
309-
"""
310-
Test simple contracts that are simply expected to succeed on call.
311-
"""
307+
"""Test simple contracts that are simply expected to succeed on call."""
312308
env = Environment()
313309

314310
sender = pre.fund_eoa()
@@ -341,9 +337,7 @@ def test_eof_functions_contract_call_fail(
341337
pre: Alloc,
342338
container: Container,
343339
):
344-
"""
345-
Test simple contracts that are simply expected to fail on call.
346-
"""
340+
"""Test simple contracts that are simply expected to fail on call."""
347341
env = Environment()
348342

349343
sender = pre.fund_eoa()

0 commit comments

Comments
 (0)