Skip to content
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ MARKDOWN_FILES = $(CURDIR)/README.md \
lint: pyspec
@$(MDFORMAT_VENV) --number --wrap=80 $(MARKDOWN_FILES)
@$(CODESPELL_VENV) . --skip "./.git,$(VENV),$(PYSPEC_DIR)/.mypy_cache" -I .codespell-whitelist
@$(PYTHON_VENV) -m black $(CURDIR)/tests
@$(PYTHON_VENV) -m isort --quiet $(CURDIR)/tests
@$(PYTHON_VENV) -m black --quiet $(CURDIR)/tests
@$(PYTHON_VENV) -m pylint --rcfile $(PYLINT_CONFIG) $(PYLINT_SCOPE)
@$(PYTHON_VENV) -m mypy --config-file $(MYPY_CONFIG) $(MYPY_SCOPE)

Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test = [
lint = [
"black==25.1.0",
"codespell==2.4.1",
"isort==6.0.1",
"mdformat-gfm-alerts==1.0.1",
"mdformat-gfm==0.4.1",
"mdformat-toc==0.3.0",
Expand All @@ -62,3 +63,13 @@ docs = [

[tool.black]
line-length = 100

[tool.isort]
profile = "black"
line_length = 100
combine_as_imports = true
known_first_party = ["eth2spec"]
skip_glob = [
"tests/core/pyspec/eth2spec/*/mainnet.py",
"tests/core/pyspec/eth2spec/*/minimal.py",
]
3 changes: 2 additions & 1 deletion tests/core/pyspec/eth2spec/config/config_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from typing import Dict, Iterable, Union, BinaryIO, TextIO, Any
from typing import Any, BinaryIO, Dict, Iterable, TextIO, Union

from ruamel.yaml import YAML


Expand Down
11 changes: 6 additions & 5 deletions tests/core/pyspec/eth2spec/debug/decode.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import Any

from eth2spec.utils.ssz.ssz_impl import hash_tree_root
from eth2spec.utils.ssz.ssz_typing import (
uint,
ByteList,
ByteVector,
Container,
List,
boolean,
Vector,
ByteVector,
ByteList,
Union,
Vector,
View,
boolean,
uint,
)


Expand Down
6 changes: 3 additions & 3 deletions tests/core/pyspec/eth2spec/debug/encode.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from eth2spec.utils.ssz.ssz_impl import hash_tree_root, serialize
from eth2spec.utils.ssz.ssz_typing import (
uint,
boolean,
Bitlist,
Bitvector,
Container,
Vector,
List,
Union,
Vector,
boolean,
uint,
)


Expand Down
19 changes: 9 additions & 10 deletions tests/core/pyspec/eth2spec/debug/random_value.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from random import Random
from enum import Enum

from random import Random
from typing import Type

from eth2spec.utils.ssz.ssz_typing import (
View,
BasicView,
uint,
Container,
List,
boolean,
Vector,
ByteVector,
ByteList,
Bitlist,
Bitvector,
ByteList,
ByteVector,
Container,
List,
Union,
Vector,
View,
boolean,
uint,
)

# in bytes
Expand Down
3 changes: 2 additions & 1 deletion tests/core/pyspec/eth2spec/gen_helpers/gen_base/dumper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from eth2spec.test import context
from eth_utils import encode_hex
from ruamel.yaml import YAML
from snappy import compress

from eth2spec.test import context

from .gen_typing import TestCase


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import threading
import time
import uuid

from typing import Any, Iterable

from pathos.multiprocessing import ProcessingPool as Pool
Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_typing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from dataclasses import dataclass
from pathlib import Path
from typing import (
Any,
Callable,
Expand All @@ -6,8 +8,6 @@
Optional,
Tuple,
)
from dataclasses import dataclass
from pathlib import Path

# Elements: name, out_kind, data
#
Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from pkgutil import walk_packages
from typing import Any, Iterable, Optional

from eth2spec.test.helpers.constants import ALL_PRESETS, TESTGEN_FORKS
from eth2spec.test.helpers.typing import SpecForkName, PresetBaseName
from eth2spec.gen_helpers.gen_base.gen_typing import TestCase
from eth2spec.test.helpers.constants import ALL_PRESETS, TESTGEN_FORKS
from eth2spec.test.helpers.typing import PresetBaseName, SpecForkName


def generate_case_fn(tfn, generator_mode, phase, preset, bls_active):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import random

from eth2spec.test.context import (
always_bls,
default_activation_threshold,
default_balances_electra,
single_phase,
spec_state_test,
spec_test,
with_altair_and_later,
with_custom_state,
with_presets,
)
from eth2spec.test.helpers.block import (
build_empty_block_for_next_slot,
)
from eth2spec.test.helpers.state import (
state_transition_and_sign_block,
transition_to,
next_epoch_via_block,
)
from eth2spec.test.helpers.constants import (
MAINNET,
MINIMAL,
)
from eth2spec.test.helpers.state import (
next_epoch_via_block,
state_transition_and_sign_block,
transition_to,
)
from eth2spec.test.helpers.sync_committee import (
compute_aggregate_sync_committee_signature,
compute_committee_indices,
run_sync_committee_processing,
run_successful_sync_committee_test,
run_sync_committee_processing,
)
from eth2spec.test.helpers.voluntary_exits import (
get_unslashed_exited_validators,
)
from eth2spec.test.context import (
with_altair_and_later,
with_presets,
spec_state_test,
always_bls,
single_phase,
with_custom_state,
spec_test,
default_balances_electra,
default_activation_threshold,
)


@with_altair_and_later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import random

from eth2spec.test.context import (
default_activation_threshold,
default_balances_electra,
misc_balances,
misc_balances_electra,
single_phase,
spec_state_test,
spec_test,
with_altair_and_later,
with_custom_state,
with_presets,
)
from eth2spec.test.helpers.constants import (
MAINNET,
MINIMAL,
Expand All @@ -16,18 +29,6 @@
from eth2spec.test.helpers.voluntary_exits import (
get_unslashed_exited_validators,
)
from eth2spec.test.context import (
with_altair_and_later,
spec_state_test,
default_activation_threshold,
misc_balances,
single_phase,
with_custom_state,
with_presets,
spec_test,
default_balances_electra,
misc_balances_electra,
)


def _test_harness_for_randomized_test_case(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from eth2spec.test.context import (
spec_state_test,
always_bls,
with_phases,
spec_state_test,
with_altair_and_later,
with_phases,
)
from eth2spec.test.helpers.constants import (
ALTAIR,
)


from eth2spec.test.helpers.deposits import (
run_deposit_processing_with_specific_fork_version,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
from random import Random

from eth2spec.test.context import spec_state_test, with_altair_and_later
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with
from eth2spec.test.helpers.inactivity_scores import (
randomize_inactivity_scores,
zero_inactivity_scores,
)
from eth2spec.test.helpers.state import (
next_epoch,
next_epoch_via_block,
set_full_participation,
set_empty_participation,
)
from eth2spec.test.helpers.voluntary_exits import exit_validators, get_exited_validators
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with
from eth2spec.test.helpers.random import (
randomize_attestation_participation,
randomize_previous_epoch_participation,
randomize_state,
)
from eth2spec.test.helpers.rewards import leaking
from eth2spec.test.helpers.state import (
next_epoch,
next_epoch_via_block,
set_empty_participation,
set_full_participation,
)
from eth2spec.test.helpers.voluntary_exits import exit_validators, get_exited_validators


def run_process_inactivity_updates(spec, state):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from random import Random

from eth2spec.test.helpers.constants import MINIMAL
from eth2spec.test.context import (
single_phase,
spec_state_test,
spec_test,
with_altair_and_later,
with_custom_state,
spec_test,
spec_state_test,
with_presets,
single_phase,
)
from eth2spec.test.helpers.state import next_epoch_via_block
from eth2spec.test.helpers.constants import MINIMAL
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with
from eth2spec.test.helpers.state import next_epoch_via_block


def get_full_flags(spec):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
from eth2spec.test.context import (
always_bls,
misc_balances,
single_phase,
spec_state_test,
spec_test,
with_altair_and_later,
with_presets,
with_custom_state,
single_phase,
misc_balances,
with_presets,
)
from eth2spec.test.helpers.constants import MINIMAL
from eth2spec.test.helpers.state import transition_to
from eth2spec.test.helpers.epoch_processing import (
run_epoch_processing_with,
)

from eth2spec.test.helpers.state import transition_to

#
# Note:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
from eth2spec.test.context import (
with_phases,
large_validator_set,
low_balances,
misc_balances,
spec_test,
with_custom_state,
with_phases,
with_presets,
spec_test,
with_state,
low_balances,
misc_balances,
large_validator_set,
)
from eth2spec.test.utils import with_meta_tags
from eth2spec.test.helpers.altair.fork import (
ALTAIR_FORK_TEST_META_TAGS,
run_fork_test,
)
from eth2spec.test.helpers.constants import (
PHASE0,
ALTAIR,
MINIMAL,
PHASE0,
)
from eth2spec.test.helpers.state import (
next_epoch,
next_epoch_via_block,
)
from eth2spec.test.helpers.altair.fork import (
ALTAIR_FORK_TEST_META_TAGS,
run_fork_test,
)
from eth2spec.test.utils import with_meta_tags


@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
Expand Down
Loading