From e72edf07f9e1f35fd3cf7f21970ce85848905841 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Wed, 25 Aug 2021 10:40:15 -0700 Subject: [PATCH] consolidate call to `max` into `randrange` --- .../core/pyspec/eth2spec/test/helpers/multi_operations.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py index 075b03aa0..73ebedfe0 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py @@ -48,7 +48,7 @@ def run_slash_and_exit(spec, state, slash_index, exit_index, valid=True): def get_random_proposer_slashings(spec, state, rng): - num_slashings = max(1, rng.randrange(spec.MAX_PROPOSER_SLASHINGS)) + num_slashings = rng.randrange(1, spec.MAX_PROPOSER_SLASHINGS) active_indices = spec.get_active_validator_indices(state, spec.get_current_epoch(state)).copy() indices = [ index for index in active_indices @@ -72,7 +72,7 @@ def get_random_attester_slashings(spec, state, rng, slashed_indices=[]): """ # ensure at least one attester slashing, the max count # is small so not much room for random inclusion - num_slashings = max(1, rng.randrange(spec.MAX_ATTESTER_SLASHINGS)) + num_slashings = rng.randrange(1, spec.MAX_ATTESTER_SLASHINGS) active_indices = spec.get_active_validator_indices(state, spec.get_current_epoch(state)).copy() indices = [ index for index in active_indices @@ -100,7 +100,7 @@ def get_random_attester_slashings(spec, state, rng, slashed_indices=[]): def get_random_attestations(spec, state, rng): - num_attestations = max(1, rng.randrange(spec.MAX_ATTESTATIONS)) + num_attestations = rng.randrange(1, spec.MAX_ATTESTATIONS) attestations = [ get_valid_attestation( @@ -114,7 +114,7 @@ def get_random_attestations(spec, state, rng): def prepare_state_and_get_random_deposits(spec, state, rng): - num_deposits = max(1, rng.randrange(spec.MAX_DEPOSITS)) + num_deposits = rng.randrange(1, spec.MAX_DEPOSITS) deposit_data_leaves = [spec.DepositData() for _ in range(len(state.validators))] deposits = []