clean up test phase 1 testgen references

This commit is contained in:
protolambda 2021-03-29 15:38:43 +02:00
parent 2bc3e814b0
commit d28cac0e8f
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
13 changed files with 42 additions and 78 deletions

View File

@ -17,8 +17,8 @@ def apply_constants_config(spec_globals: Dict[str, Any], warn_if_unknown: bool =
# Keep the same type as the default value indicates (which may be an SSZ basic type subclass, e.g. 'Gwei') # Keep the same type as the default value indicates (which may be an SSZ basic type subclass, e.g. 'Gwei')
spec_globals[k] = spec_globals[k].__class__(v) spec_globals[k] = spec_globals[k].__class__(v)
else: else:
# Note: Phase 0 spec will not know the phase 1 config values. # Note: The phase 0 spec will not warn if Altair or later config values are applied.
# Yet, during debugging you can enable explicit warnings. # During debugging you can enable explicit warnings.
if warn_if_unknown: if warn_if_unknown:
print(f"WARNING: unknown config key: '{k}' with value: '{v}'") print(f"WARNING: unknown config key: '{k}' with value: '{v}'")

View File

@ -42,9 +42,9 @@ def transition_to_slot_via_block(spec, state, slot):
def transition_to_valid_shard_slot(spec, state): def transition_to_valid_shard_slot(spec, state):
""" """
Transition to slot `spec.PHASE_1_FORK_SLOT + 1` and fork at `spec.PHASE_1_FORK_SLOT`. Transition to slot `spec.SHARDING_FORK_SLOT + 1` and fork at `spec.SHARDING_FORK_SLOT`.
""" """
transition_to(spec, state, spec.PHASE_1_FORK_SLOT) transition_to(spec, state, spec.SHARDING_FORK_SLOT)
next_slot(spec, state) next_slot(spec, state)

View File

@ -292,8 +292,6 @@ def test_duplicate_attestation(spec, state):
assert single_state.balances[index] == dup_state.balances[index] assert single_state.balances[index] == dup_state.balances[index]
# TODO: update to all phases when https://github.com/ethereum/eth2.0-specs/pull/2024 is merged
# Currently disabled for Phase 1+ due to the mechanics of on-time-attestations complicating what should be a simple test
@with_phases([PHASE0]) @with_phases([PHASE0])
@spec_state_test @spec_state_test
def test_duplicate_participants_different_attestation_1(spec, state): def test_duplicate_participants_different_attestation_1(spec, state):
@ -334,8 +332,6 @@ def test_duplicate_participants_different_attestation_1(spec, state):
assert single_correct_state.balances[index] == dup_state.balances[index] assert single_correct_state.balances[index] == dup_state.balances[index]
# TODO: update to all phases when https://github.com/ethereum/eth2.0-specs/pull/2024 is merged
# Currently disabled for Phase 1+ due to the mechanics of on-time-attestations complicating what should be a simple test
@with_phases([PHASE0]) @with_phases([PHASE0])
@spec_state_test @spec_state_test
def test_duplicate_participants_different_attestation_2(spec, state): def test_duplicate_participants_different_attestation_2(spec, state):
@ -377,8 +373,6 @@ def test_duplicate_participants_different_attestation_2(spec, state):
assert single_correct_state.balances[index] == dup_state.balances[index] assert single_correct_state.balances[index] == dup_state.balances[index]
# TODO: update to all phases when https://github.com/ethereum/eth2.0-specs/pull/2024 is merged
# Currently disabled for Phase 1+ due to the mechanics of on-time-attestations complicating what should be a simple test
@with_phases([PHASE0]) @with_phases([PHASE0])
@spec_state_test @spec_state_test
def test_duplicate_participants_different_attestation_3(spec, state): def test_duplicate_participants_different_attestation_3(spec, state):

View File

@ -108,8 +108,8 @@ As a top level dir, it is not duplicated, and the used config can be copied righ
### `<fork or phase name>/` ### `<fork or phase name>/`
This would be: "phase0", "transferparty", "phase1", etc. Each introduces new tests, but does not copy tests that do not change. This would be: "phase0", "altair", etc. Each introduces new tests, and modifies any tests that change:
If you like to test phase 1, you run phase 0 tests, with the configuration that includes phase 1 changes. Out of scope for now however. some tests of earlier forks repeat with updated state data.
### `<test runner name>/` ### `<test runner name>/`

View File

@ -164,13 +164,12 @@ Another example, to generate tests from pytests:
```python ```python
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
@ -181,15 +180,10 @@ if __name__ == "__main__":
altair_mods = {**{key: 'eth2spec.test.altair.sanity.test_' + key for key in [ altair_mods = {**{key: 'eth2spec.test.altair.sanity.test_' + key for key in [
'blocks', 'blocks',
]}, **phase_0_mods} # also run the previous phase 0 tests ]}, **phase_0_mods} # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.sanity.test_' + key for key in [
'blocks', # more phase 1 specific block tests
'shard_blocks',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="sanity", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="sanity", specs=specs, all_mods=all_mods)

View File

@ -1,11 +1,10 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
@ -27,16 +26,17 @@ if __name__ == "__main__":
]}, ]},
**phase_0_mods, **phase_0_mods,
} # also run the previous phase 0 tests } # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.epoch_processing.test_process_' + key for key in [
'reveal_deadlines', # TODO Custody Game testgen is disabled for now
'challenge_deadlines', # custody_game_mods = {**{key: 'eth2spec.test.custody_game.epoch_processing.test_process_' + key for key in [
'custody_final_updates', # 'reveal_deadlines',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec) # 'challenge_deadlines',
# 'custody_final_updates',
# ]}, **phase_0_mods} # also run the previous phase 0 tests (but against custody game spec)
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="epoch_processing", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="epoch_processing", specs=specs, all_mods=all_mods)

View File

@ -1,23 +1,19 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
phase_0_mods = {'finality': 'eth2spec.test.phase0.finality.test_finality'} phase_0_mods = {'finality': 'eth2spec.test.phase0.finality.test_finality'}
# No additional altair or phase 1 specific finality tests, yet. altair_mods = phase_0_mods # No additional altair specific finality tests
altair_mods = phase_0_mods
phase_1_mods = phase_0_mods
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="finality", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="finality", specs=specs, all_mods=all_mods)

View File

@ -1,25 +1,22 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
phase_0_mods = {key: 'eth2spec.test.phase0.fork_choice.test_' + key for key in [ phase_0_mods = {key: 'eth2spec.test.phase0.fork_choice.test_' + key for key in [
'get_head', 'get_head',
]} ]}
# No additional Altair or phase 1 specific finality tests, yet. # No additional Altair specific finality tests, yet.
altair_mods = phase_0_mods altair_mods = phase_0_mods
phase_1_mods = phase_0_mods
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="fork_choice", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="fork_choice", specs=specs, all_mods=all_mods)

View File

@ -1,11 +1,10 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
@ -14,11 +13,9 @@ if __name__ == "__main__":
'validity', 'validity',
]} ]}
altair_mods = phase_0_mods altair_mods = phase_0_mods
phase_1_mods = phase_0_mods
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="genesis", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="genesis", specs=specs, all_mods=all_mods)

View File

@ -1,11 +1,10 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
@ -23,19 +22,19 @@ if __name__ == "__main__":
]}, ]},
**phase_0_mods, **phase_0_mods,
} # also run the previous phase 0 tests } # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.block_processing.test_process_' + key for key in [
'attestation', # TODO Custody Game testgen is disabled for now
'chunk_challenge', # custody_game_mods = {**{key: 'eth2spec.test.custody_game.block_processing.test_process_' + key for key in [
'custody_key_reveal', # 'attestation',
'custody_slashing', # 'chunk_challenge',
'early_derived_secret_reveal', # 'custody_key_reveal',
'shard_transition', # 'custody_slashing',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec) # 'early_derived_secret_reveal',
# ]}, **phase_0_mods} # also run the previous phase 0 tests (but against custody game spec)
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="operations", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="operations", specs=specs, all_mods=all_mods)

View File

@ -1,11 +1,10 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
@ -14,14 +13,12 @@ if __name__ == "__main__":
'leak', 'leak',
'random', 'random',
]} ]}
# No additional altair or phase 1 specific rewards tests, yet. # No additional altair specific rewards tests, yet.
altair_mods = phase_0_mods altair_mods = phase_0_mods
phase_1_mods = phase_0_mods
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="rewards", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="rewards", specs=specs, all_mods=all_mods)

View File

@ -1,12 +1,11 @@
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.test.context import PHASE0, ALTAIR
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
specs = (spec_phase0, spec_altair, spec_phase1) specs = (spec_phase0, spec_altair)
if __name__ == "__main__": if __name__ == "__main__":
@ -17,15 +16,10 @@ if __name__ == "__main__":
altair_mods = {**{key: 'eth2spec.test.altair.sanity.test_' + key for key in [ altair_mods = {**{key: 'eth2spec.test.altair.sanity.test_' + key for key in [
'blocks', 'blocks',
]}, **phase_0_mods} # also run the previous phase 0 tests ]}, **phase_0_mods} # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.sanity.test_' + key for key in [
'blocks', # more phase 1 specific block tests
'shard_blocks',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
all_mods = { all_mods = {
PHASE0: phase_0_mods, PHASE0: phase_0_mods,
ALTAIR: altair_mods, ALTAIR: altair_mods,
PHASE1: phase_1_mods,
} }
run_state_test_generators(runner_name="sanity", specs=specs, all_mods=all_mods) run_state_test_generators(runner_name="sanity", specs=specs, all_mods=all_mods)

View File

@ -8,9 +8,8 @@ from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
from eth2spec.debug import random_value, encode from eth2spec.debug import random_value, encode
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.altair import spec as spec_altair from eth2spec.altair import spec as spec_altair
from eth2spec.test.context import PHASE1, ALTAIR, TESTGEN_FORKS, MINIMAL, MAINNET from eth2spec.test.context import ALTAIR, TESTGEN_FORKS, MINIMAL, MAINNET
from eth2spec.utils.ssz.ssz_typing import Container from eth2spec.utils.ssz.ssz_typing import Container
from eth2spec.utils.ssz.ssz_impl import ( from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root, hash_tree_root,
@ -64,15 +63,12 @@ def create_provider(fork_name, config_name: str, seed: int, mode: random_value.R
# Apply changes to presets, this affects some of the vector types. # Apply changes to presets, this affects some of the vector types.
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_phase1)
reload(spec_altair) reload(spec_altair)
return config_name return config_name
def cases_fn() -> Iterable[gen_typing.TestCase]: def cases_fn() -> Iterable[gen_typing.TestCase]:
count = cases_if_random if chaos or mode.is_changing() else 1 count = cases_if_random if chaos or mode.is_changing() else 1
spec = spec_phase0 spec = spec_phase0
if fork_name == PHASE1:
spec = spec_phase1
if fork_name == ALTAIR: if fork_name == ALTAIR:
spec = spec_altair spec = spec_altair