remove fork_test

This commit is contained in:
Danny Ryan 2021-03-09 16:18:30 -07:00
parent 21cdbc9b3d
commit f9b54ea03b
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
2 changed files with 5 additions and 23 deletions

View File

@ -70,7 +70,7 @@ class SpecForks(TypedDict, total=False):
def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Callable[[Any], int], def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Callable[[Any], int],
spec: Spec, phases: SpecForks, is_fork_test: bool): spec: Spec, phases: SpecForks):
p0 = phases[PHASE0] p0 = phases[PHASE0]
balances = balances_fn(p0) balances = balances_fn(p0)
@ -82,7 +82,7 @@ def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Ca
# TODO: instead of upgrading a test phase0 genesis state we can also write a phase1 state helper. # TODO: instead of upgrading a test phase0 genesis state we can also write a phase1 state helper.
# Decide based on performance/consistency results later. # Decide based on performance/consistency results later.
state = phases[PHASE1].upgrade_to_phase1(state) state = phases[PHASE1].upgrade_to_phase1(state)
elif spec.fork == LIGHTCLIENT_PATCH and not is_fork_test: # do not upgrade if spec test elif spec.fork == LIGHTCLIENT_PATCH:
state = phases[LIGHTCLIENT_PATCH].upgrade_to_lightclient_patch(state) state = phases[LIGHTCLIENT_PATCH].upgrade_to_lightclient_patch(state)
return state return state
@ -98,11 +98,10 @@ def with_custom_state(balances_fn: Callable[[Any], Sequence[int]],
def entry(*args, spec: Spec, phases: SpecForks, **kw): def entry(*args, spec: Spec, phases: SpecForks, **kw):
# make a key for the state # make a key for the state
# genesis fork version separates configs during test-generation runtime. # genesis fork version separates configs during test-generation runtime.
is_fork_test = kw.pop('fork_test') if 'fork_test' in kw else False key = (spec.fork, spec.GENESIS_FORK_VERSION, spec.__file__, balances_fn, threshold_fn)
key = (spec.fork, spec.GENESIS_FORK_VERSION, spec.__file__, balances_fn, threshold_fn, is_fork_test)
global _custom_state_cache_dict global _custom_state_cache_dict
if key not in _custom_state_cache_dict: if key not in _custom_state_cache_dict:
state = _prepare_state(balances_fn, threshold_fn, spec, phases, is_fork_test) state = _prepare_state(balances_fn, threshold_fn, spec, phases)
_custom_state_cache_dict[key] = state.get_backing() _custom_state_cache_dict[key] = state.get_backing()
# Take an entry out of the LRU. # Take an entry out of the LRU.
@ -288,16 +287,6 @@ def bls_switch(fn):
return entry return entry
def fork_test(fn):
"""
"""
def entry(*args, **kw):
# override fork test setting
kw['fork_test'] = True
return fn(*args, **kw)
return entry
def disable_process_reveal_deadlines(fn): def disable_process_reveal_deadlines(fn):
""" """
Decorator to make a function execute with `process_reveal_deadlines` OFF. Decorator to make a function execute with `process_reveal_deadlines` OFF.

View File

@ -1,7 +1,7 @@
from eth2spec.test.context import ( from eth2spec.test.context import (
PHASE0, LIGHTCLIENT_PATCH, PHASE0, LIGHTCLIENT_PATCH,
with_phases, with_phases,
with_custom_state, fork_test, with_custom_state,
spec_test, with_state, spec_test, with_state,
low_balances, misc_balances, large_validator_set, low_balances, misc_balances, large_validator_set,
) )
@ -53,7 +53,6 @@ def run_fork_test(spec, pre_state):
yield 'post', post_state yield 'post', post_state
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@spec_test @spec_test
@with_state @with_state
@ -62,7 +61,6 @@ def test_fork_base_state(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@spec_test @spec_test
@with_state @with_state
@ -72,7 +70,6 @@ def test_fork_next_epoch(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@spec_test @spec_test
@with_state @with_state
@ -82,7 +79,6 @@ def test_fork_next_epoch_with_block(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@spec_test @spec_test
@with_state @with_state
@ -93,7 +89,6 @@ def test_fork_many_next_epoch(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE) @with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test @spec_test
@ -102,7 +97,6 @@ def test_fork_random_low_balances(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE) @with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test @spec_test
@ -111,7 +105,6 @@ def test_fork_random_misc_balances(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state) yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@fork_test
@with_phases(([PHASE0])) @with_phases(([PHASE0]))
@with_custom_state(balances_fn=large_validator_set, threshold_fn=lambda spec: spec.EJECTION_BALANCE) @with_custom_state(balances_fn=large_validator_set, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test @spec_test