From 7eeb754f7dd1739821c5906733af7c9876aaf297 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 12 Aug 2020 21:50:36 +0800 Subject: [PATCH] Add `disable_process_reveal_deadlines` decorator --- tests/core/pyspec/eth2spec/test/context.py | 8 ++++++++ .../pyspec/eth2spec/test/phase0/sanity/test_blocks.py | 7 +++++-- tests/formats/README.md | 3 +++ tests/formats/sanity/blocks.md | 7 ++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index 68696ea0a..bc1ebe092 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -300,3 +300,11 @@ def with_phases(phases, other_phases=None): return ret return wrapper return decorator + + +def disable_process_reveal_deadlines(fn): + def entry(*args, spec: Spec, **kw): + if hasattr(spec, 'process_reveal_deadlines'): + spec.process_reveal_deadlines = lambda state: None + return fn(*args, spec=spec, **kw) + return with_meta_tags({'reveal_deadlines_setting': 1})(entry) 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 6d7ff096a..973dd3ae4 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py @@ -23,6 +23,7 @@ from eth2spec.test.helpers.shard_transitions import get_shard_transition_of_comm from eth2spec.test.context import ( PHASE0, PHASE1, spec_state_test, with_all_phases, expect_assertion_error, always_bls, with_phases, + disable_process_reveal_deadlines, ) @@ -762,8 +763,9 @@ def prepare_signed_exits(spec, state, indices): # exceeding the minimal-config randao mixes memory size. # Applies to all voluntary-exit sanity block tests. -@with_phases([PHASE0]) +@with_all_phases @spec_state_test +@disable_process_reveal_deadlines def test_voluntary_exit(spec, state): validator_index = spec.get_active_validator_indices(state, spec.get_current_epoch(state))[-1] @@ -811,8 +813,9 @@ def test_double_validator_exit_same_block(spec, state): yield 'post', None -@with_phases([PHASE0]) +@with_all_phases @spec_state_test +@disable_process_reveal_deadlines def test_multiple_different_validator_exits_same_block(spec, state): validator_indices = [ spec.get_active_validator_indices(state, spec.get_current_epoch(state))[i] diff --git a/tests/formats/README.md b/tests/formats/README.md index 63b9a5390..36a5ec21b 100644 --- a/tests/formats/README.md +++ b/tests/formats/README.md @@ -165,6 +165,9 @@ bls_setting: int -- optional, can have 3 different values: but there is no change of outcome when running the test if BLS is ON or OFF. 1: known as "BLS required" - if the test validity is strictly dependent on BLS being ON 2: known as "BLS ignored" - if the test validity is strictly dependent on BLS being OFF +reveal_deadlines_setting: -- optional, can have 2 different values: + 0: default, `process_reveal_deadlines` is ON. + 1: `process_reveal_deadlines` is OFF. ``` diff --git a/tests/formats/sanity/blocks.md b/tests/formats/sanity/blocks.md index 991bc35d2..44b37ed5e 100644 --- a/tests/formats/sanity/blocks.md +++ b/tests/formats/sanity/blocks.md @@ -7,9 +7,10 @@ Sanity tests to cover a series of one or more blocks being processed, aiming to ### `meta.yaml` ```yaml -description: string -- Optional. Description of test case, purely for debugging purposes. -bls_setting: int -- see general test-format spec. -blocks_count: int -- the number of blocks processed in this test. +description: string -- Optional. Description of test case, purely for debugging purposes. +bls_setting: int -- see general test-format spec. +reveal_deadlines_setting: int -- see general test-format spec. +blocks_count: int -- the number of blocks processed in this test. ```