ensure all validators in randomized test are active
This commit is contained in:
parent
5094193f9a
commit
6da2c7a916
|
@ -152,6 +152,21 @@ def misc_balances(spec):
|
||||||
return balances
|
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):
|
def low_single_balance(spec):
|
||||||
"""
|
"""
|
||||||
Helper method to create a single of balance of 1 Gwei.
|
Helper method to create a single of balance of 1 Gwei.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import itertools
|
import itertools
|
||||||
from random import Random
|
from random import Random
|
||||||
from typing import Callable
|
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 (
|
from eth2spec.test.helpers.multi_operations import (
|
||||||
build_random_block_from_state,
|
build_random_block_from_state,
|
||||||
)
|
)
|
||||||
|
@ -272,7 +272,7 @@ def _iter_temporal(spec, callable_or_int):
|
||||||
|
|
||||||
@pytest_generate_tests_adapter
|
@pytest_generate_tests_adapter
|
||||||
@with_all_phases
|
@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
|
@spec_test
|
||||||
@single_phase
|
@single_phase
|
||||||
@always_bls
|
@always_bls
|
||||||
|
|
Loading…
Reference in New Issue