mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-12 11:44:41 +00:00
add spec test case for rewards with exited validators and _no_ leak
This commit is contained in:
parent
e341f4e1f8
commit
7cb5901ee6
@ -255,7 +255,19 @@ def run_get_inactivity_penalty_deltas(spec, state):
|
||||
else:
|
||||
assert penalties[index] > base_penalty
|
||||
else:
|
||||
assert penalties[index] == 0
|
||||
if not is_post_altair(spec):
|
||||
assert penalties[index] == 0
|
||||
continue
|
||||
else:
|
||||
# post altair, this penalty is derived from the inactivity score
|
||||
# regardless if the state is leaking or not...
|
||||
if index in matching_attesting_indices:
|
||||
assert penalties[index] == 0
|
||||
else:
|
||||
# copied from spec:
|
||||
penalty_numerator = state.validators[index].effective_balance * state.inactivity_scores[index]
|
||||
penalty_denominator = spec.config.INACTIVITY_SCORE_BIAS * spec.INACTIVITY_PENALTY_QUOTIENT_ALTAIR
|
||||
assert penalties[index] == penalty_numerator // penalty_denominator
|
||||
|
||||
|
||||
def transition_state_to_leak(spec, state, epochs=None):
|
||||
|
@ -9,6 +9,7 @@ from eth2spec.test.context import (
|
||||
low_balances, misc_balances,
|
||||
)
|
||||
import eth2spec.test.helpers.rewards as rewards_helpers
|
||||
from eth2spec.test.helpers.random import randomize_state, patch_state_to_non_leaking
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@ -57,3 +58,14 @@ def test_full_random_low_balances_1(spec, state):
|
||||
@single_phase
|
||||
def test_full_random_misc_balances(spec, state):
|
||||
yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(7070))
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@spec_state_test
|
||||
def test_full_random_without_leak_0(spec, state):
|
||||
rng = Random(1010)
|
||||
randomize_state(spec, state, rng)
|
||||
assert spec.is_in_inactivity_leak(state)
|
||||
patch_state_to_non_leaking(spec, state)
|
||||
assert not spec.is_in_inactivity_leak(state)
|
||||
yield from rewards_helpers.run_deltas(spec, state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user