Make test_fork.py truly pass

This commit is contained in:
Hsiao-Wei Wang 2021-03-09 20:31:06 +08:00
parent 6c406753f1
commit 50fb3da072
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
2 changed files with 25 additions and 23 deletions

View File

@ -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.
# Decide based on performance/consistency results later.
state = phases[PHASE1].upgrade_to_phase1(state)
elif spec.fork == LIGHTCLIENT_PATCH and not fork_test: # do not upgrade if spec ttttest
elif spec.fork == LIGHTCLIENT_PATCH and not is_fork_test: # do not upgrade if spec ttttest
state = phases[LIGHTCLIENT_PATCH].upgrade_to_lightclient_patch(state)
return state
@ -294,6 +294,7 @@ def fork_test(fn):
def entry(*args, **kw):
# override fork test setting
kw['fork_test'] = True
return fn(*args, **kw)
return entry

View File

@ -1,5 +1,5 @@
from eth2spec.test.context import (
LIGHTCLIENT_PATCH,
PHASE0, LIGHTCLIENT_PATCH,
with_phases,
with_custom_state, fork_test,
spec_test, with_state,
@ -53,39 +53,39 @@ def run_fork_test(spec, pre_state):
yield 'post', post_state
@with_phases(([LIGHTCLIENT_PATCH]))
@with_state
@spec_test
@fork_test
@with_phases(([PHASE0]))
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_base_state(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@with_phases(([LIGHTCLIENT_PATCH]))
@with_state
@spec_test
@fork_test
@with_phases(([PHASE0]))
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_next_epoch(spec, phases, state):
next_epoch(spec, state)
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@with_phases(([LIGHTCLIENT_PATCH]))
@with_state
@spec_test
@fork_test
@with_phases(([PHASE0]))
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_next_epoch_with_block(spec, phases, state):
next_epoch_via_block(spec, state)
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@with_phases(([LIGHTCLIENT_PATCH]))
@with_state
@spec_test
@fork_test
@with_phases(([PHASE0]))
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_many_next_epoch(spec, phases, state):
for _ in range(3):
@ -93,28 +93,29 @@ def test_fork_many_next_epoch(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@with_phases(([LIGHTCLIENT_PATCH]))
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@fork_test
@with_phases(([PHASE0]))
@spec_test
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_random_low_balances(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@with_phases(([LIGHTCLIENT_PATCH]))
@with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@fork_test
@with_phases(([PHASE0]))
@with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_random_misc_balances(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
@with_phases(([LIGHTCLIENT_PATCH]))
@with_custom_state(balances_fn=large_validator_set, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@fork_test
@with_phases(([PHASE0]))
@with_custom_state(balances_fn=large_validator_set, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
def test_fork_random_large_validator_set(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)