From b975a92e9016650bc90c4ea6619675933d70ddeb Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 18 May 2020 09:29:01 -0600 Subject: [PATCH] ensure at least one validator is slashed for slashing rewards tests --- tests/core/pyspec/eth2spec/test/helpers/rewards.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/rewards.py b/tests/core/pyspec/eth2spec/test/helpers/rewards.py index c5eace226..0433e808a 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/rewards.py +++ b/tests/core/pyspec/eth2spec/test/helpers/rewards.py @@ -83,8 +83,10 @@ def exit_random_validators(spec, state, rng): def slash_random_validators(spec, state, rng): # Slash ~1/2 of validators - for validator in state.validators: - validator.slashed = rng.choice([True, False]) + for index in range(len(state.validators)): + # slash at least one validator + if index == 0 or rng.choice([True, False]): + spec.slash_validator(state, index) def run_test_empty(spec, state, runner):