Fix `disable_process_reveal_deadlines` decorator: should have set it back to the spec function for other test cases afterwards

This commit is contained in:
Hsiao-Wei Wang 2020-09-07 13:34:23 +08:00
parent e57e1407a2
commit fd4e7dde94
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 18 additions and 8 deletions

View File

@ -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):