ensure all validators in randomized test are active

This commit is contained in:
Alex Stokes 2021-08-21 16:59:54 -07:00
parent 5094193f9a
commit 6da2c7a916
No known key found for this signature in database
GPG Key ID: 99B3D88FD6C55A69
2 changed files with 17 additions and 2 deletions

View File

@ -152,6 +152,21 @@ def misc_balances(spec):
return balances
def misc_balances_in_default_range(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
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)
]
rng = Random(1234)
rng.shuffle(balances)
return balances
def low_single_balance(spec):
"""
Helper method to create a single of balance of 1 Gwei.

View File

@ -1,7 +1,7 @@
import itertools
from random import Random
from typing import Callable
from tests.core.pyspec.eth2spec.test.context import default_activation_threshold
from tests.core.pyspec.eth2spec.test.context import default_activation_threshold, misc_balances_in_default_range
from eth2spec.test.helpers.multi_operations import (
build_random_block_from_state,
)
@ -272,7 +272,7 @@ def _iter_temporal(spec, callable_or_int):
@pytest_generate_tests_adapter
@with_all_phases
@with_custom_state(balances_fn=misc_balances, threshold_fn=default_activation_threshold)
@with_custom_state(balances_fn=misc_balances_in_default_range, threshold_fn=default_activation_threshold)
@spec_test
@single_phase
@always_bls