diff --git a/Makefile b/Makefile index 1ede7fdbd9..f81657d86e 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 01167d9053..62060e68b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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", +] diff --git a/tests/core/pyspec/eth2spec/config/config_util.py b/tests/core/pyspec/eth2spec/config/config_util.py index f36e415460..92ab703f13 100644 --- a/tests/core/pyspec/eth2spec/config/config_util.py +++ b/tests/core/pyspec/eth2spec/config/config_util.py @@ -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 diff --git a/tests/core/pyspec/eth2spec/debug/decode.py b/tests/core/pyspec/eth2spec/debug/decode.py index 1a9d54a06d..f465f5515b 100644 --- a/tests/core/pyspec/eth2spec/debug/decode.py +++ b/tests/core/pyspec/eth2spec/debug/decode.py @@ -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, ) diff --git a/tests/core/pyspec/eth2spec/debug/encode.py b/tests/core/pyspec/eth2spec/debug/encode.py index 8bacf4d9a6..06f1272b38 100644 --- a/tests/core/pyspec/eth2spec/debug/encode.py +++ b/tests/core/pyspec/eth2spec/debug/encode.py @@ -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, ) diff --git a/tests/core/pyspec/eth2spec/debug/random_value.py b/tests/core/pyspec/eth2spec/debug/random_value.py index 9ea5909b92..ca1f3ee096 100644 --- a/tests/core/pyspec/eth2spec/debug/random_value.py +++ b/tests/core/pyspec/eth2spec/debug/random_value.py @@ -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 diff --git a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/dumper.py b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/dumper.py index 6e6d46306e..b8209eb839 100644 --- a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/dumper.py +++ b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/dumper.py @@ -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 diff --git a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py index aa50282fb4..931671a59c 100644 --- a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py +++ b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py @@ -3,7 +3,6 @@ import threading import time import uuid - from typing import Any, Iterable from pathos.multiprocessing import ProcessingPool as Pool diff --git a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_typing.py b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_typing.py index d8358486c7..26bfc8bc1c 100644 --- a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_typing.py +++ b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_typing.py @@ -1,3 +1,5 @@ +from dataclasses import dataclass +from pathlib import Path from typing import ( Any, Callable, @@ -6,8 +8,6 @@ Optional, Tuple, ) -from dataclasses import dataclass -from pathlib import Path # Elements: name, out_kind, data # diff --git a/tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/gen.py b/tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/gen.py index 24696119e9..b91403e301 100644 --- a/tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/gen.py +++ b/tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/gen.py @@ -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): diff --git a/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate.py b/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate.py index c585ca3d0d..3ae4061a36 100644 --- a/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate.py +++ b/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate.py @@ -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 diff --git a/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate_random.py b/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate_random.py index 538b19d97d..f83f7eb3e5 100644 --- a/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate_random.py +++ b/tests/core/pyspec/eth2spec/test/altair/block_processing/sync_aggregate/test_process_sync_aggregate_random.py @@ -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, @@ -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( diff --git a/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_deposit.py b/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_deposit.py index 25c2767269..81881c08dc 100644 --- a/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_deposit.py +++ b/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_deposit.py @@ -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, ) diff --git a/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_inactivity_updates.py b/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_inactivity_updates.py index bee7ce88c8..bfdff20a66 100644 --- a/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_inactivity_updates.py +++ b/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_inactivity_updates.py @@ -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): diff --git a/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_participation_flag_updates.py b/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_participation_flag_updates.py index 206fe9d7e4..049fda229b 100644 --- a/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_participation_flag_updates.py +++ b/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_participation_flag_updates.py @@ -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): diff --git a/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_sync_committee_updates.py b/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_sync_committee_updates.py index 8d808142e3..0a540b5d41 100644 --- a/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_sync_committee_updates.py +++ b/tests/core/pyspec/eth2spec/test/altair/epoch_processing/test_process_sync_committee_updates.py @@ -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: diff --git a/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_basic.py b/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_basic.py index 7e940ffb15..f02d7e3f5a 100644 --- a/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_basic.py @@ -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]) diff --git a/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_random.py b/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_random.py index a4b0de7ad1..32ba880f85 100644 --- a/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_random.py +++ b/tests/core/pyspec/eth2spec/test/altair/fork/test_altair_fork_random.py @@ -1,29 +1,29 @@ from random import Random 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.constants import ( - PHASE0, - ALTAIR, - MINIMAL, ) from eth2spec.test.helpers.altair.fork import ( ALTAIR_FORK_TEST_META_TAGS, run_fork_test, ) +from eth2spec.test.helpers.constants import ( + ALTAIR, + MINIMAL, + PHASE0, +) from eth2spec.test.helpers.random import ( - randomize_state, randomize_attestation_participation, + randomize_state, ) +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[PHASE0], other_phases=[ALTAIR]) diff --git a/tests/core/pyspec/eth2spec/test/altair/light_client/test_data_collection.py b/tests/core/pyspec/eth2spec/test/altair/light_client/test_data_collection.py index e407fcfbdc..64f9829e6a 100644 --- a/tests/core/pyspec/eth2spec/test/altair/light_client/test_data_collection.py +++ b/tests/core/pyspec/eth2spec/test/altair/light_client/test_data_collection.py @@ -1,12 +1,13 @@ from eth2spec.test.context import ( spec_state_test_with_matching_config, - with_presets, with_light_client, + with_presets, ) from eth2spec.test.helpers.constants import ( MINIMAL, ) from eth2spec.test.helpers.light_client_data_collection import ( + BlockID, add_new_block, finish_lc_data_collection_test, get_lc_bootstrap_block_id, @@ -17,7 +18,6 @@ get_light_client_update_for_period, select_new_head, setup_lc_data_collection_test, - BlockID, ) diff --git a/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py b/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py index 87217a3e0f..185c5fc5ee 100644 --- a/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py +++ b/tests/core/pyspec/eth2spec/test/altair/light_client/test_sync.py @@ -19,8 +19,8 @@ MINIMAL, ) from eth2spec.test.helpers.light_client import ( - get_sync_aggregate, compute_start_slot_at_next_sync_committee_period, + get_sync_aggregate, ) from eth2spec.test.helpers.light_client_sync import ( emit_force_update, diff --git a/tests/core/pyspec/eth2spec/test/altair/light_client/test_update_ranking.py b/tests/core/pyspec/eth2spec/test/altair/light_client/test_update_ranking.py index cfbe95f4e6..e8075dc9b3 100644 --- a/tests/core/pyspec/eth2spec/test/altair/light_client/test_update_ranking.py +++ b/tests/core/pyspec/eth2spec/test/altair/light_client/test_update_ranking.py @@ -1,7 +1,7 @@ from eth2spec.test.context import ( spec_state_test, - with_presets, with_light_client, + with_presets, ) from eth2spec.test.helpers.attestations import ( next_slots_with_attestations, diff --git a/tests/core/pyspec/eth2spec/test/altair/random/test_random.py b/tests/core/pyspec/eth2spec/test/altair/random/test_random.py index 995fc0a74d..9523447565 100644 --- a/tests/core/pyspec/eth2spec/test/altair/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/altair/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import ALTAIR from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import ALTAIR from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/altair/rewards/test_inactivity_scores.py b/tests/core/pyspec/eth2spec/test/altair/rewards/test_inactivity_scores.py index 5d1b7ffbf7..c2c1699677 100644 --- a/tests/core/pyspec/eth2spec/test/altair/rewards/test_inactivity_scores.py +++ b/tests/core/pyspec/eth2spec/test/altair/rewards/test_inactivity_scores.py @@ -1,17 +1,17 @@ from random import Random +import eth2spec.test.helpers.rewards as rewards_helpers from eth2spec.test.context import ( - with_altair_and_later, - spec_test, - spec_state_test, - with_custom_state, - single_phase, low_balances, misc_balances, + single_phase, + spec_state_test, + spec_test, + with_altair_and_later, + with_custom_state, ) from eth2spec.test.helpers.inactivity_scores import randomize_inactivity_scores from eth2spec.test.helpers.rewards import leaking -import eth2spec.test.helpers.rewards as rewards_helpers @with_altair_and_later diff --git a/tests/core/pyspec/eth2spec/test/altair/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/altair/sanity/test_blocks.py index caa30ae0b1..7be8ca714e 100644 --- a/tests/core/pyspec/eth2spec/test/altair/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/altair/sanity/test_blocks.py @@ -1,23 +1,23 @@ from random import Random -from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, - next_epoch, - set_full_participation_previous_epoch, +from eth2spec.test.context import ( + spec_state_test, + with_altair_and_later, ) from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, build_empty_block, + build_empty_block_for_next_slot, +) +from eth2spec.test.helpers.inactivity_scores import randomize_inactivity_scores +from eth2spec.test.helpers.rewards import leaking +from eth2spec.test.helpers.state import ( + next_epoch, + set_full_participation_previous_epoch, + state_transition_and_sign_block, ) from eth2spec.test.helpers.sync_committee import ( compute_aggregate_sync_committee_signature, ) -from eth2spec.test.context import ( - with_altair_and_later, - spec_state_test, -) -from eth2spec.test.helpers.rewards import leaking -from eth2spec.test.helpers.inactivity_scores import randomize_inactivity_scores def run_sync_committee_sanity_test(spec, state, fraction_full=1.0, rng=Random(454545)): diff --git a/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py b/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py index 09ba5828e8..e5c649660a 100644 --- a/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py +++ b/tests/core/pyspec/eth2spec/test/altair/transition/test_activations_and_exits.py @@ -1,9 +1,10 @@ import random + from eth2spec.test.context import ( - ForkMeta, ALTAIR, - with_presets, + ForkMeta, with_fork_metas, + with_presets, ) from eth2spec.test.helpers.constants import ( ALL_PRE_POST_FORKS, @@ -11,8 +12,8 @@ ) from eth2spec.test.helpers.fork_transition import ( do_fork, - transition_until_fork, transition_to_next_epoch_and_append_blocks, + transition_until_fork, ) from eth2spec.test.helpers.random import ( exit_random_validators, @@ -20,7 +21,6 @@ set_some_new_deposits, ) - # # Exit # diff --git a/tests/core/pyspec/eth2spec/test/altair/transition/test_leaking.py b/tests/core/pyspec/eth2spec/test/altair/transition/test_leaking.py index 8463e4fd52..f90ce0d103 100644 --- a/tests/core/pyspec/eth2spec/test/altair/transition/test_leaking.py +++ b/tests/core/pyspec/eth2spec/test/altair/transition/test_leaking.py @@ -7,8 +7,8 @@ ) from eth2spec.test.helpers.fork_transition import ( do_fork, - transition_until_fork, transition_to_next_epoch_and_append_blocks, + transition_until_fork, ) diff --git a/tests/core/pyspec/eth2spec/test/altair/transition/test_operations.py b/tests/core/pyspec/eth2spec/test/altair/transition/test_operations.py index 714d06f200..7953f95c10 100644 --- a/tests/core/pyspec/eth2spec/test/altair/transition/test_operations.py +++ b/tests/core/pyspec/eth2spec/test/altair/transition/test_operations.py @@ -13,7 +13,6 @@ run_transition_with_operation, ) - # # PROPOSER_SLASHING # diff --git a/tests/core/pyspec/eth2spec/test/altair/transition/test_slashing.py b/tests/core/pyspec/eth2spec/test/altair/transition/test_slashing.py index b35b974b60..697573e699 100644 --- a/tests/core/pyspec/eth2spec/test/altair/transition/test_slashing.py +++ b/tests/core/pyspec/eth2spec/test/altair/transition/test_slashing.py @@ -1,4 +1,5 @@ import random + from eth2spec.test.context import ( ForkMeta, with_fork_metas, diff --git a/tests/core/pyspec/eth2spec/test/altair/transition/test_transition.py b/tests/core/pyspec/eth2spec/test/altair/transition/test_transition.py index 77654db31a..4c5b17e9a7 100644 --- a/tests/core/pyspec/eth2spec/test/altair/transition/test_transition.py +++ b/tests/core/pyspec/eth2spec/test/altair/transition/test_transition.py @@ -1,18 +1,13 @@ import random + from eth2spec.test.context import ( ForkMeta, with_fork_metas, ) -from eth2spec.test.helpers.random import ( - randomize_state, -) +from eth2spec.test.helpers.attestations import next_slots_with_attestations from eth2spec.test.helpers.constants import ( ALL_PRE_POST_FORKS, ) -from eth2spec.test.helpers.state import ( - next_epoch_via_signed_block, -) -from eth2spec.test.helpers.attestations import next_slots_with_attestations from eth2spec.test.helpers.fork_transition import ( do_fork, no_blocks, @@ -22,6 +17,12 @@ transition_to_next_epoch_and_append_blocks, transition_until_fork, ) +from eth2spec.test.helpers.random import ( + randomize_state, +) +from eth2spec.test.helpers.state import ( + next_epoch_via_signed_block, +) @with_fork_metas( diff --git a/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py b/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py index 652d6a2d9a..cef9f4177d 100644 --- a/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py +++ b/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py @@ -2,8 +2,8 @@ from eth2spec.test.context import ( spec_state_test_with_matching_config, - with_presets, with_light_client, + with_presets, ) from eth2spec.test.helpers.attestations import ( next_epoch_with_attestations, diff --git a/tests/core/pyspec/eth2spec/test/altair/unittests/test_config_override.py b/tests/core/pyspec/eth2spec/test/altair/unittests/test_config_override.py index 212250fc41..7c2e999cf5 100644 --- a/tests/core/pyspec/eth2spec/test/altair/unittests/test_config_override.py +++ b/tests/core/pyspec/eth2spec/test/altair/unittests/test_config_override.py @@ -9,10 +9,10 @@ with_state, ) from eth2spec.test.helpers.constants import ( - PHASE0, + ALL_PHASES, ALTAIR, BELLATRIX, - ALL_PHASES, + PHASE0, ) from eth2spec.test.helpers.forks import is_post_fork diff --git a/tests/core/pyspec/eth2spec/test/altair/unittests/validator/test_validator.py b/tests/core/pyspec/eth2spec/test/altair/unittests/validator/test_validator.py index 52be98d095..4bd095464c 100644 --- a/tests/core/pyspec/eth2spec/test/altair/unittests/validator/test_validator.py +++ b/tests/core/pyspec/eth2spec/test/altair/unittests/validator/test_validator.py @@ -1,24 +1,25 @@ import random from collections import defaultdict -from eth2spec.utils.ssz.ssz_typing import Bitvector -from eth2spec.utils import bls -from eth2spec.test.helpers.block import build_empty_block -from eth2spec.test.helpers.keys import pubkey_to_privkey, privkeys, pubkeys -from eth2spec.test.helpers.state import transition_to -from eth2spec.test.helpers.sync_committee import compute_sync_committee_signature + from eth2spec.test.context import ( always_bls, spec_state_test, + with_all_phases_from_except, with_altair_and_later, with_presets, - with_all_phases_from_except, ) +from eth2spec.test.helpers.block import build_empty_block from eth2spec.test.helpers.constants import ( - MAINNET, - MINIMAL, ALTAIR, EIP7805, + MAINNET, + MINIMAL, ) +from eth2spec.test.helpers.keys import privkeys, pubkey_to_privkey, pubkeys +from eth2spec.test.helpers.state import transition_to +from eth2spec.test.helpers.sync_committee import compute_sync_committee_signature +from eth2spec.utils import bls +from eth2spec.utils.ssz.ssz_typing import Bitvector rng = random.Random(1337) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_deposit.py b/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_deposit.py index 9ab578663f..d3751cab11 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_deposit.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_deposit.py @@ -1,6 +1,6 @@ from eth2spec.test.context import ( - spec_state_test, always_bls, + spec_state_test, with_bellatrix_and_later, ) from eth2spec.test.helpers.deposits import ( diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_execution_payload.py b/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_execution_payload.py index 32acbf0ec0..3e202e20c7 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_execution_payload.py @@ -1,13 +1,5 @@ from random import Random -from eth2spec.test.helpers.execution_payload import ( - build_empty_execution_payload, - build_randomized_execution_payload, - compute_el_block_hash, - get_execution_payload_header, - build_state_with_incomplete_transition, - build_state_with_complete_transition, -) from eth2spec.test.context import ( BELLATRIX, expect_assertion_error, @@ -16,9 +8,17 @@ with_bellatrix_until_eip7732, with_phases, ) +from eth2spec.test.helpers.execution_payload import ( + build_empty_execution_payload, + build_randomized_execution_payload, + build_state_with_complete_transition, + build_state_with_incomplete_transition, + compute_el_block_hash, + get_execution_payload_header, +) +from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.state import next_slot -from eth2spec.test.helpers.forks import is_post_eip7732 def run_execution_payload_processing( diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_voluntary_exit.py b/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_voluntary_exit.py index 2754068f2b..99a81ee15f 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_voluntary_exit.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_voluntary_exit.py @@ -1,6 +1,6 @@ from eth2spec.test.context import ( - spec_state_test, always_bls, + spec_state_test, with_bellatrix_and_later, with_phases, ) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_basic.py b/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_basic.py index 3cf7f23bff..23d6a6d766 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_basic.py @@ -1,14 +1,17 @@ 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.bellatrix.fork import ( + BELLATRIX_FORK_TEST_META_TAGS, + run_fork_test, +) from eth2spec.test.helpers.constants import ( ALTAIR, BELLATRIX, @@ -18,10 +21,7 @@ next_epoch, next_epoch_via_block, ) -from eth2spec.test.helpers.bellatrix.fork import ( - BELLATRIX_FORK_TEST_META_TAGS, - run_fork_test, -) +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[ALTAIR], other_phases=[BELLATRIX]) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_random.py b/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_random.py index d2800df439..778a333712 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_random.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/fork/test_bellatrix_fork_random.py @@ -1,26 +1,26 @@ from random import Random 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.bellatrix.fork import ( + BELLATRIX_FORK_TEST_META_TAGS, + run_fork_test, +) from eth2spec.test.helpers.constants import ( ALTAIR, BELLATRIX, MINIMAL, ) -from eth2spec.test.helpers.bellatrix.fork import ( - BELLATRIX_FORK_TEST_META_TAGS, - run_fork_test, -) from eth2spec.test.helpers.random import randomize_state +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[ALTAIR], other_phases=[BELLATRIX]) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_on_merge_block.py b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_on_merge_block.py index fb072c506b..bc7d473d1d 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_on_merge_block.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_on_merge_block.py @@ -1,29 +1,25 @@ -from eth2spec.utils.ssz.ssz_typing import uint256 +from eth2spec.test.context import BELLATRIX, spec_state_test, with_phases from eth2spec.test.exceptions import BlockNotFoundException -from eth2spec.test.context import spec_state_test, with_phases, BELLATRIX from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) from eth2spec.test.helpers.execution_payload import ( + build_state_with_incomplete_transition, compute_el_block_hash, ) from eth2spec.test.helpers.fork_choice import ( + add_pow_block, get_genesis_forkchoice_store_and_block, on_tick_and_append_step, tick_and_add_block, ) -from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, -) -from eth2spec.test.helpers.fork_choice import ( - add_pow_block, -) from eth2spec.test.helpers.pow_block import ( prepare_random_pow_block, ) -from eth2spec.test.helpers.execution_payload import ( - build_state_with_incomplete_transition, +from eth2spec.test.helpers.state import ( + state_transition_and_sign_block, ) +from eth2spec.utils.ssz.ssz_typing import uint256 def with_pow_block_patch(spec, blocks, func): diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py index 96be0a9330..88a17c7960 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py @@ -3,15 +3,15 @@ with_bellatrix_until_eip7732, with_presets, ) -from eth2spec.test.helpers.constants import ( - MINIMAL, -) from eth2spec.test.helpers.attestations import ( get_valid_attestations_at_slot, ) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) +from eth2spec.test.helpers.constants import ( + MINIMAL, +) from eth2spec.test.helpers.fork_choice import ( apply_next_epoch_with_attestations, apply_next_slots_with_attestations, @@ -22,9 +22,9 @@ tick_and_run_on_attestation, ) from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, next_epoch, next_slot, + state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/random/test_random.py b/tests/core/pyspec/eth2spec/test/bellatrix/random/test_random.py index 51d27954b0..3cd6d78f07 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import BELLATRIX from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import BELLATRIX from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/bellatrix/sanity/test_blocks.py index d13d9f905f..399b6dab45 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/sanity/test_blocks.py @@ -1,15 +1,16 @@ from random import Random -from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, - next_slot, -) -from eth2spec.test.helpers.block import build_empty_block_for_next_slot -from eth2spec.test.helpers.execution_payload import build_randomized_execution_payload + from eth2spec.test.context import ( BELLATRIX, + spec_state_test, with_bellatrix_until_eip7732, with_phases, - spec_state_test, +) +from eth2spec.test.helpers.block import build_empty_block_for_next_slot +from eth2spec.test.helpers.execution_payload import build_randomized_execution_payload +from eth2spec.test.helpers.state import ( + next_slot, + state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/sync/test_optimistic.py b/tests/core/pyspec/eth2spec/test/bellatrix/sync/test_optimistic.py index 5ebd4d940a..79f2c385b9 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/sync/test_optimistic.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/sync/test_optimistic.py @@ -16,9 +16,9 @@ on_tick_and_append_step, ) from eth2spec.test.helpers.optimistic_sync import ( + MegaStore, PayloadStatusV1, PayloadStatusV1Status, - MegaStore, add_optimistic_block, get_optimistic_store, ) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_is_valid_terminal_pow_block.py b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_is_valid_terminal_pow_block.py index 8109d92d7c..826a489cb2 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_is_valid_terminal_pow_block.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_is_valid_terminal_pow_block.py @@ -1,11 +1,11 @@ -from eth2spec.utils.ssz.ssz_typing import uint256 -from eth2spec.test.helpers.pow_block import ( - prepare_random_pow_block, -) from eth2spec.test.context import ( spec_state_test, with_bellatrix_and_later, ) +from eth2spec.test.helpers.pow_block import ( + prepare_random_pow_block, +) +from eth2spec.utils.ssz.ssz_typing import uint256 @with_bellatrix_and_later diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_transition.py b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_transition.py index f78a2d653c..6211f60cd8 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_transition.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_transition.py @@ -1,13 +1,13 @@ -from eth2spec.test.helpers.execution_payload import ( - build_empty_execution_payload, - build_state_with_incomplete_transition, - build_state_with_complete_transition, -) from eth2spec.test.context import ( spec_state_test, with_bellatrix_and_later, with_bellatrix_until_eip7732, ) +from eth2spec.test.helpers.execution_payload import ( + build_empty_execution_payload, + build_state_with_complete_transition, + build_state_with_incomplete_transition, +) @with_bellatrix_and_later diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_validate_merge_block.py b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_validate_merge_block.py index cafec07d13..7ae4813a99 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_validate_merge_block.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_validate_merge_block.py @@ -1,5 +1,10 @@ from typing import Optional -from eth2spec.utils.ssz.ssz_typing import uint256, Bytes32 + +from eth2spec.test.context import ( + spec_configured_state_test, + spec_state_test, + with_bellatrix_and_later, +) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) @@ -7,16 +12,11 @@ build_empty_execution_payload, compute_el_block_hash, ) +from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.pow_block import ( prepare_random_pow_chain, ) -from eth2spec.test.helpers.forks import is_post_eip7732 -from eth2spec.test.context import ( - spec_state_test, - with_bellatrix_and_later, - spec_configured_state_test, -) - +from eth2spec.utils.ssz.ssz_typing import Bytes32, uint256 TERMINAL_BLOCK_HASH_CONFIG_VAR = ( "0x0000000000000000000000000000000000000000000000000000000000000001" diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/validator/test_validator.py b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/validator/test_validator.py index 71fee1170d..42765bb7cf 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/unittests/validator/test_validator.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/unittests/validator/test_validator.py @@ -1,18 +1,17 @@ from copy import deepcopy from typing import Optional -from eth2spec.test.helpers.pow_block import ( - prepare_random_pow_chain, +from eth2spec.test.context import ( + spec_state_test, + with_phases, ) from eth2spec.test.helpers.constants import ( BELLATRIX, ) -from eth2spec.test.context import ( - spec_state_test, - with_phases, +from eth2spec.test.helpers.pow_block import ( + prepare_random_pow_chain, ) - # For test_get_pow_block_at_terminal_total_difficulty IS_HEAD_BLOCK = "is_head_block" IS_HEAD_PARENT_BLOCK = "is_head_parent_block" diff --git a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_bls_to_execution_change.py b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_bls_to_execution_change.py index 64ea413221..53cba585a6 100644 --- a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_bls_to_execution_change.py +++ b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_bls_to_execution_change.py @@ -1,14 +1,14 @@ -from eth2spec.test.helpers.keys import pubkeys -from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change -from eth2spec.test.helpers.constants import CAPELLA, MAINNET from eth2spec.test.context import ( always_bls, expect_assertion_error, spec_state_test, with_capella_and_later, - with_presets, with_phases, + with_presets, ) +from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change +from eth2spec.test.helpers.constants import CAPELLA, MAINNET +from eth2spec.test.helpers.keys import pubkeys def run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=True): diff --git a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py index de455bacb1..39d7eff2d1 100644 --- a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py +++ b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py @@ -2,12 +2,12 @@ spec_state_test, with_capella_until_eip7732, ) -from eth2spec.test.helpers.forks import is_post_electra -from eth2spec.test.helpers.state import next_epoch_via_block from eth2spec.test.helpers.deposits import ( prepare_state_and_deposit, run_deposit_processing, ) +from eth2spec.test.helpers.forks import is_post_electra +from eth2spec.test.helpers.state import next_epoch_via_block from eth2spec.test.helpers.withdrawals import set_validator_fully_withdrawable diff --git a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_execution_payload.py b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_execution_payload.py index 223931585f..4b8df432eb 100644 --- a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_execution_payload.py @@ -1,16 +1,16 @@ -from eth2spec.test.helpers.execution_payload import ( - build_empty_execution_payload, - compute_el_block_hash, - build_state_with_incomplete_transition, +from eth2spec.test.bellatrix.block_processing.test_process_execution_payload import ( + run_execution_payload_processing, ) from eth2spec.test.context import ( spec_state_test, with_capella_and_later, ) -from eth2spec.test.helpers.state import next_slot -from eth2spec.test.bellatrix.block_processing.test_process_execution_payload import ( - run_execution_payload_processing, +from eth2spec.test.helpers.execution_payload import ( + build_empty_execution_payload, + build_state_with_incomplete_transition, + compute_el_block_hash, ) +from eth2spec.test.helpers.state import next_slot @with_capella_and_later diff --git a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_withdrawals.py b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_withdrawals.py index 1f1cd72c36..cbd0f641db 100644 --- a/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_withdrawals.py +++ b/tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_withdrawals.py @@ -2,9 +2,9 @@ from eth2spec.test.context import ( spec_state_test, - with_presets, with_capella_and_later, with_capella_until_eip7732, + with_presets, ) from eth2spec.test.helpers.constants import MAINNET, MINIMAL from eth2spec.test.helpers.execution_payload import ( @@ -21,10 +21,10 @@ from eth2spec.test.helpers.withdrawals import ( get_expected_withdrawals, prepare_expected_withdrawals, + run_withdrawals_processing, set_eth1_withdrawal_credential_with_balance, set_validator_fully_withdrawable, set_validator_partially_withdrawable, - run_withdrawals_processing, ) diff --git a/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_basic.py b/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_basic.py index 1ad4428195..85918bf6ed 100644 --- a/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_basic.py @@ -1,14 +1,17 @@ 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.capella.fork import ( + CAPELLA_FORK_TEST_META_TAGS, + run_fork_test, +) from eth2spec.test.helpers.constants import ( BELLATRIX, CAPELLA, @@ -18,10 +21,7 @@ next_epoch, next_epoch_via_block, ) -from eth2spec.test.helpers.capella.fork import ( - CAPELLA_FORK_TEST_META_TAGS, - run_fork_test, -) +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[BELLATRIX], other_phases=[CAPELLA]) diff --git a/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_random.py b/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_random.py index a5c53c2205..b3cdb9ba2b 100644 --- a/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_random.py +++ b/tests/core/pyspec/eth2spec/test/capella/fork/test_capella_fork_random.py @@ -1,26 +1,26 @@ from random import Random 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.capella.fork import ( + CAPELLA_FORK_TEST_META_TAGS, + run_fork_test, +) from eth2spec.test.helpers.constants import ( BELLATRIX, CAPELLA, MINIMAL, ) -from eth2spec.test.helpers.capella.fork import ( - CAPELLA_FORK_TEST_META_TAGS, - run_fork_test, -) from eth2spec.test.helpers.random import randomize_state +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[BELLATRIX], other_phases=[CAPELLA]) diff --git a/tests/core/pyspec/eth2spec/test/capella/random/test_random.py b/tests/core/pyspec/eth2spec/test/capella/random/test_random.py index ac3a9aee5e..386b26893e 100644 --- a/tests/core/pyspec/eth2spec/test/capella/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/capella/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import CAPELLA from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import CAPELLA from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/capella/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/capella/sanity/test_blocks.py index 92700bb7e3..345010136e 100644 --- a/tests/core/pyspec/eth2spec/test/capella/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/capella/sanity/test_blocks.py @@ -1,39 +1,39 @@ import random -from eth2spec.test.helpers.constants import MINIMAL -from eth2spec.test.helpers.forks import is_post_electra, is_post_eip7732 + from eth2spec.test.context import ( + spec_state_test, with_capella_and_later, with_capella_until_eip7732, - spec_state_test, with_presets, ) -from eth2spec.test.helpers.keys import pubkeys -from eth2spec.test.helpers.state import ( - next_epoch_via_block, - state_transition_and_sign_block, - transition_to, - next_slot, +from eth2spec.test.helpers.attestations import ( + next_epoch_with_attestations, ) from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, build_empty_block, + build_empty_block_for_next_slot, ) from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change -from eth2spec.test.helpers.attestations import ( - next_epoch_with_attestations, +from eth2spec.test.helpers.constants import MINIMAL +from eth2spec.test.helpers.deposits import ( + prepare_state_and_deposit, +) +from eth2spec.test.helpers.forks import is_post_eip7732, is_post_electra +from eth2spec.test.helpers.keys import pubkeys +from eth2spec.test.helpers.state import ( + next_epoch_via_block, + next_slot, + state_transition_and_sign_block, + transition_to, ) +from eth2spec.test.helpers.voluntary_exits import prepare_signed_exits from eth2spec.test.helpers.withdrawals import ( get_expected_withdrawals, + prepare_expected_withdrawals, set_eth1_withdrawal_credential_with_balance, set_validator_fully_withdrawable, set_validator_partially_withdrawable, - prepare_expected_withdrawals, -) -from eth2spec.test.helpers.deposits import ( - prepare_state_and_deposit, ) -from eth2spec.test.helpers.voluntary_exits import prepare_signed_exits - # # `is_execution_enabled` has been removed from Capella diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index feae92701a..27a9858bd5 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -1,46 +1,45 @@ -import pytest +import importlib from copy import deepcopy from dataclasses import dataclass -import importlib +from random import Random +from typing import Any, Callable, Dict, Sequence + +import pytest +from lru import LRU from eth2spec.utils import bls from .exceptions import SkippedTest from .helpers.constants import ( - PHASE0, + ALL_PHASES, + ALLOWED_TEST_RUNNER_FORKS, ALTAIR, BELLATRIX, CAPELLA, DENEB, - ELECTRA, - FULU, EIP7441, EIP7732, + ELECTRA, + FULU, + LIGHT_CLIENT_TESTING_FORKS, MINIMAL, - ALL_PHASES, + PHASE0, POST_FORK_OF, - ALLOWED_TEST_RUNNER_FORKS, - LIGHT_CLIENT_TESTING_FORKS, ) -from .helpers.forks import is_post_fork, is_post_electra +from .helpers.forks import is_post_electra, is_post_fork from .helpers.genesis import create_genesis_state +from .helpers.specs import ( + spec_targets, +) from .helpers.typing import ( Spec, SpecForks, ) -from .helpers.specs import ( - spec_targets, -) from .utils import ( vector_test, with_meta_tags, ) -from random import Random -from typing import Any, Callable, Sequence, Dict - -from lru import LRU - # Without pytest CLI arg or pyspec-test-generator 'preset' argument, this will be the config to apply. DEFAULT_TEST_PRESET = MINIMAL diff --git a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py index b089a63f84..624b461c85 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py @@ -1,21 +1,21 @@ from random import Random -from eth2spec.test.helpers.execution_payload import ( - build_empty_execution_payload, - compute_el_block_hash, - get_execution_payload_header, -) from eth2spec.test.context import ( - spec_state_test, expect_assertion_error, + spec_state_test, with_deneb_and_later, ) -from eth2spec.test.helpers.keys import privkeys -from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, get_max_blob_count, + get_sample_blob_tx, ) +from eth2spec.test.helpers.execution_payload import ( + build_empty_execution_payload, + compute_el_block_hash, + get_execution_payload_header, +) +from eth2spec.test.helpers.forks import is_post_eip7732 +from eth2spec.test.helpers.keys import privkeys def run_execution_payload_processing( diff --git a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_voluntary_exit.py b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_voluntary_exit.py index b01eaab0e1..12daf3b065 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_voluntary_exit.py +++ b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_voluntary_exit.py @@ -1,3 +1,6 @@ +from eth2spec.test.bellatrix.block_processing.test_process_voluntary_exit import ( + run_voluntary_exit_processing_test, +) from eth2spec.test.context import ( always_bls, spec_state_test, @@ -6,9 +9,6 @@ from eth2spec.test.helpers.constants import ( DENEB, ) -from eth2spec.test.bellatrix.block_processing.test_process_voluntary_exit import ( - run_voluntary_exit_processing_test, -) @with_deneb_and_later diff --git a/tests/core/pyspec/eth2spec/test/deneb/epoch_processing/test_process_registry_updates.py b/tests/core/pyspec/eth2spec/test/deneb/epoch_processing/test_process_registry_updates.py index a4db24c193..de81a4353e 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/epoch_processing/test_process_registry_updates.py +++ b/tests/core/pyspec/eth2spec/test/deneb/epoch_processing/test_process_registry_updates.py @@ -1,17 +1,17 @@ -from eth2spec.test.helpers.keys import pubkeys -from eth2spec.test.helpers.forks import is_post_electra -from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.context import ( - with_deneb_and_later, - spec_test, - spec_state_test, + scaled_churn_balances_equal_activation_churn_limit, + scaled_churn_balances_exceed_activation_churn_limit, single_phase, + spec_state_test, + spec_test, with_custom_state, + with_deneb_and_later, with_presets, - scaled_churn_balances_exceed_activation_churn_limit, - scaled_churn_balances_equal_activation_churn_limit, ) +from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with +from eth2spec.test.helpers.forks import is_post_electra +from eth2spec.test.helpers.keys import pubkeys def run_process_registry_updates(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_basic.py b/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_basic.py index 4f5a9afbaa..17f5dbf458 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_basic.py @@ -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.constants import ( CAPELLA, DENEB, MINIMAL, ) -from eth2spec.test.helpers.state import ( - next_epoch, - next_epoch_via_block, -) from eth2spec.test.helpers.deneb.fork import ( DENEB_FORK_TEST_META_TAGS, run_fork_test, ) +from eth2spec.test.helpers.state import ( + next_epoch, + next_epoch_via_block, +) +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[CAPELLA], other_phases=[DENEB]) diff --git a/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_random.py b/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_random.py index ae130110d3..558706806b 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_random.py +++ b/tests/core/pyspec/eth2spec/test/deneb/fork/test_deneb_fork_random.py @@ -1,16 +1,15 @@ from random import Random 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.constants import ( CAPELLA, DENEB, @@ -21,6 +20,7 @@ run_fork_test, ) from eth2spec.test.helpers.random import randomize_state +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[CAPELLA], other_phases=[DENEB]) diff --git a/tests/core/pyspec/eth2spec/test/deneb/fork_choice/test_on_block.py b/tests/core/pyspec/eth2spec/test/deneb/fork_choice/test_on_block.py index 442d993a1d..4b5cdbc1ce 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/fork_choice/test_on_block.py +++ b/tests/core/pyspec/eth2spec/test/deneb/fork_choice/test_on_block.py @@ -4,16 +4,17 @@ spec_state_test, with_all_phases_from_except, ) - -from eth2spec.test.helpers.constants import ( - DENEB, - FULU, - EIP7732, +from eth2spec.test.helpers.blob import ( + get_sample_blob_tx, ) - from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) +from eth2spec.test.helpers.constants import ( + DENEB, + EIP7732, + FULU, +) from eth2spec.test.helpers.execution_payload import ( compute_el_block_hash, ) @@ -26,9 +27,6 @@ from eth2spec.test.helpers.state import ( state_transition_and_sign_block, ) -from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, -) def get_block_with_blob(spec, state, rng=None): diff --git a/tests/core/pyspec/eth2spec/test/deneb/merkle_proof/test_single_merkle_proof.py b/tests/core/pyspec/eth2spec/test/deneb/merkle_proof/test_single_merkle_proof.py index 3742716462..549ff3ad1e 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/merkle_proof/test_single_merkle_proof.py +++ b/tests/core/pyspec/eth2spec/test/deneb/merkle_proof/test_single_merkle_proof.py @@ -1,10 +1,17 @@ import random +from eth2spec.debug.random_value import ( + RandomizationMode, + get_random_ssz_object, +) from eth2spec.test.context import ( spec_state_test, with_deneb_and_later, with_test_suite_name, ) +from eth2spec.test.helpers.blob import ( + get_sample_blob_tx, +) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, sign_block, @@ -13,13 +20,6 @@ compute_el_block_hash, ) from eth2spec.test.helpers.forks import is_post_eip7732 -from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, -) -from eth2spec.debug.random_value import ( - RandomizationMode, - get_random_ssz_object, -) def _run_blob_kzg_commitment_merkle_proof_test(spec, state, rng=None): diff --git a/tests/core/pyspec/eth2spec/test/deneb/random/test_random.py b/tests/core/pyspec/eth2spec/test/deneb/random/test_random.py index fef3810fa3..461b30db20 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/deneb/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import DENEB from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import DENEB from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py index 1cf5437966..7df22dac9d 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py @@ -1,22 +1,22 @@ import random -from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, -) -from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, -) from eth2spec.test.context import ( spec_state_test, with_deneb_until_eip7732, ) +from eth2spec.test.helpers.blob import ( + get_max_blob_count, + get_sample_blob_tx, +) +from eth2spec.test.helpers.block import ( + build_empty_block_for_next_slot, +) from eth2spec.test.helpers.execution_payload import ( compute_el_block_hash, get_random_tx, ) -from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, - get_max_blob_count, +from eth2spec.test.helpers.state import ( + state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py b/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py index ad62b8d464..83e701fe2e 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py +++ b/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py @@ -13,18 +13,17 @@ AFTER_DENEB_PRE_POST_FORKS, DENEB, ) -from eth2spec.test.helpers.state import ( - next_epoch_via_block, - state_transition_and_sign_block, - transition_to, -) from eth2spec.test.helpers.fork_transition import ( OperationType, do_fork, run_transition_with_operation, transition_until_fork, ) - +from eth2spec.test.helpers.state import ( + next_epoch_via_block, + state_transition_and_sign_block, + transition_to, +) # # BLSToExecutionChange diff --git a/tests/core/pyspec/eth2spec/test/deneb/transition/test_transition.py b/tests/core/pyspec/eth2spec/test/deneb/transition/test_transition.py index 9031b2e84e..5c1b42288f 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/transition/test_transition.py +++ b/tests/core/pyspec/eth2spec/test/deneb/transition/test_transition.py @@ -7,12 +7,12 @@ AFTER_DENEB_PRE_POST_FORKS, MINIMAL, ) -from eth2spec.test.helpers.keys import pubkeys from eth2spec.test.helpers.fork_transition import ( do_fork, transition_to_next_epoch_and_append_blocks, transition_until_fork, ) +from eth2spec.test.helpers.keys import pubkeys def mock_activated_validators(spec, state, mock_activations): diff --git a/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py b/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py index 7e225b57fc..aa72570715 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py +++ b/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py @@ -1,16 +1,16 @@ import random from eth2spec.test.context import ( - spec_test, + always_bls, + expect_assertion_error, single_phase, + spec_test, with_deneb_and_later, - expect_assertion_error, - always_bls, ) from eth2spec.test.helpers.blob import ( - get_sample_blob, - get_poly_in_both_forms, eval_poly_in_coeff_form, + get_poly_in_both_forms, + get_sample_blob, ) from eth2spec.utils import bls from eth2spec.utils.bls import BLS_MODULUS diff --git a/tests/core/pyspec/eth2spec/test/deneb/unittests/test_execution_engine_interface.py b/tests/core/pyspec/eth2spec/test/deneb/unittests/test_execution_engine_interface.py index b2ec5a6adf..c877ee488c 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/unittests/test_execution_engine_interface.py +++ b/tests/core/pyspec/eth2spec/test/deneb/unittests/test_execution_engine_interface.py @@ -1,8 +1,8 @@ from eth2spec.test.context import ( DENEB, spec_state_test, - with_phases, with_deneb_and_later, + with_phases, ) from eth2spec.test.helpers.execution_payload import ( build_empty_execution_payload, diff --git a/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py b/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py index 6f1deedcb8..7a0ff4d794 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py +++ b/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py @@ -1,16 +1,17 @@ import random + from eth2spec.test.context import ( spec_state_test, with_deneb_and_later, ) -from eth2spec.test.helpers.execution_payload import ( - compute_el_block_hash, -) -from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.blob import ( get_sample_blob_tx, ) from eth2spec.test.helpers.block import build_empty_block_for_next_slot, sign_block +from eth2spec.test.helpers.execution_payload import ( + compute_el_block_hash, +) +from eth2spec.test.helpers.forks import is_post_eip7732 def _get_sample_sidecars(spec, state, rng): diff --git a/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_opening_proof.py b/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_opening_proof.py index 19b0125f12..ea8f240358 100644 --- a/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_opening_proof.py +++ b/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_opening_proof.py @@ -1,4 +1,4 @@ -from eth2spec.test.context import spec_state_test, with_eip7441_and_later, expect_assertion_error +from eth2spec.test.context import expect_assertion_error, spec_state_test, with_eip7441_and_later from eth2spec.test.helpers.eip7441 import ( compute_whisk_k_commitment, compute_whisk_tracker, diff --git a/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_registration.py b/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_registration.py index caea59dc44..49ffb2c40e 100644 --- a/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_registration.py +++ b/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_eip7441_registration.py @@ -1,9 +1,9 @@ -from eth2spec.test.context import spec_state_test, with_eip7441_and_later, expect_assertion_error +from eth2spec.test.context import expect_assertion_error, spec_state_test, with_eip7441_and_later from eth2spec.test.helpers.eip7441 import ( - set_as_first_proposal, compute_whisk_k_commitment, - set_registration, register_tracker, + set_as_first_proposal, + set_registration, ) diff --git a/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_shuffled_trackers.py b/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_shuffled_trackers.py index 23e3501bdf..24cbed2cdf 100644 --- a/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_shuffled_trackers.py +++ b/tests/core/pyspec/eth2spec/test/eip7441/block_processing/test_process_shuffled_trackers.py @@ -1,8 +1,9 @@ -from eth2spec.test.context import spec_state_test, with_eip7441_and_later, expect_assertion_error -from eth2spec.test.helpers.keys import whisk_ks_initial -from eth2spec.test.helpers.eip7441 import compute_whisk_tracker from curdleproofs import GenerateWhiskShuffleProof +from eth2spec.test.context import expect_assertion_error, spec_state_test, with_eip7441_and_later +from eth2spec.test.helpers.eip7441 import compute_whisk_tracker +from eth2spec.test.helpers.keys import whisk_ks_initial + def set_correct_shuffle_proofs(spec, state, body): pre_shuffle_trackers = get_and_populate_pre_shuffle_trackers(spec, state, body) diff --git a/tests/core/pyspec/eth2spec/test/eip7441/sanity/blocks/test_eip7441.py b/tests/core/pyspec/eth2spec/test/eip7441/sanity/blocks/test_eip7441.py index f2118c8e3b..c856feefbd 100644 --- a/tests/core/pyspec/eth2spec/test/eip7441/sanity/blocks/test_eip7441.py +++ b/tests/core/pyspec/eth2spec/test/eip7441/sanity/blocks/test_eip7441.py @@ -1,9 +1,10 @@ -from eth2spec.test.helpers.block import build_empty_block +from curdleproofs import WhiskTracker + from eth2spec.test.context import spec_state_test, with_eip7441_and_later +from eth2spec.test.helpers.block import build_empty_block +from eth2spec.test.helpers.eip7441 import compute_whisk_tracker_and_commitment from eth2spec.test.helpers.keys import whisk_ks_initial from eth2spec.test.helpers.state import state_transition_and_sign_block -from eth2spec.test.helpers.eip7441 import compute_whisk_tracker_and_commitment -from curdleproofs import WhiskTracker known_whisk_trackers = {} diff --git a/tests/core/pyspec/eth2spec/test/eip7441/unittests/test_config_invariants.py b/tests/core/pyspec/eth2spec/test/eip7441/unittests/test_config_invariants.py index e94df3b8b3..9f615ba2e0 100644 --- a/tests/core/pyspec/eth2spec/test/eip7441/unittests/test_config_invariants.py +++ b/tests/core/pyspec/eth2spec/test/eip7441/unittests/test_config_invariants.py @@ -1,5 +1,4 @@ -from eth2spec.test.context import spec_test, with_eip7441_and_later -from eth2spec.test.context import single_phase +from eth2spec.test.context import single_phase, spec_test, with_eip7441_and_later # Note: remove once whisk is rebased on top of deneb diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_attestation.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_attestation.py index df10ce5203..bae9c546a9 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_attestation.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_attestation.py @@ -1,4 +1,3 @@ -from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.context import ( always_bls, spec_state_test, @@ -6,13 +5,14 @@ with_presets, ) from eth2spec.test.helpers.attestations import ( - run_attestation_processing, - get_valid_attestation, - sign_attestation, build_attestation_data, - get_valid_attestation_at_slot, get_empty_eip7549_aggregation_bits, + get_valid_attestation, + get_valid_attestation_at_slot, + run_attestation_processing, + sign_attestation, ) +from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.state import ( next_slots, ) diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py index 2e2ae2a7d6..3afa3cb210 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py @@ -1,18 +1,18 @@ -from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.context import ( - with_electra_and_later, - with_presets, - spec_test, - single_phase, - with_custom_state, - scaled_churn_balances_exceed_activation_exit_churn_limit, default_activation_threshold, + scaled_churn_balances_exceed_activation_exit_churn_limit, + single_phase, spec_state_test, + spec_test, + with_custom_state, + with_electra_and_later, + with_presets, ) +from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.withdrawals import ( - set_eth1_withdrawal_credential_with_balance, - set_compounding_withdrawal_credential_with_balance, set_compounding_withdrawal_credential, + set_compounding_withdrawal_credential_with_balance, + set_eth1_withdrawal_credential_with_balance, ) # *********************** diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_request.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_request.py index a787b57f87..480b6dafe5 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_request.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_request.py @@ -1,4 +1,4 @@ -from eth2spec.test.context import spec_state_test, always_bls, with_electra_and_later +from eth2spec.test.context import always_bls, spec_state_test, with_electra_and_later from eth2spec.test.helpers.deposits import ( prepare_deposit_request, run_deposit_request_processing, diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_voluntary_exit.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_voluntary_exit.py index fe439b7134..cde2ebaf27 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_voluntary_exit.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_voluntary_exit.py @@ -1,9 +1,9 @@ -from eth2spec.test.helpers.constants import MAINNET from eth2spec.test.context import ( spec_state_test, with_electra_and_later, with_presets, ) +from eth2spec.test.helpers.constants import MAINNET from eth2spec.test.helpers.keys import pubkey_to_privkey from eth2spec.test.helpers.voluntary_exits import ( run_voluntary_exit_processing, diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawal_request.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawal_request.py index 5e8e42a617..c2b17db9ad 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawal_request.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawal_request.py @@ -1,7 +1,8 @@ import random + from eth2spec.test.context import ( - spec_state_test, expect_assertion_error, + spec_state_test, with_electra_and_later, with_presets, ) @@ -10,8 +11,8 @@ get_validator_index_by_pubkey, ) from eth2spec.test.helpers.withdrawals import ( - set_eth1_withdrawal_credential_with_balance, set_compounding_withdrawal_credential, + set_eth1_withdrawal_credential_with_balance, ) # diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawals.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawals.py index b55c29722b..5d6f3190dd 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawals.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_withdrawals.py @@ -12,9 +12,9 @@ ) from eth2spec.test.helpers.withdrawals import ( prepare_expected_withdrawals, + prepare_pending_withdrawal, run_withdrawals_processing, set_compounding_withdrawal_credential_with_balance, - prepare_pending_withdrawal, ) diff --git a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_apply_pending_deposit.py b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_apply_pending_deposit.py index 046e342e43..fc5dbabfb4 100644 --- a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_apply_pending_deposit.py +++ b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_apply_pending_deposit.py @@ -1,7 +1,7 @@ from eth2spec.test.context import ( + always_bls, spec_state_test, with_electra_and_later, - always_bls, ) from eth2spec.test.helpers.deposits import ( prepare_pending_deposit, diff --git a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_process_pending_deposits.py b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_process_pending_deposits.py index acddd7fd00..57f713fd31 100644 --- a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_process_pending_deposits.py +++ b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/pending_deposits/test_process_pending_deposits.py @@ -1,22 +1,22 @@ -from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with from eth2spec.test.context import ( + always_bls, + default_activation_threshold, + scaled_churn_balances_exceed_activation_exit_churn_limit, + single_phase, spec_state_test, - with_electra_and_later, - with_presets, spec_test, - single_phase, with_custom_state, - scaled_churn_balances_exceed_activation_exit_churn_limit, - default_activation_threshold, - always_bls, + with_electra_and_later, + with_presets, ) +from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.deposits import prepare_pending_deposit +from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with from eth2spec.test.helpers.state import ( - next_epoch_with_full_participation, advance_finality_to, + next_epoch_with_full_participation, set_full_participation, ) -from eth2spec.test.helpers.constants import MINIMAL def run_process_pending_deposits(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_consolidations.py b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_consolidations.py index 5cb716db8a..4ab49662bf 100644 --- a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_consolidations.py +++ b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_consolidations.py @@ -1,17 +1,17 @@ -from eth2spec.test.helpers.epoch_processing import ( - run_epoch_processing_with, - run_epoch_processing_to, -) from eth2spec.test.context import ( spec_state_test, with_electra_and_later, ) +from eth2spec.test.helpers.epoch_processing import ( + run_epoch_processing_to, + run_epoch_processing_with, +) from eth2spec.test.helpers.state import ( next_epoch_with_full_participation, ) from eth2spec.test.helpers.withdrawals import ( - set_eth1_withdrawal_credential_with_balance, set_compounding_withdrawal_credential_with_balance, + set_eth1_withdrawal_credential_with_balance, ) # *********************** diff --git a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_registry_updates.py b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_registry_updates.py index 847f7ec5a6..72c82c5a26 100644 --- a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_registry_updates.py +++ b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_registry_updates.py @@ -1,10 +1,10 @@ -from eth2spec.test.helpers.deposits import mock_deposit -from eth2spec.test.helpers.state import next_epoch from eth2spec.test.context import spec_state_test, with_electra_and_later +from eth2spec.test.helpers.deposits import mock_deposit from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with +from eth2spec.test.helpers.state import next_epoch from eth2spec.test.helpers.withdrawals import ( - set_eth1_withdrawal_credential_with_balance, set_compounding_withdrawal_credential_with_balance, + set_eth1_withdrawal_credential_with_balance, ) diff --git a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py index b439c4ee99..10448ec2e8 100644 --- a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py @@ -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.constants import ( DENEB, ELECTRA, MINIMAL, ) -from eth2spec.test.helpers.state import ( - next_epoch, - next_epoch_via_block, -) from eth2spec.test.helpers.electra.fork import ( ELECTRA_FORK_TEST_META_TAGS, run_fork_test, ) +from eth2spec.test.helpers.state import ( + next_epoch, + next_epoch_via_block, +) +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[DENEB], other_phases=[ELECTRA]) diff --git a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_random.py b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_random.py index 90c42bf95f..b165c783a7 100644 --- a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_random.py +++ b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_random.py @@ -1,16 +1,15 @@ from random import Random 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.constants import ( DENEB, ELECTRA, @@ -21,6 +20,7 @@ run_fork_test, ) from eth2spec.test.helpers.random import randomize_state +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[DENEB], other_phases=[ELECTRA]) diff --git a/tests/core/pyspec/eth2spec/test/electra/fork_choice/test_deposit_with_reorg.py b/tests/core/pyspec/eth2spec/test/electra/fork_choice/test_deposit_with_reorg.py index 5f5009bd28..1ac8525eb6 100644 --- a/tests/core/pyspec/eth2spec/test/electra/fork_choice/test_deposit_with_reorg.py +++ b/tests/core/pyspec/eth2spec/test/electra/fork_choice/test_deposit_with_reorg.py @@ -1,28 +1,28 @@ -from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, -) from eth2spec.test.context import ( - with_presets, spec_state_test, with_electra_until_eip7732, + with_presets, ) -from eth2spec.test.helpers.execution_payload import ( - compute_el_block_hash_for_block, +from eth2spec.test.helpers.block import ( + build_empty_block_for_next_slot, ) -from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, - next_slot, +from eth2spec.test.helpers.constants import ( + MINIMAL, ) from eth2spec.test.helpers.deposits import ( prepare_deposit_request, ) +from eth2spec.test.helpers.execution_payload import ( + compute_el_block_hash_for_block, +) from eth2spec.test.helpers.fork_choice import ( + apply_next_slots_with_attestations, get_genesis_forkchoice_store_and_block, tick_and_add_block, - apply_next_slots_with_attestations, ) -from eth2spec.test.helpers.constants import ( - MINIMAL, +from eth2spec.test.helpers.state import ( + next_slot, + state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/electra/random/test_random.py b/tests/core/pyspec/eth2spec/test/electra/random/test_random.py index 95bc7af74b..22a63b41f4 100644 --- a/tests/core/pyspec/eth2spec/test/electra/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/electra/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import ELECTRA from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import ELECTRA from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py index af88357ce2..8861ca5a3b 100644 --- a/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py @@ -1,37 +1,37 @@ -from eth2spec.test.helpers.constants import MINIMAL -from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, - transition_unsigned_block, -) from eth2spec.test.context import ( - spec_test, + default_activation_threshold, + scaled_churn_balances_exceed_activation_exit_churn_limit, + single_phase, spec_state_test, + spec_test, + with_custom_state, with_electra_until_eip7732, - single_phase, with_presets, - with_custom_state, - scaled_churn_balances_exceed_activation_exit_churn_limit, - default_activation_threshold, +) +from eth2spec.test.helpers.block import ( + build_empty_block_for_next_slot, + transition_unsigned_block, ) from eth2spec.test.helpers.bls_to_execution_changes import ( get_signed_address_change, ) +from eth2spec.test.helpers.constants import MINIMAL +from eth2spec.test.helpers.deposits import ( + prepare_deposit_request, +) from eth2spec.test.helpers.execution_payload import ( compute_el_block_hash_for_block, ) -from eth2spec.test.helpers.voluntary_exits import ( - prepare_signed_exits, -) from eth2spec.test.helpers.state import ( state_transition_and_sign_block, transition_to, ) +from eth2spec.test.helpers.voluntary_exits import ( + prepare_signed_exits, +) from eth2spec.test.helpers.withdrawals import ( - set_eth1_withdrawal_credential_with_balance, set_compounding_withdrawal_credential_with_balance, -) -from eth2spec.test.helpers.deposits import ( - prepare_deposit_request, + set_eth1_withdrawal_credential_with_balance, ) diff --git a/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py index 8a76550aad..4311b0fdb4 100644 --- a/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py +++ b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py @@ -1,10 +1,10 @@ -from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, -) from eth2spec.test.context import ( + ELECTRA, spec_state_test, with_phases, - ELECTRA, +) +from eth2spec.test.helpers.block import ( + build_empty_block_for_next_slot, ) from eth2spec.test.helpers.deposits import ( build_deposit_data, diff --git a/tests/core/pyspec/eth2spec/test/electra/transition/test_operations.py b/tests/core/pyspec/eth2spec/test/electra/transition/test_operations.py index f096fc6335..972b445c3c 100644 --- a/tests/core/pyspec/eth2spec/test/electra/transition/test_operations.py +++ b/tests/core/pyspec/eth2spec/test/electra/transition/test_operations.py @@ -13,7 +13,6 @@ run_transition_with_operation, ) - # # DepositRequest # diff --git a/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_basic.py b/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_basic.py index 040b301ff6..7c4cbab771 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_basic.py @@ -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.constants import ( ELECTRA, FULU, MINIMAL, ) -from eth2spec.test.helpers.state import ( - next_epoch, - next_epoch_via_block, -) from eth2spec.test.helpers.fulu.fork import ( FULU_FORK_TEST_META_TAGS, run_fork_test, ) +from eth2spec.test.helpers.state import ( + next_epoch, + next_epoch_via_block, +) +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[ELECTRA], other_phases=[FULU]) diff --git a/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_random.py b/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_random.py index 73ca3f0a4c..c1d3060f1a 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_random.py +++ b/tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_random.py @@ -1,16 +1,15 @@ from random import Random 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.constants import ( ELECTRA, FULU, @@ -21,6 +20,7 @@ run_fork_test, ) from eth2spec.test.helpers.random import randomize_state +from eth2spec.test.utils import with_meta_tags @with_phases(phases=[ELECTRA], other_phases=[FULU]) diff --git a/tests/core/pyspec/eth2spec/test/fulu/merkle_proof/test_single_merkle_proof.py b/tests/core/pyspec/eth2spec/test/fulu/merkle_proof/test_single_merkle_proof.py index 54d16b8cbb..f78e859c08 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/merkle_proof/test_single_merkle_proof.py +++ b/tests/core/pyspec/eth2spec/test/fulu/merkle_proof/test_single_merkle_proof.py @@ -1,10 +1,17 @@ import random +from eth2spec.debug.random_value import ( + RandomizationMode, + get_random_ssz_object, +) from eth2spec.test.context import ( spec_state_test, with_fulu_and_later, with_test_suite_name, ) +from eth2spec.test.helpers.blob import ( + get_sample_blob_tx, +) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, sign_block, @@ -12,13 +19,6 @@ from eth2spec.test.helpers.execution_payload import ( compute_el_block_hash, ) -from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, -) -from eth2spec.debug.random_value import ( - RandomizationMode, - get_random_ssz_object, -) def _run_blob_kzg_commitments_merkle_proof_test(spec, state, rng=None, blob_count=1): diff --git a/tests/core/pyspec/eth2spec/test/fulu/random/test_random.py b/tests/core/pyspec/eth2spec/test/fulu/random/test_random.py index 66ecbc688c..f7c9ce51e5 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/fulu/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import FULU from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import FULU from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/fulu/unittests/das/test_das.py b/tests/core/pyspec/eth2spec/test/fulu/unittests/das/test_das.py index b056c86c6d..0f19548ab5 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/unittests/das/test_das.py +++ b/tests/core/pyspec/eth2spec/test/fulu/unittests/das/test_das.py @@ -1,8 +1,9 @@ import random + from eth2spec.test.context import ( expect_assertion_error, - spec_test, single_phase, + spec_test, with_config_overrides, with_fulu_and_later, ) diff --git a/tests/core/pyspec/eth2spec/test/fulu/unittests/polynomial_commitments/test_polynomial_commitments.py b/tests/core/pyspec/eth2spec/test/fulu/unittests/polynomial_commitments/test_polynomial_commitments.py index de21134ecd..d0928df0b3 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/unittests/polynomial_commitments/test_polynomial_commitments.py +++ b/tests/core/pyspec/eth2spec/test/fulu/unittests/polynomial_commitments/test_polynomial_commitments.py @@ -1,8 +1,9 @@ import random + from eth2spec.test.context import ( - spec_test, - single_phase, expect_assertion_error, + single_phase, + spec_test, with_fulu_and_later, ) from eth2spec.test.helpers.blob import ( diff --git a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_config_invariants.py b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_config_invariants.py index a1deb9bc52..c96a202969 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_config_invariants.py +++ b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_config_invariants.py @@ -1,10 +1,10 @@ from eth2spec.test.context import ( + expect_assertion_error, single_phase, - spec_test, spec_state_test, - with_presets, + spec_test, with_fulu_and_later, - expect_assertion_error, + with_presets, ) from eth2spec.test.helpers.constants import ( MAINNET, diff --git a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_custody.py b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_custody.py index 38b49513b0..1588451c6d 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_custody.py +++ b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_custody.py @@ -1,7 +1,7 @@ from eth2spec.test.context import ( expect_assertion_error, - spec_test, single_phase, + spec_test, with_fulu_and_later, ) diff --git a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_networking.py b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_networking.py index 6a0a182db1..e2d3745226 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_networking.py +++ b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_networking.py @@ -1,13 +1,17 @@ import random + +from eth2spec.debug.random_value import ( + RandomizationMode, + get_random_ssz_object, +) from eth2spec.test.context import ( single_phase, spec_state_test, spec_test, with_fulu_and_later, ) -from eth2spec.debug.random_value import ( - RandomizationMode, - get_random_ssz_object, +from eth2spec.test.helpers.blob import ( + get_sample_blob_tx, ) from eth2spec.test.helpers.block import ( sign_block, @@ -15,10 +19,6 @@ from eth2spec.test.helpers.execution_payload import ( compute_el_block_hash, ) -from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, -) - # Helper functions diff --git a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_security.py b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_security.py index 1c16c25a24..69c2ce35a8 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/unittests/test_security.py +++ b/tests/core/pyspec/eth2spec/test/fulu/unittests/test_security.py @@ -1,6 +1,6 @@ from eth2spec.test.context import ( - spec_test, single_phase, + spec_test, with_fulu_and_later, with_phases, ) diff --git a/tests/core/pyspec/eth2spec/test/helpers/attestations.py b/tests/core/pyspec/eth2spec/test/helpers/attestations.py index efc23e567e..3ac6071a98 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/attestations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/attestations.py @@ -1,17 +1,17 @@ -from lru import LRU - from typing import List +from lru import LRU + from eth2spec.test.context import expect_assertion_error +from eth2spec.test.helpers.block import build_empty_block_for_next_slot +from eth2spec.test.helpers.forks import is_post_altair, is_post_deneb, is_post_electra +from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.state import ( - payload_state_transition_no_store, - state_transition_and_sign_block, next_epoch, next_slot, + payload_state_transition_no_store, + state_transition_and_sign_block, ) -from eth2spec.test.helpers.block import build_empty_block_for_next_slot -from eth2spec.test.helpers.forks import is_post_altair, is_post_deneb, is_post_electra -from eth2spec.test.helpers.keys import privkeys from eth2spec.utils import bls from eth2spec.utils.ssz.ssz_typing import Bitlist diff --git a/tests/core/pyspec/eth2spec/test/helpers/blob.py b/tests/core/pyspec/eth2spec/test/helpers/blob.py index 296e42a48b..0e7718eefa 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/blob.py +++ b/tests/core/pyspec/eth2spec/test/helpers/blob.py @@ -1,5 +1,6 @@ import random -from rlp import encode, Serializable + +from rlp import Serializable, encode from rlp.sedes import Binary, CountableList, List as RLPList, big_endian_int, binary from eth2spec.test.helpers.forks import ( diff --git a/tests/core/pyspec/eth2spec/test/helpers/block.py b/tests/core/pyspec/eth2spec/test/helpers/block.py index 105260ed1c..b7e355c1aa 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/block.py +++ b/tests/core/pyspec/eth2spec/test/helpers/block.py @@ -1,33 +1,36 @@ -from eth2spec.test.helpers.execution_payload import build_empty_execution_payload -from eth2spec.test.helpers.execution_payload import build_empty_signed_execution_payload_header -from eth2spec.test.helpers.forks import ( - is_post_eip7441, - is_post_altair, - is_post_bellatrix, - is_post_eip7732, - is_post_electra, -) -from eth2spec.test.helpers.keys import privkeys, whisk_ks_initial, whisk_ks_final -from eth2spec.utils import bls -from eth2spec.utils.bls import only_with_bls -from eth2spec.utils.ssz.ssz_impl import hash_tree_root from curdleproofs import ( + GenerateWhiskShuffleProof, GenerateWhiskTrackerProof, WhiskTracker, - GenerateWhiskShuffleProof, ) -from py_ecc.optimized_bls12_381.optimized_curve import G1, multiply -from py_ecc.typing import Optimized_Field, Optimized_Point3D +from py_arkworks_bls12381 import Scalar from py_ecc.bls.g2_primitives import ( G1_to_pubkey as py_ecc_G1_to_bytes48, pubkey_to_G1 as py_ecc_bytes48_to_G1, ) +from py_ecc.optimized_bls12_381.optimized_curve import G1, multiply +from py_ecc.typing import Optimized_Field, Optimized_Point3D + from eth2spec.test.helpers.eip7441 import ( compute_whisk_tracker_and_commitment, is_first_proposal, resolve_known_tracker, ) -from py_arkworks_bls12381 import Scalar +from eth2spec.test.helpers.execution_payload import ( + build_empty_execution_payload, + build_empty_signed_execution_payload_header, +) +from eth2spec.test.helpers.forks import ( + is_post_altair, + is_post_bellatrix, + is_post_eip7441, + is_post_eip7732, + is_post_electra, +) +from eth2spec.test.helpers.keys import privkeys, whisk_ks_final, whisk_ks_initial +from eth2spec.utils import bls +from eth2spec.utils.bls import only_with_bls +from eth2spec.utils.ssz.ssz_impl import hash_tree_root PointProjective = Optimized_Point3D[Optimized_Field] diff --git a/tests/core/pyspec/eth2spec/test/helpers/bls_to_execution_changes.py b/tests/core/pyspec/eth2spec/test/helpers/bls_to_execution_changes.py index fe70e4b146..c2ad9f75b1 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/bls_to_execution_changes.py +++ b/tests/core/pyspec/eth2spec/test/helpers/bls_to_execution_changes.py @@ -1,5 +1,5 @@ +from eth2spec.test.helpers.keys import privkeys, pubkey_to_privkey, pubkeys from eth2spec.utils import bls -from eth2spec.test.helpers.keys import pubkeys, privkeys, pubkey_to_privkey def get_signed_address_change( diff --git a/tests/core/pyspec/eth2spec/test/helpers/constants.py b/tests/core/pyspec/eth2spec/test/helpers/constants.py index a63bba7a2b..aa937980ee 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/constants.py +++ b/tests/core/pyspec/eth2spec/test/helpers/constants.py @@ -1,5 +1,4 @@ -from .typing import SpecForkName, PresetBaseName - +from .typing import PresetBaseName, SpecForkName # # SpecForkName diff --git a/tests/core/pyspec/eth2spec/test/helpers/deneb/fork.py b/tests/core/pyspec/eth2spec/test/helpers/deneb/fork.py index 123b16f707..43bed9ec10 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/deneb/fork.py +++ b/tests/core/pyspec/eth2spec/test/helpers/deneb/fork.py @@ -2,7 +2,6 @@ DENEB, ) - DENEB_FORK_TEST_META_TAGS = { "fork": DENEB, } diff --git a/tests/core/pyspec/eth2spec/test/helpers/deposits.py b/tests/core/pyspec/eth2spec/test/helpers/deposits.py index 9a168fe3ea..16668d128e 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/deposits.py +++ b/tests/core/pyspec/eth2spec/test/helpers/deposits.py @@ -1,10 +1,10 @@ from random import Random from eth2spec.test.context import expect_assertion_error +from eth2spec.test.helpers.epoch_processing import run_epoch_processing_to from eth2spec.test.helpers.forks import is_post_altair, is_post_electra -from eth2spec.test.helpers.keys import pubkeys, privkeys +from eth2spec.test.helpers.keys import privkeys, pubkeys from eth2spec.test.helpers.state import get_balance -from eth2spec.test.helpers.epoch_processing import run_epoch_processing_to from eth2spec.utils import bls from eth2spec.utils.merkle_minimal import calc_merkle_tree_from_leaves, get_merkle_proof from eth2spec.utils.ssz.ssz_impl import hash_tree_root diff --git a/tests/core/pyspec/eth2spec/test/helpers/eip7441.py b/tests/core/pyspec/eth2spec/test/helpers/eip7441.py index 9a0ea6a78c..885c983f73 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/eip7441.py +++ b/tests/core/pyspec/eth2spec/test/helpers/eip7441.py @@ -1,9 +1,10 @@ -from typing import Tuple, Optional -from eth_typing import BLSPubkey +from typing import Optional, Tuple + from curdleproofs import GenerateWhiskTrackerProof, WhiskTracker -from eth2spec.test.helpers.keys import whisk_ks_initial +from eth_typing import BLSPubkey from py_arkworks_bls12381 import G1Point, Scalar +from eth2spec.test.helpers.keys import whisk_ks_initial # Map of validator index to initial WhiskTracker (r = 1, k = index) whisk_initial_tracker_cache_by_index = {} diff --git a/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py b/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py index 40dd1d4184..b7274cd441 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py +++ b/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py @@ -2,7 +2,6 @@ ELECTRA, ) - ELECTRA_FORK_TEST_META_TAGS = { "fork": ELECTRA, } diff --git a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py index c355fa7df6..29a52928f1 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py @@ -1,19 +1,20 @@ -from eth_hash.auto import keccak from hashlib import sha256 -from trie import HexaryTrie + +from eth_hash.auto import keccak from rlp import encode -from rlp.sedes import big_endian_int, Binary, List +from rlp.sedes import Binary, List, big_endian_int +from trie import HexaryTrie -from eth2spec.test.helpers.keys import privkeys -from eth2spec.utils.ssz.ssz_impl import hash_tree_root from eth2spec.debug.random_value import get_random_bytes_list -from eth2spec.test.helpers.withdrawals import get_expected_withdrawals from eth2spec.test.helpers.forks import ( is_post_capella, is_post_deneb, - is_post_electra, is_post_eip7732, + is_post_electra, ) +from eth2spec.test.helpers.keys import privkeys +from eth2spec.test.helpers.withdrawals import get_expected_withdrawals +from eth2spec.utils.ssz.ssz_impl import hash_tree_root def get_execution_payload_header(spec, state, execution_payload): diff --git a/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py b/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py index 2e2dbd9b5c..f440913306 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py +++ b/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py @@ -1,13 +1,14 @@ -from typing import NamedTuple, Sequence, Any +from typing import Any, NamedTuple, Sequence from eth_utils import encode_hex + from eth2spec.test.exceptions import BlockNotFoundException -from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.attestations import ( next_epoch_with_attestations, next_slots_with_attestations, state_transition_with_full_block, ) +from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.state import ( payload_state_transition, payload_state_transition_no_store, diff --git a/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py b/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py index 3579bd1fd7..9e49f3ee26 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py +++ b/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py @@ -1,39 +1,44 @@ from enum import Enum, auto -from eth2spec.test.helpers.attester_slashings import ( - get_valid_attester_slashing_by_indices, -) from eth2spec.test.helpers.attestations import ( next_slots_with_attestations, state_transition_with_full_block, ) +from eth2spec.test.helpers.attester_slashings import ( + get_valid_attester_slashing_by_indices, +) from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, build_empty_block, + build_empty_block_for_next_slot, sign_block, ) from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change +from eth2spec.test.helpers.consolidations import ( + prepare_switch_to_compounding_request, +) from eth2spec.test.helpers.constants import ( + DENEB, PHASE0, POST_FORK_OF, PREVIOUS_FORK_OF, - DENEB, ) from eth2spec.test.helpers.deposits import ( - prepare_state_and_deposit, prepare_deposit_request, + prepare_state_and_deposit, ) from eth2spec.test.helpers.execution_payload import ( + build_empty_execution_payload, + compute_el_block_hash, compute_el_block_hash_for_block, ) -from eth2spec.test.helpers.proposer_slashings import ( - get_valid_proposer_slashing, -) from eth2spec.test.helpers.forks import ( get_next_fork_transition, is_post_bellatrix, - is_post_electra, is_post_eip7732, + is_post_electra, +) +from eth2spec.test.helpers.proposer_slashings import ( + get_valid_proposer_slashing, ) from eth2spec.test.helpers.state import ( next_slot, @@ -46,13 +51,6 @@ from eth2spec.test.helpers.withdrawals import ( prepare_withdrawal_request, ) -from eth2spec.test.helpers.consolidations import ( - prepare_switch_to_compounding_request, -) -from eth2spec.test.helpers.execution_payload import ( - build_empty_execution_payload, - compute_el_block_hash, -) class OperationType(Enum): diff --git a/tests/core/pyspec/eth2spec/test/helpers/forks.py b/tests/core/pyspec/eth2spec/test/helpers/forks.py index b422f7f0e1..62eeb23ce5 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/forks.py +++ b/tests/core/pyspec/eth2spec/test/helpers/forks.py @@ -1,13 +1,13 @@ from .constants import ( - PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, - ELECTRA, - FULU, EIP7441, EIP7732, + ELECTRA, + FULU, + PHASE0, PREVIOUS_FORK_OF, ) diff --git a/tests/core/pyspec/eth2spec/test/helpers/fulu/fork.py b/tests/core/pyspec/eth2spec/test/helpers/fulu/fork.py index eac4e25b01..0f2ad6c344 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/fulu/fork.py +++ b/tests/core/pyspec/eth2spec/test/helpers/fulu/fork.py @@ -2,7 +2,6 @@ FULU, ) - FULU_FORK_TEST_META_TAGS = { "fork": FULU, } diff --git a/tests/core/pyspec/eth2spec/test/helpers/genesis.py b/tests/core/pyspec/eth2spec/test/helpers/genesis.py index 1382a6eb07..ab95b9a098 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/genesis.py +++ b/tests/core/pyspec/eth2spec/test/helpers/genesis.py @@ -1,8 +1,13 @@ from hashlib import sha256 + from eth2spec.test.helpers.constants import ( PHASE0, PREVIOUS_FORK_OF, ) +from eth2spec.test.helpers.eip7441 import ( + compute_whisk_initial_k_commitment_cached, + compute_whisk_initial_tracker_cached, +) from eth2spec.test.helpers.execution_payload import ( compute_el_header_block_hash, ) @@ -11,15 +16,11 @@ is_post_bellatrix, is_post_capella, is_post_deneb, - is_post_electra, is_post_eip7441, is_post_eip7732, + is_post_electra, ) from eth2spec.test.helpers.keys import pubkeys -from eth2spec.test.helpers.eip7441 import ( - compute_whisk_initial_tracker_cached, - compute_whisk_initial_k_commitment_cached, -) def build_mock_validator(spec, i: int, balance: int): diff --git a/tests/core/pyspec/eth2spec/test/helpers/light_client.py b/tests/core/pyspec/eth2spec/test/helpers/light_client.py index 101050522d..c15c45e06b 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/light_client.py +++ b/tests/core/pyspec/eth2spec/test/helpers/light_client.py @@ -1,3 +1,5 @@ +from math import floor + from eth2spec.test.helpers.constants import ( CAPELLA, DENEB, @@ -11,7 +13,6 @@ compute_aggregate_sync_committee_signature, compute_committee_indices, ) -from math import floor def latest_finalized_root_gindex(spec): diff --git a/tests/core/pyspec/eth2spec/test/helpers/light_client_data_collection.py b/tests/core/pyspec/eth2spec/test/helpers/light_client_data_collection.py index 125bff9df2..dbd08d4c62 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/light_client_data_collection.py +++ b/tests/core/pyspec/eth2spec/test/helpers/light_client_data_collection.py @@ -1,7 +1,8 @@ -from typing import Any, Dict, List, Set from dataclasses import dataclass +from typing import Any, Dict, List, Set from eth_utils import encode_hex + from eth2spec.test.helpers.constants import ( ALTAIR, ) diff --git a/tests/core/pyspec/eth2spec/test/helpers/light_client_sync.py b/tests/core/pyspec/eth2spec/test/helpers/light_client_sync.py index 0b0ff0811f..8a13fe34b3 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/light_client_sync.py +++ b/tests/core/pyspec/eth2spec/test/helpers/light_client_sync.py @@ -1,6 +1,7 @@ from typing import Any, Dict, List from eth_utils import encode_hex + from eth2spec.test.helpers.attestations import ( next_slots_with_attestations, state_transition_with_full_block, @@ -18,8 +19,8 @@ from eth2spec.test.helpers.light_client import ( get_sync_aggregate, upgrade_lc_bootstrap_to_new_spec, - upgrade_lc_update_to_new_spec, upgrade_lc_store_to_new_spec, + upgrade_lc_update_to_new_spec, ) from eth2spec.test.helpers.state import ( next_slots, diff --git a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py index cdbeac2ae0..314ac6a3be 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py @@ -1,22 +1,22 @@ from random import Random +from eth2spec.test.helpers.attestations import get_max_attestations, get_valid_attestation +from eth2spec.test.helpers.attester_slashings import get_valid_attester_slashing_by_indices +from eth2spec.test.helpers.block import ( + build_empty_block_for_next_slot, +) +from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change +from eth2spec.test.helpers.deposits import build_deposit, deposit_from_context from eth2spec.test.helpers.keys import privkeys, pubkeys +from eth2spec.test.helpers.proposer_slashings import get_valid_proposer_slashing from eth2spec.test.helpers.state import ( state_transition_and_sign_block, ) -from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, -) from eth2spec.test.helpers.sync_committee import ( - compute_committee_indices, compute_aggregate_sync_committee_signature, + compute_committee_indices, ) -from eth2spec.test.helpers.proposer_slashings import get_valid_proposer_slashing -from eth2spec.test.helpers.attester_slashings import get_valid_attester_slashing_by_indices -from eth2spec.test.helpers.attestations import get_valid_attestation, get_max_attestations -from eth2spec.test.helpers.deposits import build_deposit, deposit_from_context from eth2spec.test.helpers.voluntary_exits import prepare_signed_exits -from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change def run_slash_and_exit(spec, state, slash_index, exit_index, valid=True): diff --git a/tests/core/pyspec/eth2spec/test/helpers/optimistic_sync.py b/tests/core/pyspec/eth2spec/test/helpers/optimistic_sync.py index ad8cc20096..f18ee689dd 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/optimistic_sync.py +++ b/tests/core/pyspec/eth2spec/test/helpers/optimistic_sync.py @@ -7,10 +7,10 @@ from eth_utils import encode_hex -from eth2spec.utils.ssz.ssz_typing import Bytes32 from eth2spec.test.helpers.fork_choice import ( add_block, ) +from eth2spec.utils.ssz.ssz_typing import Bytes32 class PayloadStatusV1StatusAlias(Enum): diff --git a/tests/core/pyspec/eth2spec/test/helpers/pow_block.py b/tests/core/pyspec/eth2spec/test/helpers/pow_block.py index 104730b536..6a92c7703c 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/pow_block.py +++ b/tests/core/pyspec/eth2spec/test/helpers/pow_block.py @@ -1,4 +1,5 @@ from random import Random + from eth2spec.utils.ssz.ssz_typing import uint256 diff --git a/tests/core/pyspec/eth2spec/test/helpers/rewards.py b/tests/core/pyspec/eth2spec/test/helpers/rewards.py index 6b33bf5b72..61728ad88d 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/rewards.py +++ b/tests/core/pyspec/eth2spec/test/helpers/rewards.py @@ -1,21 +1,22 @@ from random import Random + from lru import LRU from eth2spec.phase0.mainnet import VALIDATOR_REGISTRY_LIMIT # equal everywhere, fine to import -from eth2spec.test.helpers.forks import is_post_altair, is_post_bellatrix -from eth2spec.test.helpers.state import ( - next_epoch, +from eth2spec.test.helpers.attestations import ( + cached_prepare_state_with_attestations, ) +from eth2spec.test.helpers.forks import is_post_altair, is_post_bellatrix from eth2spec.test.helpers.random import ( - set_some_new_deposits, exit_random_validators, - slash_random_validators, randomize_state, + set_some_new_deposits, + slash_random_validators, ) -from eth2spec.test.helpers.attestations import ( - cached_prepare_state_with_attestations, +from eth2spec.test.helpers.state import ( + next_epoch, ) -from eth2spec.utils.ssz.ssz_typing import Container, uint64, List +from eth2spec.utils.ssz.ssz_typing import Container, List, uint64 class Deltas(Container): diff --git a/tests/core/pyspec/eth2spec/test/helpers/specs.py b/tests/core/pyspec/eth2spec/test/helpers/specs.py index 811926415a..0785f5d35e 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/specs.py +++ b/tests/core/pyspec/eth2spec/test/helpers/specs.py @@ -1,19 +1,19 @@ from typing import ( Dict, ) + from .constants import ( - MINIMAL, - MAINNET, ALL_PHASES, EIP7441, + MAINNET, + MINIMAL, ) from .typing import ( PresetBaseName, - SpecForkName, Spec, + SpecForkName, ) - # NOTE: special case like `ALLOWED_TEST_RUNNER_FORKS` ALL_EXECUTABLE_SPEC_NAMES = ALL_PHASES + (EIP7441,) diff --git a/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py b/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py index c053714e3f..8237e0ee39 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py +++ b/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py @@ -3,11 +3,11 @@ from eth2spec.test.context import ( expect_assertion_error, ) -from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) from eth2spec.test.helpers.block_processing import run_block_processing_to +from eth2spec.test.helpers.keys import privkeys from eth2spec.utils import bls diff --git a/tests/core/pyspec/eth2spec/test/helpers/voluntary_exits.py b/tests/core/pyspec/eth2spec/test/helpers/voluntary_exits.py index d68e1bf0cc..aa6a31885c 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/voluntary_exits.py +++ b/tests/core/pyspec/eth2spec/test/helpers/voluntary_exits.py @@ -1,8 +1,9 @@ from random import Random -from eth2spec.utils import bls + from eth2spec.test.context import expect_assertion_error from eth2spec.test.helpers.forks import is_post_deneb from eth2spec.test.helpers.keys import privkeys +from eth2spec.utils import bls def prepare_signed_exits(spec, state, indices, fork_version=None): diff --git a/tests/core/pyspec/eth2spec/test/helpers/withdrawals.py b/tests/core/pyspec/eth2spec/test/helpers/withdrawals.py index ab9c7fcebe..c16a61868c 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/withdrawals.py +++ b/tests/core/pyspec/eth2spec/test/helpers/withdrawals.py @@ -1,5 +1,4 @@ -from eth2spec.test.helpers.forks import is_post_electra -from eth2spec.test.helpers.forks import is_post_eip7732 +from eth2spec.test.helpers.forks import is_post_eip7732, is_post_electra def get_expected_withdrawals(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attestation.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attestation.py index 00bc783ce9..3546d18328 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attestation.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attestation.py @@ -1,23 +1,23 @@ from eth2spec.test.context import ( - spec_state_test, always_bls, + low_balances, never_bls, - with_all_phases, + single_phase, + spec_state_test, spec_test, - low_balances, + with_all_phases, with_custom_state, - single_phase, ) from eth2spec.test.helpers.attestations import ( - run_attestation_processing, + compute_max_inclusion_slot, get_valid_attestation, + run_attestation_processing, sign_aggregate_attestation, sign_attestation, - compute_max_inclusion_slot, ) from eth2spec.test.helpers.state import ( - next_slots, next_epoch_via_block, + next_slots, transition_to_slot_via_block, ) from eth2spec.utils.ssz.ssz_typing import Bitlist diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py index 1d353354c4..70799da218 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py @@ -1,23 +1,23 @@ from random import Random from eth2spec.test.context import ( - spec_state_test, - expect_assertion_error, always_bls, - with_all_phases, - with_custom_state, - spec_test, - single_phase, + expect_assertion_error, low_balances, misc_balances, + single_phase, + spec_state_test, + spec_test, + with_all_phases, + with_custom_state, ) from eth2spec.test.helpers.attestations import sign_indexed_attestation from eth2spec.test.helpers.attester_slashings import ( + get_attestation_1_data, + get_attestation_2_data, + get_indexed_attestation_participants, get_valid_attester_slashing, get_valid_attester_slashing_by_indices, - get_indexed_attestation_participants, - get_attestation_2_data, - get_attestation_1_data, ) from eth2spec.test.helpers.proposer_slashings import ( get_min_slashing_penalty_quotient, diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_block_header.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_block_header.py index a5faf3da39..1098e100c1 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_block_header.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_block_header.py @@ -1,15 +1,14 @@ from copy import deepcopy -from eth2spec.test.context import spec_state_test, expect_assertion_error, with_all_phases +from eth2spec.test.context import expect_assertion_error, spec_state_test, with_all_phases from eth2spec.test.helpers.block import build_empty_block_for_next_slot -from eth2spec.test.helpers.execution_payload import compute_el_block_hash_for_block -from eth2spec.test.helpers.forks import is_post_bellatrix -from eth2spec.test.helpers.forks import is_post_eip7732 -from eth2spec.test.helpers.state import next_slot from eth2spec.test.helpers.execution_payload import ( build_empty_execution_payload, compute_el_block_hash, + compute_el_block_hash_for_block, ) +from eth2spec.test.helpers.forks import is_post_bellatrix, is_post_eip7732 +from eth2spec.test.helpers.state import next_slot def prepare_state_for_header_processing(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py index c21a9596bc..5d1bde5bdd 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py @@ -1,4 +1,4 @@ -from eth2spec.test.context import spec_state_test, always_bls, with_all_phases +from eth2spec.test.context import always_bls, spec_state_test, with_all_phases from eth2spec.test.helpers.deposits import ( build_deposit, prepare_state_and_deposit, @@ -6,8 +6,8 @@ run_deposit_processing_with_specific_fork_version, sign_deposit_data, ) -from eth2spec.test.helpers.keys import privkeys, pubkeys from eth2spec.test.helpers.forks import is_post_electra +from eth2spec.test.helpers.keys import privkeys, pubkeys @with_all_phases diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_proposer_slashing.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_proposer_slashing.py index 269802a5cd..857bcd1849 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_proposer_slashing.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_proposer_slashing.py @@ -1,15 +1,15 @@ from eth2spec.test.context import ( - spec_state_test, - expect_assertion_error, always_bls, + expect_assertion_error, + spec_state_test, with_all_phases, ) from eth2spec.test.helpers.block import build_empty_block_for_next_slot from eth2spec.test.helpers.block_header import sign_block_header from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.proposer_slashings import ( - get_valid_proposer_slashing, check_proposer_slashing_effect, + get_valid_proposer_slashing, ) from eth2spec.test.helpers.state import next_epoch diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_voluntary_exit.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_voluntary_exit.py index d7c7c8cb6d..e34bec23af 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_voluntary_exit.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_voluntary_exit.py @@ -1,14 +1,14 @@ -from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.context import ( - spec_state_test, always_bls, - with_all_phases, - with_presets, - spec_test, + scaled_churn_balances_min_churn_limit, single_phase, + spec_state_test, + spec_test, + with_all_phases, with_custom_state, - scaled_churn_balances_min_churn_limit, + with_presets, ) +from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.keys import pubkey_to_privkey from eth2spec.test.helpers.voluntary_exits import ( run_voluntary_exit_processing, diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_effective_balance_updates.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_effective_balance_updates.py index 5eb5553313..ff41e7606c 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_effective_balance_updates.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_effective_balance_updates.py @@ -1,9 +1,9 @@ from eth2spec.test.context import spec_state_test, with_all_phases from eth2spec.test.helpers.epoch_processing import run_epoch_processing_to +from eth2spec.test.helpers.forks import is_post_electra from eth2spec.test.helpers.withdrawals import ( set_compounding_withdrawal_credential, ) -from eth2spec.test.helpers.forks import is_post_electra @with_all_phases diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_historical_roots_update.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_historical_roots_update.py index ffac596043..f600fc65a7 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_historical_roots_update.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_historical_roots_update.py @@ -1,7 +1,7 @@ from eth2spec.test.context import ( - PHASE0, ALTAIR, BELLATRIX, + PHASE0, spec_state_test, with_phases, ) diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_justification_and_finalization.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_justification_and_finalization.py index aabd8e058d..521018eb7e 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_justification_and_finalization.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_justification_and_finalization.py @@ -1,10 +1,11 @@ from random import Random + from eth2spec.test.context import spec_state_test, with_all_phases from eth2spec.test.helpers.epoch_processing import ( run_epoch_processing_with, ) from eth2spec.test.helpers.forks import is_post_altair -from eth2spec.test.helpers.state import transition_to, next_epoch_via_block, next_slot +from eth2spec.test.helpers.state import next_epoch_via_block, next_slot, transition_to from eth2spec.test.helpers.voluntary_exits import get_unslashed_exited_validators diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_registry_updates.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_registry_updates.py index 1c8e6c8939..4ea89722ae 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_registry_updates.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_registry_updates.py @@ -1,17 +1,17 @@ -from eth2spec.test.helpers.deposits import mock_deposit -from eth2spec.test.helpers.state import next_epoch, next_slots -from eth2spec.test.helpers.forks import is_post_electra -from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.context import ( - spec_test, + scaled_churn_balances_min_churn_limit, + single_phase, spec_state_test, + spec_test, with_all_phases, - single_phase, with_custom_state, with_presets, - scaled_churn_balances_min_churn_limit, ) +from eth2spec.test.helpers.constants import MINIMAL +from eth2spec.test.helpers.deposits import mock_deposit from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with +from eth2spec.test.helpers.forks import is_post_electra +from eth2spec.test.helpers.state import next_epoch, next_slots def run_process_registry_updates(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py index b347dcada9..b15524ea53 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py @@ -1,32 +1,33 @@ +from random import Random + from eth2spec.test.context import ( + PHASE0, + low_single_balance, + misc_balances, + single_phase, spec_state_test, spec_test, with_all_phases, - single_phase, - with_phases, - PHASE0, with_custom_state, + with_phases, zero_activation_threshold, - misc_balances, - low_single_balance, -) -from eth2spec.test.helpers.forks import ( - is_post_altair, -) -from eth2spec.test.helpers.state import ( - next_epoch, - next_slot, ) from eth2spec.test.helpers.attestations import ( add_attestations_to_state, get_valid_attestation, - sign_attestation, prepare_state_with_attestations, + sign_attestation, ) -from eth2spec.test.helpers.rewards import leaking from eth2spec.test.helpers.attester_slashings import get_indexed_attestation_participants from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with -from random import Random +from eth2spec.test.helpers.forks import ( + is_post_altair, +) +from eth2spec.test.helpers.rewards import leaking +from eth2spec.test.helpers.state import ( + next_epoch, + next_slot, +) def run_process_rewards_and_penalties(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_slashings.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_slashings.py index 4c732e9bd0..7ffc355aff 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_slashings.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_slashings.py @@ -1,8 +1,9 @@ from random import Random + from eth2spec.test.context import spec_state_test, with_all_phases from eth2spec.test.helpers.epoch_processing import ( - run_epoch_processing_with, run_epoch_processing_to, + run_epoch_processing_with, ) from eth2spec.test.helpers.forks import ( is_post_altair, @@ -10,9 +11,8 @@ is_post_electra, ) from eth2spec.test.helpers.random import randomize_state -from eth2spec.test.helpers.state import has_active_balance_differential +from eth2spec.test.helpers.state import has_active_balance_differential, next_epoch from eth2spec.test.helpers.voluntary_exits import get_unslashed_exited_validators -from eth2spec.test.helpers.state import next_epoch def run_process_slashings(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase0/finality/test_finality.py b/tests/core/pyspec/eth2spec/test/phase0/finality/test_finality.py index 2b22340a5b..e7c962a1ce 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/finality/test_finality.py +++ b/tests/core/pyspec/eth2spec/test/phase0/finality/test_finality.py @@ -1,6 +1,6 @@ from eth2spec.test.context import spec_state_test, with_all_phases -from eth2spec.test.helpers.state import next_epoch_via_block from eth2spec.test.helpers.attestations import next_epoch_with_attestations +from eth2spec.test.helpers.state import next_epoch_via_block def check_finality( diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_ex_ante.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_ex_ante.py index c39016b11b..cd120a3b78 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_ex_ante.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_ex_ante.py @@ -12,18 +12,18 @@ build_empty_block, ) from eth2spec.test.helpers.constants import MAINNET -from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.fork_choice import ( + add_attestation, + add_block, check_head_against_root, get_genesis_forkchoice_store_and_block, on_tick_and_append_step, - add_attestation, - add_block, tick_and_add_block, ) +from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, payload_state_transition, + state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py index cb13fd1da6..30f628f564 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_head.py @@ -1,4 +1,5 @@ import random + from eth2spec.test.context import ( spec_state_test, with_altair_and_later, @@ -12,26 +13,26 @@ ) from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.fork_choice import ( + add_attestation, add_attester_slashing, add_block, + apply_next_epoch_with_attestations, check_head_against_root, get_anchor_root, - get_genesis_forkchoice_store_and_block, get_formatted_head_output, + get_genesis_forkchoice_store_and_block, on_tick_and_append_step, - add_attestation, - tick_and_run_on_attestation, - tick_and_add_block, output_head_check, - apply_next_epoch_with_attestations, + tick_and_add_block, + tick_and_run_on_attestation, ) from eth2spec.test.helpers.forks import ( is_post_altair, is_post_eip7732, ) from eth2spec.test.helpers.state import ( - next_slots, next_epoch, + next_slots, payload_state_transition, state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py index 9abcee9ccc..36bd153b11 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_get_proposer_head.py @@ -1,4 +1,5 @@ from eth_utils import encode_hex + from eth2spec.test.context import ( spec_state_test, with_altair_until_eip7732, diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py index 0d856f81c1..786c86ceb3 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py @@ -1,17 +1,17 @@ import random + from eth_utils import encode_hex -from eth2spec.utils.ssz.ssz_impl import hash_tree_root from eth2spec.test.context import MINIMAL, spec_state_test, with_altair_and_later, with_presets from eth2spec.test.helpers.attestations import ( next_epoch_with_attestations, next_slots_with_attestations, ) from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, build_empty_block, - transition_unsigned_block, + build_empty_block_for_next_slot, sign_block, + transition_unsigned_block, ) from eth2spec.test.helpers.execution_payload import ( build_empty_execution_payload, @@ -19,16 +19,16 @@ compute_el_block_hash_for_block, ) from eth2spec.test.helpers.fork_choice import ( + add_block, + apply_next_epoch_with_attestations, + apply_next_slots_with_attestations, check_head_against_root, + find_next_justifying_slot, get_genesis_forkchoice_store_and_block, get_store_full_state, + is_ready_to_justify, on_tick_and_append_step, - add_block, tick_and_add_block, - apply_next_epoch_with_attestations, - apply_next_slots_with_attestations, - is_ready_to_justify, - find_next_justifying_slot, ) from eth2spec.test.helpers.forks import ( is_post_bellatrix, @@ -40,6 +40,7 @@ payload_state_transition, state_transition_and_sign_block, ) +from eth2spec.utils.ssz.ssz_impl import hash_tree_root rng = random.Random(2020) diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_reorg.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_reorg.py index 6aceb0ec66..685bc1e313 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_reorg.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_reorg.py @@ -3,40 +3,39 @@ with_altair_and_later, with_presets, ) -from eth2spec.test.helpers.constants import ( - MINIMAL, -) from eth2spec.test.helpers.attestations import ( - state_transition_with_full_block, get_valid_attestation, get_valid_attestations_at_slot, + state_transition_with_full_block, ) from eth2spec.test.helpers.block import ( build_empty_block, build_empty_block_for_next_slot, ) -from eth2spec.test.helpers.forks import is_post_eip7732 +from eth2spec.test.helpers.constants import ( + MINIMAL, +) from eth2spec.test.helpers.fork_choice import ( - check_head_against_root, - get_genesis_forkchoice_store_and_block, - get_store_full_state, - on_tick_and_append_step, add_attestations, - tick_and_add_block, apply_next_epoch_with_attestations, + check_head_against_root, find_next_justifying_slot, + get_genesis_forkchoice_store_and_block, + get_store_full_state, is_ready_to_justify, + on_tick_and_append_step, payload_state_transition, payload_state_transition_no_store, + tick_and_add_block, ) +from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, next_epoch, next_slot, + state_transition_and_sign_block, transition_to, ) - TESTING_PRESETS = [MINIMAL] diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_withholding.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_withholding.py index ba8a7b4871..3468b0e336 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_withholding.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_withholding.py @@ -3,33 +3,32 @@ with_altair_and_later, with_presets, ) -from eth2spec.test.helpers.constants import ( - MINIMAL, -) from eth2spec.test.helpers.attestations import ( state_transition_with_full_block, ) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) -from eth2spec.test.helpers.forks import is_post_eip7732 +from eth2spec.test.helpers.constants import ( + MINIMAL, +) from eth2spec.test.helpers.fork_choice import ( + apply_next_epoch_with_attestations, check_head_against_root, + find_next_justifying_slot, get_genesis_forkchoice_store_and_block, get_store_full_state, on_tick_and_append_step, payload_state_transition, payload_state_transition_no_store, tick_and_add_block, - apply_next_epoch_with_attestations, - find_next_justifying_slot, ) +from eth2spec.test.helpers.forks import is_post_eip7732 from eth2spec.test.helpers.state import ( - state_transition_and_sign_block, next_epoch, + state_transition_and_sign_block, ) - TESTING_PRESETS = [MINIMAL] diff --git a/tests/core/pyspec/eth2spec/test/phase0/genesis/test_initialization.py b/tests/core/pyspec/eth2spec/test/phase0/genesis/test_initialization.py index 2c6741c8e1..fad3115ba2 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/genesis/test_initialization.py +++ b/tests/core/pyspec/eth2spec/test/phase0/genesis/test_initialization.py @@ -2,8 +2,8 @@ PHASE0, single_phase, spec_test, - with_presets, with_phases, + with_presets, ) from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.deposits import ( diff --git a/tests/core/pyspec/eth2spec/test/phase0/genesis/test_validity.py b/tests/core/pyspec/eth2spec/test/phase0/genesis/test_validity.py index 4b93bab529..092adb1897 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/genesis/test_validity.py +++ b/tests/core/pyspec/eth2spec/test/phase0/genesis/test_validity.py @@ -1,9 +1,9 @@ from eth2spec.test.context import ( PHASE0, - spec_test, single_phase, - with_presets, + spec_test, with_phases, + with_presets, ) from eth2spec.test.helpers.constants import MINIMAL from eth2spec.test.helpers.deposits import ( diff --git a/tests/core/pyspec/eth2spec/test/phase0/random/test_random.py b/tests/core/pyspec/eth2spec/test/phase0/random/test_random.py index 3b93c628e3..0df30d6acd 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/random/test_random.py +++ b/tests/core/pyspec/eth2spec/test/phase0/random/test_random.py @@ -4,19 +4,17 @@ See the README for that generator for more information. """ -from eth2spec.test.helpers.constants import PHASE0 from eth2spec.test.context import ( + always_bls, misc_balances_in_default_range_with_many_validators, - with_phases, - zero_activation_threshold, only_generator, -) -from eth2spec.test.context import ( - always_bls, + single_phase, spec_test, with_custom_state, - single_phase, + with_phases, + zero_activation_threshold, ) +from eth2spec.test.helpers.constants import PHASE0 from eth2spec.test.utils.randomized_block_tests import ( run_generated_randomized_test, ) diff --git a/tests/core/pyspec/eth2spec/test/phase0/rewards/test_basic.py b/tests/core/pyspec/eth2spec/test/phase0/rewards/test_basic.py index 32ace544f5..2fbfa2b697 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/rewards/test_basic.py +++ b/tests/core/pyspec/eth2spec/test/phase0/rewards/test_basic.py @@ -1,6 +1,6 @@ -from eth2spec.test.context import with_all_phases, with_phases, spec_state_test -from eth2spec.test.helpers.constants import PHASE0 import eth2spec.test.helpers.rewards as rewards_helpers +from eth2spec.test.context import spec_state_test, with_all_phases, with_phases +from eth2spec.test.helpers.constants import PHASE0 @with_all_phases diff --git a/tests/core/pyspec/eth2spec/test/phase0/rewards/test_leak.py b/tests/core/pyspec/eth2spec/test/phase0/rewards/test_leak.py index 145977d3da..b1fbe7b326 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/rewards/test_leak.py +++ b/tests/core/pyspec/eth2spec/test/phase0/rewards/test_leak.py @@ -1,7 +1,7 @@ -from eth2spec.test.context import with_all_phases, with_phases, spec_state_test +import eth2spec.test.helpers.rewards as rewards_helpers +from eth2spec.test.context import spec_state_test, with_all_phases, with_phases from eth2spec.test.helpers.constants import PHASE0 from eth2spec.test.helpers.rewards import leaking -import eth2spec.test.helpers.rewards as rewards_helpers @with_all_phases diff --git a/tests/core/pyspec/eth2spec/test/phase0/rewards/test_random.py b/tests/core/pyspec/eth2spec/test/phase0/rewards/test_random.py index cc97e39eea..7e1d5c1741 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/rewards/test_random.py +++ b/tests/core/pyspec/eth2spec/test/phase0/rewards/test_random.py @@ -1,19 +1,19 @@ from random import Random +import eth2spec.test.helpers.rewards as rewards_helpers from eth2spec.test.context import ( - with_all_phases, - spec_test, - spec_state_test, - with_custom_state, - single_phase, low_balances, misc_balances, + single_phase, + spec_state_test, + spec_test, + with_all_phases, + with_custom_state, ) -import eth2spec.test.helpers.rewards as rewards_helpers from eth2spec.test.helpers.random import ( - randomize_state, patch_state_to_non_leaking, randomize_attestation_participation, + randomize_state, ) from eth2spec.test.helpers.state import has_active_balance_differential, next_epoch from eth2spec.test.helpers.voluntary_exits import get_unslashed_exited_validators diff --git a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py index 83ab1046d5..994b370b09 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py @@ -1,31 +1,32 @@ from random import Random -from eth2spec.utils import bls -from eth2spec.test.helpers.state import ( - get_balance, - state_transition_and_sign_block, - next_slot, - next_epoch, - next_epoch_via_block, -) -from eth2spec.test.helpers.block import ( - build_empty_block_for_next_slot, - build_empty_block, - sign_block, - transition_unsigned_block, +from eth2spec.test.context import ( + always_bls, + dump_skipping_message, + expect_assertion_error, + large_validator_set, + single_phase, + spec_state_test, + spec_test, + with_all_phases, + with_custom_state, + with_phases, + with_presets, ) -from eth2spec.test.helpers.keys import pubkeys +from eth2spec.test.helpers.attestations import get_valid_attestation from eth2spec.test.helpers.attester_slashings import ( - get_valid_attester_slashing_by_indices, - get_valid_attester_slashing, get_indexed_attestation_participants, get_max_attester_slashings, + get_valid_attester_slashing, + get_valid_attester_slashing_by_indices, ) -from eth2spec.test.helpers.proposer_slashings import ( - get_valid_proposer_slashing, - check_proposer_slashing_effect, +from eth2spec.test.helpers.block import ( + build_empty_block, + build_empty_block_for_next_slot, + sign_block, + transition_unsigned_block, ) -from eth2spec.test.helpers.attestations import get_valid_attestation +from eth2spec.test.helpers.constants import MINIMAL, PHASE0 from eth2spec.test.helpers.deposits import prepare_state_and_deposit from eth2spec.test.helpers.execution_payload import ( build_empty_execution_payload, @@ -33,36 +34,35 @@ compute_el_block_hash, compute_el_block_hash_for_block, ) -from eth2spec.test.helpers.voluntary_exits import prepare_signed_exits +from eth2spec.test.helpers.forks import ( + is_post_altair, + is_post_bellatrix, + is_post_capella, + is_post_eip7732, + is_post_electra, +) +from eth2spec.test.helpers.keys import pubkeys from eth2spec.test.helpers.multi_operations import ( run_slash_and_exit, run_test_full_random_operations, ) +from eth2spec.test.helpers.proposer_slashings import ( + check_proposer_slashing_effect, + get_valid_proposer_slashing, +) +from eth2spec.test.helpers.state import ( + get_balance, + next_epoch, + next_epoch_via_block, + next_slot, + state_transition_and_sign_block, +) from eth2spec.test.helpers.sync_committee import ( compute_committee_indices, compute_sync_committee_participant_reward_and_penalty, ) -from eth2spec.test.helpers.constants import PHASE0, MINIMAL -from eth2spec.test.helpers.forks import ( - is_post_altair, - is_post_bellatrix, - is_post_electra, - is_post_capella, - is_post_eip7732, -) -from eth2spec.test.context import ( - spec_test, - spec_state_test, - dump_skipping_message, - with_phases, - with_all_phases, - single_phase, - expect_assertion_error, - always_bls, - with_presets, - with_custom_state, - large_validator_set, -) +from eth2spec.test.helpers.voluntary_exits import prepare_signed_exits +from eth2spec.utils import bls @with_all_phases diff --git a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_slots.py b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_slots.py index 7e1ab3e6d6..b5d317551b 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_slots.py +++ b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_slots.py @@ -1,10 +1,10 @@ -from eth2spec.test.helpers.forks import ( - is_post_capella, -) from eth2spec.test.context import ( spec_state_test, with_all_phases, ) +from eth2spec.test.helpers.forks import ( + is_post_capella, +) from eth2spec.test.helpers.state import get_state_root, next_epoch, next_slot, transition_to diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py index d7b0297992..866f27ede8 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py @@ -1,15 +1,15 @@ -from eth2spec.test.context import with_all_phases, spec_state_test -from eth2spec.test.helpers.block import build_empty_block_for_next_slot +from eth2spec.test.context import spec_state_test, with_all_phases from eth2spec.test.helpers.attestations import get_valid_attestation, sign_attestation +from eth2spec.test.helpers.block import build_empty_block_for_next_slot from eth2spec.test.helpers.constants import ALL_PHASES -from eth2spec.test.helpers.forks import is_post_electra, is_post_eip7732 +from eth2spec.test.helpers.fork_choice import get_genesis_forkchoice_store +from eth2spec.test.helpers.forks import is_post_eip7732, is_post_electra from eth2spec.test.helpers.state import ( - transition_to, - state_transition_and_sign_block, next_epoch, next_slot, + state_transition_and_sign_block, + transition_to, ) -from eth2spec.test.helpers.fork_choice import get_genesis_forkchoice_store def run_on_attestation(spec, state, store, attestation, valid=True): diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_tick.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_tick.py index e9f5c5903a..16fba7e717 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_tick.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_tick.py @@ -1,8 +1,8 @@ -from eth2spec.test.context import with_all_phases, spec_state_test -from eth2spec.test.helpers.fork_choice import get_genesis_forkchoice_store +from eth2spec.test.context import spec_state_test, with_all_phases from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) +from eth2spec.test.helpers.fork_choice import get_genesis_forkchoice_store from eth2spec.test.helpers.state import ( next_epoch, state_transition_and_sign_block, diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/math/test_integer_squareroot.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/math/test_integer_squareroot.py index 159f3c9b94..43013c3654 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/math/test_integer_squareroot.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/math/test_integer_squareroot.py @@ -1,8 +1,9 @@ import random from math import isqrt + from eth2spec.test.context import ( - spec_test, single_phase, + spec_test, with_all_phases, ) diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/validator/test_validator_unittest.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/validator/test_validator_unittest.py index 48f1eae614..c40d823aed 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/validator/test_validator_unittest.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/validator/test_validator_unittest.py @@ -1,16 +1,16 @@ import random from eth2spec.test.context import ( + always_bls, single_phase, spec_state_test, spec_test, - always_bls, - with_phases, with_all_phases, + with_phases, ) -from eth2spec.test.helpers.constants import PHASE0 from eth2spec.test.helpers.attestations import build_attestation_data, get_valid_attestation from eth2spec.test.helpers.block import build_empty_block +from eth2spec.test.helpers.constants import PHASE0 from eth2spec.test.helpers.deposits import prepare_state_and_deposit from eth2spec.test.helpers.keys import privkeys, pubkeys from eth2spec.test.helpers.state import next_epoch diff --git a/tests/core/pyspec/eth2spec/test/utils/__init__.py b/tests/core/pyspec/eth2spec/test/utils/__init__.py index abd79f9ede..cead6efbd7 100644 --- a/tests/core/pyspec/eth2spec/test/utils/__init__.py +++ b/tests/core/pyspec/eth2spec/test/utils/__init__.py @@ -3,7 +3,6 @@ with_meta_tags, ) - __all__ = [ # avoid "unused import" lint error "vector_test", "with_meta_tags", diff --git a/tests/core/pyspec/eth2spec/test/utils/kzg_tests.py b/tests/core/pyspec/eth2spec/test/utils/kzg_tests.py index 63828fbffb..d926b8a774 100644 --- a/tests/core/pyspec/eth2spec/test/utils/kzg_tests.py +++ b/tests/core/pyspec/eth2spec/test/utils/kzg_tests.py @@ -3,9 +3,8 @@ int_to_big_endian, ) -from eth2spec.utils import bls from eth2spec.fulu import spec - +from eth2spec.utils import bls ############################################################################### # Helper functions diff --git a/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py b/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py index 27fc37a165..58c0e00b14 100644 --- a/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py +++ b/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py @@ -7,31 +7,31 @@ from random import Random from typing import Callable +from eth2spec.test.helpers.blob import ( + get_sample_blob_tx, +) from eth2spec.test.helpers.execution_payload import ( - compute_el_block_hash_for_block, build_randomized_execution_payload, + compute_el_block_hash_for_block, +) +from eth2spec.test.helpers.inactivity_scores import ( + randomize_inactivity_scores, ) from eth2spec.test.helpers.multi_operations import ( build_random_block_from_state_for_next_slot, get_random_bls_to_execution_changes, + get_random_execution_requests, get_random_sync_aggregate, prepare_state_and_get_random_deposits, - get_random_execution_requests, -) -from eth2spec.test.helpers.inactivity_scores import ( - randomize_inactivity_scores, ) from eth2spec.test.helpers.random import ( - randomize_state as randomize_state_helper, patch_state_to_non_leaking, -) -from eth2spec.test.helpers.blob import ( - get_sample_blob_tx, + randomize_state as randomize_state_helper, ) from eth2spec.test.helpers.state import ( - next_slot, - next_epoch, ensure_state_has_validators_across_lifecycle, + next_epoch, + next_slot, state_transition_and_sign_block, ) diff --git a/tests/core/pyspec/eth2spec/test/utils/utils.py b/tests/core/pyspec/eth2spec/test/utils/utils.py index 8273ff2d98..6dab2514ee 100644 --- a/tests/core/pyspec/eth2spec/test/utils/utils.py +++ b/tests/core/pyspec/eth2spec/test/utils/utils.py @@ -1,6 +1,7 @@ -from typing import Dict, Any -from eth2spec.utils.ssz.ssz_typing import View +from typing import Any, Dict + from eth2spec.utils.ssz.ssz_impl import serialize +from eth2spec.utils.ssz.ssz_typing import View def vector_test(description: str = None): diff --git a/tests/core/pyspec/eth2spec/utils/bls.py b/tests/core/pyspec/eth2spec/utils/bls.py index 5b8f7ca365..f15cd60fc6 100644 --- a/tests/core/pyspec/eth2spec/utils/bls.py +++ b/tests/core/pyspec/eth2spec/utils/bls.py @@ -1,38 +1,35 @@ +import milagro_bls_binding as milagro_bls # noqa: F401 for BLS switching option +import py_arkworks_bls12381 as arkworks_bls # noqa: F401 for BLS switching option +from py_arkworks_bls12381 import ( + GT as arkworks_GT, + G1Point as arkworks_G1, + G2Point as arkworks_G2, + Scalar as arkworks_Scalar, +) from py_ecc.bls import G2ProofOfPossession as py_ecc_bls -from py_ecc.bls.g2_primitives import signature_to_G2 as _signature_to_G2 -from py_ecc.utils import prime_field_inv as py_ecc_prime_field_inv +from py_ecc.bls.g2_primitives import ( # noqa: F401 + G1_to_pubkey as py_ecc_G1_to_bytes48, + G2_to_signature as py_ecc_G2_to_bytes96, + curve_order as BLS_MODULUS, + pubkey_to_G1 as py_ecc_bytes48_to_G1, + signature_to_G2 as _signature_to_G2, + signature_to_G2 as py_ecc_bytes96_to_G2, +) from py_ecc.optimized_bls12_381 import ( # noqa: F401 + FQ, + FQ2, + FQ12 as py_ecc_GT, G1 as py_ecc_G1, G2 as py_ecc_G2, Z1 as py_ecc_Z1, Z2 as py_ecc_Z2, add as py_ecc_add, + final_exponentiate as py_ecc_final_exponentiate, multiply as py_ecc_mul, neg as py_ecc_neg, pairing as py_ecc_pairing, - final_exponentiate as py_ecc_final_exponentiate, - FQ12 as py_ecc_GT, - FQ, - FQ2, ) -from py_ecc.bls.g2_primitives import ( # noqa: F401 - curve_order as BLS_MODULUS, - G1_to_pubkey as py_ecc_G1_to_bytes48, - pubkey_to_G1 as py_ecc_bytes48_to_G1, - G2_to_signature as py_ecc_G2_to_bytes96, - signature_to_G2 as py_ecc_bytes96_to_G2, -) -from py_arkworks_bls12381 import ( - G1Point as arkworks_G1, - G2Point as arkworks_G2, - Scalar as arkworks_Scalar, - GT as arkworks_GT, -) - - -import milagro_bls_binding as milagro_bls # noqa: F401 for BLS switching option - -import py_arkworks_bls12381 as arkworks_bls # noqa: F401 for BLS switching option +from py_ecc.utils import prime_field_inv as py_ecc_prime_field_inv class py_ecc_Scalar(FQ): diff --git a/tests/core/pyspec/eth2spec/utils/hash_function.py b/tests/core/pyspec/eth2spec/utils/hash_function.py index ba749db89c..329bc7c216 100644 --- a/tests/core/pyspec/eth2spec/utils/hash_function.py +++ b/tests/core/pyspec/eth2spec/utils/hash_function.py @@ -1,7 +1,8 @@ from hashlib import sha256 -from remerkleable.byte_arrays import Bytes32 from typing import Union +from remerkleable.byte_arrays import Bytes32 + ZERO_BYTES32 = b"\x00" * 32 diff --git a/tests/core/pyspec/eth2spec/utils/kzg.py b/tests/core/pyspec/eth2spec/utils/kzg.py index ea90a46b9b..4bd3407417 100644 --- a/tests/core/pyspec/eth2spec/utils/kzg.py +++ b/tests/core/pyspec/eth2spec/utils/kzg.py @@ -3,22 +3,22 @@ # - https://github.com/asn-d6/kzgverify import json import os +from pathlib import Path from typing import ( - Tuple, Sequence, + Tuple, ) -from pathlib import Path from eth_utils import encode_hex from py_ecc.typing import ( Optimized_Point3D, ) + from eth2spec.utils import bls from eth2spec.utils.bls import ( BLS_MODULUS, ) - PRIMITIVE_ROOT_OF_UNITY = 7 diff --git a/tests/core/pyspec/eth2spec/utils/merkle_minimal.py b/tests/core/pyspec/eth2spec/utils/merkle_minimal.py index 6a6491fb4d..1a889c02f0 100644 --- a/tests/core/pyspec/eth2spec/utils/merkle_minimal.py +++ b/tests/core/pyspec/eth2spec/utils/merkle_minimal.py @@ -1,6 +1,6 @@ -from eth2spec.utils.hash_function import hash from math import log2 +from eth2spec.utils.hash_function import hash ZERO_BYTES32 = b"\x00" * 32 diff --git a/tests/core/pyspec/eth2spec/utils/ssz/ssz_impl.py b/tests/core/pyspec/eth2spec/utils/ssz/ssz_impl.py index 807c302291..f15b54b2da 100644 --- a/tests/core/pyspec/eth2spec/utils/ssz/ssz_impl.py +++ b/tests/core/pyspec/eth2spec/utils/ssz/ssz_impl.py @@ -1,8 +1,8 @@ from typing import TypeVar from remerkleable.basic import uint -from remerkleable.core import Type, View from remerkleable.byte_arrays import Bytes32 +from remerkleable.core import Type, View def ssz_serialize(obj: View) -> bytes: diff --git a/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py b/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py index a67fd642dd..4c0ae94b8e 100644 --- a/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -1,10 +1,8 @@ -from remerkleable.complex import Container, Vector, List -from remerkleable.union import Union from remerkleable.basic import ( - boolean, bit, - uint, + boolean, byte, + uint, uint8, uint16, uint32, @@ -12,19 +10,20 @@ uint128, uint256, ) -from remerkleable.bitfields import Bitvector, Bitlist +from remerkleable.bitfields import Bitlist, Bitvector from remerkleable.byte_arrays import ( - ByteVector, + ByteList, Bytes1, Bytes4, Bytes8, Bytes32, Bytes48, Bytes96, - ByteList, + ByteVector, ) -from remerkleable.core import BasicView, View, Path - +from remerkleable.complex import Container, List, Vector +from remerkleable.core import BasicView, Path, View +from remerkleable.union import Union Bytes20 = ByteVector[20] # type: ignore Bytes31 = ByteVector[31] # type: ignore diff --git a/tests/core/pyspec/eth2spec/utils/test_merkle_minimal.py b/tests/core/pyspec/eth2spec/utils/test_merkle_minimal.py index d55562c342..97c56374a5 100644 --- a/tests/core/pyspec/eth2spec/utils/test_merkle_minimal.py +++ b/tests/core/pyspec/eth2spec/utils/test_merkle_minimal.py @@ -1,6 +1,7 @@ import pytest -from .merkle_minimal import zerohashes, merkleize_chunks, get_merkle_root + from .hash_function import hash +from .merkle_minimal import get_merkle_root, merkleize_chunks, zerohashes def h(a: bytes, b: bytes) -> bytes: diff --git a/tests/core/pyspec/eth2spec/utils/test_merkle_proof_util.py b/tests/core/pyspec/eth2spec/utils/test_merkle_proof_util.py index c72e9c3b2e..aca064632b 100644 --- a/tests/core/pyspec/eth2spec/utils/test_merkle_proof_util.py +++ b/tests/core/pyspec/eth2spec/utils/test_merkle_proof_util.py @@ -1,6 +1,5 @@ import pytest - # Note: these functions are extract from merkle-proofs.md (deprecated), # the tests are temporary to show correctness while the document is still there. diff --git a/tests/generators/main.py b/tests/generators/main.py index b2df06b5e8..a15e213eaa 100644 --- a/tests/generators/main.py +++ b/tests/generators/main.py @@ -3,7 +3,6 @@ from eth2spec.gen_helpers.gen_base import gen_runner - if __name__ == "__main__": current_dir = os.path.dirname(__file__) runners_dir = os.path.join(current_dir, "runners") diff --git a/tests/generators/runners/bls.py b/tests/generators/runners/bls.py index 5a71e3f98d..a38158f997 100644 --- a/tests/generators/runners/bls.py +++ b/tests/generators/runners/bls.py @@ -2,16 +2,15 @@ BLS test vectors generator """ -import milagro_bls_binding as milagro_bls +from typing import Iterable +import milagro_bls_binding as milagro_bls from eth_utils import encode_hex -from typing import Iterable -from eth2spec.utils import bls -from eth2spec.test.helpers.constants import ALTAIR -from eth2spec.gen_helpers.gen_base.gen_typing import TestCase from eth2spec.altair import spec - +from eth2spec.gen_helpers.gen_base.gen_typing import TestCase +from eth2spec.test.helpers.constants import ALTAIR +from eth2spec.utils import bls ############################################################################### # Helper functions diff --git a/tests/generators/runners/forks.py b/tests/generators/runners/forks.py index 62131bf371..d2d1504985 100644 --- a/tests/generators/runners/forks.py +++ b/tests/generators/runners/forks.py @@ -2,7 +2,7 @@ from typing import Iterable from eth2spec.gen_helpers.gen_base.gen_typing import TestCase -from eth2spec.gen_helpers.gen_from_tests.gen import get_expected_modules, generate_from_tests +from eth2spec.gen_helpers.gen_from_tests.gen import generate_from_tests, get_expected_modules from eth2spec.test.helpers.constants import ALL_PRESETS, POST_FORK_OF diff --git a/tests/generators/runners/kzg_4844.py b/tests/generators/runners/kzg_4844.py index 06aaa7e155..826c249d11 100644 --- a/tests/generators/runners/kzg_4844.py +++ b/tests/generators/runners/kzg_4844.py @@ -24,7 +24,6 @@ encode_hex_list, ) - ############################################################################### # Test helpers ############################################################################### diff --git a/tests/generators/runners/kzg_7594.py b/tests/generators/runners/kzg_7594.py index 9c575d0859..dc60a7f405 100644 --- a/tests/generators/runners/kzg_7594.py +++ b/tests/generators/runners/kzg_7594.py @@ -21,7 +21,6 @@ encode_hex_list, ) - ############################################################################### # Test helpers ############################################################################### diff --git a/tests/generators/runners/shuffling.py b/tests/generators/runners/shuffling.py index 0947b44c6b..151f0a5b4c 100644 --- a/tests/generators/runners/shuffling.py +++ b/tests/generators/runners/shuffling.py @@ -1,10 +1,9 @@ -from typing import Iterable import random +from typing import Iterable from eth2spec.gen_helpers.gen_base.gen_typing import TestCase - from eth2spec.phase0 import mainnet as spec_mainnet, minimal as spec_minimal -from eth2spec.test.helpers.constants import PHASE0, ALL_PRESETS, MINIMAL, MAINNET +from eth2spec.test.helpers.constants import ALL_PRESETS, MAINNET, MINIMAL, PHASE0 def generate_random_bytes(rng=random.Random(5566)): diff --git a/tests/generators/runners/ssz_generic.py b/tests/generators/runners/ssz_generic.py index e28cbd22d5..72f575784b 100644 --- a/tests/generators/runners/ssz_generic.py +++ b/tests/generators/runners/ssz_generic.py @@ -1,13 +1,17 @@ from typing import Iterable + from eth2spec.gen_helpers.gen_base.gen_typing import TestCase -from .ssz_generic_cases import ssz_basic_vector -from .ssz_generic_cases import ssz_bitlist -from .ssz_generic_cases import ssz_bitvector -from .ssz_generic_cases import ssz_boolean -from .ssz_generic_cases import ssz_uints -from .ssz_generic_cases import ssz_container from eth2spec.test.helpers.constants import PHASE0 +from .ssz_generic_cases import ( + ssz_basic_vector, + ssz_bitlist, + ssz_bitvector, + ssz_boolean, + ssz_container, + ssz_uints, +) + def get_test_cases() -> Iterable[TestCase]: test_case_fns = [ diff --git a/tests/generators/runners/ssz_generic_cases/ssz_basic_vector.py b/tests/generators/runners/ssz_generic_cases/ssz_basic_vector.py index a075f7cce5..bd7ff5f962 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_basic_vector.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_basic_vector.py @@ -1,5 +1,11 @@ -from .ssz_test_case import invalid_test_case, valid_test_case +from random import Random +from typing import Dict, Type + +from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object +from eth2spec.utils.ssz.ssz_impl import serialize from eth2spec.utils.ssz.ssz_typing import ( + BasicView, + Vector, boolean, uint8, uint16, @@ -7,13 +13,9 @@ uint64, uint128, uint256, - Vector, - BasicView, ) -from eth2spec.utils.ssz.ssz_impl import serialize -from random import Random -from typing import Dict, Type -from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object + +from .ssz_test_case import invalid_test_case, valid_test_case def basic_vector_case_fn( diff --git a/tests/generators/runners/ssz_generic_cases/ssz_bitlist.py b/tests/generators/runners/ssz_generic_cases/ssz_bitlist.py index 1130c51dd0..8f76385b00 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_bitlist.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_bitlist.py @@ -1,8 +1,10 @@ -from .ssz_test_case import invalid_test_case, valid_test_case -from eth2spec.utils.ssz.ssz_typing import Bitlist -from eth2spec.utils.ssz.ssz_impl import serialize from random import Random + from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object +from eth2spec.utils.ssz.ssz_impl import serialize +from eth2spec.utils.ssz.ssz_typing import Bitlist + +from .ssz_test_case import invalid_test_case, valid_test_case def bitlist_case_fn(rng: Random, mode: RandomizationMode, limit: int): diff --git a/tests/generators/runners/ssz_generic_cases/ssz_bitvector.py b/tests/generators/runners/ssz_generic_cases/ssz_bitvector.py index 1f2856e59c..2da383354a 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_bitvector.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_bitvector.py @@ -1,8 +1,10 @@ -from .ssz_test_case import invalid_test_case, valid_test_case -from eth2spec.utils.ssz.ssz_typing import Bitvector -from eth2spec.utils.ssz.ssz_impl import serialize from random import Random + from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object +from eth2spec.utils.ssz.ssz_impl import serialize +from eth2spec.utils.ssz.ssz_typing import Bitvector + +from .ssz_test_case import invalid_test_case, valid_test_case def bitvector_case_fn( diff --git a/tests/generators/runners/ssz_generic_cases/ssz_boolean.py b/tests/generators/runners/ssz_generic_cases/ssz_boolean.py index f61be23ad6..f42868ce80 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_boolean.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_boolean.py @@ -1,6 +1,7 @@ -from .ssz_test_case import valid_test_case, invalid_test_case from eth2spec.utils.ssz.ssz_typing import boolean +from .ssz_test_case import invalid_test_case, valid_test_case + def valid_cases(): yield "true", valid_test_case(lambda: boolean(True)) diff --git a/tests/generators/runners/ssz_generic_cases/ssz_container.py b/tests/generators/runners/ssz_generic_cases/ssz_container.py index e63b8eac39..925ca4babf 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_container.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_container.py @@ -1,22 +1,24 @@ -from .ssz_test_case import invalid_test_case, valid_test_case +from random import Random +from typing import Callable, Dict, Sequence, Tuple, Type + +from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object +from eth2spec.utils.ssz.ssz_impl import serialize from eth2spec.utils.ssz.ssz_typing import ( - View, + Bitlist, + Bitvector, + ByteList, Container, + List, + Vector, + View, byte, uint8, uint16, uint32, uint64, - List, - ByteList, - Vector, - Bitvector, - Bitlist, ) -from eth2spec.utils.ssz.ssz_impl import serialize -from random import Random -from typing import Dict, Tuple, Sequence, Callable, Type -from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object + +from .ssz_test_case import invalid_test_case, valid_test_case class SingleFieldTestStruct(Container): diff --git a/tests/generators/runners/ssz_generic_cases/ssz_test_case.py b/tests/generators/runners/ssz_generic_cases/ssz_test_case.py index 264fe56954..5450b7431f 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_test_case.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_test_case.py @@ -1,7 +1,8 @@ -from eth2spec.utils.ssz.ssz_impl import serialize, hash_tree_root +from typing import Callable + from eth2spec.debug.encode import encode +from eth2spec.utils.ssz.ssz_impl import hash_tree_root, serialize from eth2spec.utils.ssz.ssz_typing import View -from typing import Callable def valid_test_case(value_fn: Callable[[], View]): diff --git a/tests/generators/runners/ssz_generic_cases/ssz_uints.py b/tests/generators/runners/ssz_generic_cases/ssz_uints.py index 962502ce29..4152cebb53 100644 --- a/tests/generators/runners/ssz_generic_cases/ssz_uints.py +++ b/tests/generators/runners/ssz_generic_cases/ssz_uints.py @@ -1,8 +1,10 @@ -from .ssz_test_case import invalid_test_case, valid_test_case -from eth2spec.utils.ssz.ssz_typing import BasicView, uint8, uint16, uint32, uint64, uint128, uint256 from random import Random from typing import Type + from eth2spec.debug.random_value import RandomizationMode, get_random_ssz_object +from eth2spec.utils.ssz.ssz_typing import BasicView, uint8, uint16, uint32, uint64, uint128, uint256 + +from .ssz_test_case import invalid_test_case, valid_test_case def uint_case_fn(rng: Random, mode: RandomizationMode, typ: Type[BasicView]): diff --git a/tests/generators/runners/ssz_generic_cases/uint_test_cases.py b/tests/generators/runners/ssz_generic_cases/uint_test_cases.py index 82704ea420..cf444d4eea 100644 --- a/tests/generators/runners/ssz_generic_cases/uint_test_cases.py +++ b/tests/generators/runners/ssz_generic_cases/uint_test_cases.py @@ -3,14 +3,14 @@ from eth_utils import ( to_tuple, ) - -import ssz -from ssz.sedes import ( - UInt, -) from renderers import ( render_test_case, ) +from ssz.sedes import ( + UInt, +) + +import ssz random.seed(0) diff --git a/tests/generators/runners/ssz_static.py b/tests/generators/runners/ssz_static.py index 3bc6ee7eff..e9983e1196 100644 --- a/tests/generators/runners/ssz_static.py +++ b/tests/generators/runners/ssz_static.py @@ -1,20 +1,17 @@ import hashlib - +from inspect import getmembers, isclass from random import Random from typing import Iterable -from inspect import getmembers, isclass +from eth2spec.debug import encode, random_value from eth2spec.gen_helpers.gen_base.gen_typing import TestCase, TestCasePart - -from eth2spec.debug import random_value, encode -from eth2spec.test.helpers.constants import TESTGEN_FORKS, MINIMAL, MAINNET from eth2spec.test.context import spec_targets -from eth2spec.utils.ssz.ssz_typing import Container +from eth2spec.test.helpers.constants import MAINNET, MINIMAL, TESTGEN_FORKS from eth2spec.utils.ssz.ssz_impl import ( hash_tree_root, serialize, ) - +from eth2spec.utils.ssz.ssz_typing import Container MAX_BYTES_LENGTH = 1000 MAX_LIST_LENGTH = 10 diff --git a/tests/generators/runners/transition.py b/tests/generators/runners/transition.py index 751d3c79ae..76a30f3b79 100644 --- a/tests/generators/runners/transition.py +++ b/tests/generators/runners/transition.py @@ -2,7 +2,7 @@ from typing import Iterable from eth2spec.gen_helpers.gen_base.gen_typing import TestCase -from eth2spec.gen_helpers.gen_from_tests.gen import get_expected_modules, generate_from_tests +from eth2spec.gen_helpers.gen_from_tests.gen import generate_from_tests, get_expected_modules from eth2spec.test.helpers.constants import ALL_PRESETS, POST_FORK_OF