From 820affd2aaa8e9f0d889a125d43ef0d62936eb8c Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Sun, 22 Aug 2021 09:58:54 -0700 Subject: [PATCH] extend validator set so randomized helpers have more room for operation --- tests/core/pyspec/eth2spec/test/context.py | 5 +++-- .../eth2spec/test/phase0/sanity/test_blocks_random.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index a6828f7e0..f6f120d55 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -152,12 +152,13 @@ def misc_balances(spec): return balances -def misc_balances_in_default_range(spec): +def misc_balances_in_default_range_with_many_validators(spec): """ Helper method to create a series of balances that includes some misc. balances but none that are below the ``EJECTION_BALANCE``. """ - num_validators = spec.SLOTS_PER_EPOCH * 8 + # Double validators to facilitate randomized testing + num_validators = spec.SLOTS_PER_EPOCH * 8 * 2 floor = spec.config.EJECTION_BALANCE + spec.EFFECTIVE_BALANCE_INCREMENT balances = [ max(spec.MAX_EFFECTIVE_BALANCE * 2 * i // num_validators, floor) for i in range(num_validators) 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 cead514a5..52868c744 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 @@ -3,7 +3,11 @@ import warnings from random import Random from tests.core.pyspec.eth2spec.test.helpers.constants import PHASE0, ALTAIR from typing import Callable -from tests.core.pyspec.eth2spec.test.context import misc_balances_in_default_range, with_phases, zero_activation_threshold +from tests.core.pyspec.eth2spec.test.context import ( + misc_balances_in_default_range_with_many_validators, + with_phases, + zero_activation_threshold, +) from eth2spec.test.helpers.multi_operations import ( build_random_block_from_state, ) @@ -323,7 +327,10 @@ def _iter_temporal(spec, callable_or_int): @pytest_generate_tests_adapter @with_phases([PHASE0, ALTAIR]) -@with_custom_state(balances_fn=misc_balances_in_default_range, threshold_fn=zero_activation_threshold) +@with_custom_state( + balances_fn=misc_balances_in_default_range_with_many_validators, + threshold_fn=zero_activation_threshold +) @spec_test @single_phase @always_bls