From 993997aca5ddf88d17db341791ac89156adee77b Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Sun, 22 Aug 2021 10:07:31 -0700 Subject: [PATCH] ensure no leak on "normal" transitions --- .../test/phase0/sanity/test_blocks_random.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks_random.py b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks_random.py index e0043332d..c3b55e49d 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks_random.py +++ b/tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks_random.py @@ -124,8 +124,19 @@ def _validate_is_leaking(spec, state): return spec.is_in_inactivity_leak(state) +def _validate_is_not_leaking(spec, state): + return not _validate_is_leaking(spec, state) + + # transitions +def _with_validation(transition, validation): + if isinstance(transition, Callable): + transition = transition() + transition["validation"] = validation + return transition + + def _no_op_transition(): return {} @@ -264,8 +275,9 @@ def _generate_randomized_scenarios(): # and preface each block transition with the possible leak transitions # (... either no leak or transition to a leak before applying the block transition) + _transition_without_leak = _with_validation(_no_op_transition, _validate_is_not_leaking) leak_transitions = ( - _no_op_transition, + _transition_without_leak, _transition_to_leaking, ) scenarios = [