From fd4e7dde943c2805b2c09657a838ce0e860cfeef Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Mon, 7 Sep 2020 13:34:23 +0800 Subject: [PATCH] Fix `disable_process_reveal_deadlines` decorator: should have set it back to the spec function for other test cases afterwards --- tests/core/pyspec/eth2spec/test/context.py | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index 7f58c6610..12fb93152 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -264,6 +264,24 @@ def bls_switch(fn): return entry +def disable_process_reveal_deadlines(fn): + """ + Decorator to make a function execute with `process_reveal_deadlines` OFF. + This is for testing long-range epochs transition without considering the reveal-deadline slashing effect. + """ + def entry(*args, spec: Spec, **kw): + if hasattr(spec, 'process_reveal_deadlines'): + old_state = spec.process_reveal_deadlines + spec.process_reveal_deadlines = lambda state: None + + yield from fn(*args, spec=spec, **kw) + + if hasattr(spec, 'process_reveal_deadlines'): + spec.process_reveal_deadlines = old_state + + return with_meta_tags({'reveal_deadlines_setting': 1})(entry) + + def with_all_phases(fn): """ A decorator for running a test with every phase @@ -321,14 +339,6 @@ def with_phases(phases, other_phases=None): 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) - - def with_configs(configs, reason=None): def decorator(fn): def wrapper(*args, spec: Spec, **kw):