From 96b5733086f9d2900077132bd32885474f53e430 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 18 May 2020 12:06:24 -0600 Subject: [PATCH] cleanup set some new deposits helper for rewards tests --- tests/core/pyspec/eth2spec/test/helpers/rewards.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/rewards.py b/tests/core/pyspec/eth2spec/test/helpers/rewards.py index ac863725c..9c445f968 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/rewards.py +++ b/tests/core/pyspec/eth2spec/test/helpers/rewards.py @@ -64,13 +64,13 @@ def run_attestation_component_deltas(spec, state, component_delta_fn, matching_a def set_some_new_deposits(spec, state, rng): num_validators = len(state.validators) - # last 10th of validators are new deposits - for i in range(len(state.validators))[0:num_validators // 10]: - index = num_validators - 1 - i - mock_deposit(spec, state, index) - # Set half to eligible for activation - if i % 2 == 0: - state.validators[index].activation_eligibility_epoch = spec.get_current_epoch(state) + # Set ~1/10 to just recently deposited + for index in range(num_validators): + if rng.randrange(num_validators) < num_validators // 10: + mock_deposit(spec, state, index) + # Set ~half of selected to eligible for activation + if rng.choice([True, False]): + state.validators[index].activation_eligibility_epoch = spec.get_current_epoch(state) def exit_random_validators(spec, state, rng):