mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 01:25:16 -05:00
add some more random reawrds tests
This commit is contained in:
@@ -174,6 +174,9 @@ def set_some_new_deposits(spec, state, rng):
|
||||
num_validators = len(state.validators)
|
||||
# Set ~1/10 to just recently deposited
|
||||
for index in range(num_validators):
|
||||
# If not already active, skip
|
||||
if not spec.is_active_validator(state.validators[index], spec.get_current_epoch(state)):
|
||||
continue
|
||||
if rng.randrange(num_validators) < num_validators // 10:
|
||||
mock_deposit(spec, state, index)
|
||||
# Set ~half of selected to eligible for activation
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
from random import Random
|
||||
|
||||
from eth2spec.test.context import with_all_phases, spec_state_test
|
||||
from eth2spec.test.context import (
|
||||
with_all_phases,
|
||||
spec_test,
|
||||
spec_state_test,
|
||||
with_custom_state,
|
||||
single_phase,
|
||||
low_balances, misc_balances,
|
||||
)
|
||||
import eth2spec.test.helpers.rewards as rewards_helpers
|
||||
|
||||
|
||||
@@ -20,3 +27,19 @@ def test_full_random_1(spec, state):
|
||||
@spec_state_test
|
||||
def test_full_random_2(spec, state):
|
||||
yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(3030))
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_full_random_low_balances(spec, state):
|
||||
yield from rewards_helpers.run_test_full_random(spec, state)
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_full_random_misc_balances(spec, state):
|
||||
yield from rewards_helpers.run_test_full_random(spec, state)
|
||||
|
||||
Reference in New Issue
Block a user