mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-20 15:38:55 +00:00
fix deposit test
This commit is contained in:
parent
05a891f801
commit
0027762619
@ -2,6 +2,7 @@ from eth2spec.test.context import (
|
||||
spec_state_test,
|
||||
with_capella_and_later,
|
||||
)
|
||||
from eth2spec.test.helpers.forks import is_post_eip7251
|
||||
from eth2spec.test.helpers.state import next_epoch_via_block
|
||||
from eth2spec.test.helpers.deposits import (
|
||||
prepare_state_and_deposit,
|
||||
@ -30,10 +31,25 @@ def test_success_top_up_to_withdrawn_validator(spec, state):
|
||||
|
||||
yield from run_deposit_processing(spec, state, deposit, validator_index)
|
||||
|
||||
assert state.balances[validator_index] == amount
|
||||
assert state.validators[validator_index].effective_balance == 0
|
||||
if is_post_eip7251(spec):
|
||||
pending_balance_deposits_len = len(state.pending_balance_deposits)
|
||||
pending_balance_deposit = state.pending_balance_deposits[pending_balance_deposits_len - 1]
|
||||
assert pending_balance_deposit.amount == amount
|
||||
assert pending_balance_deposit.index == validator_index
|
||||
else:
|
||||
assert state.balances[validator_index] == amount
|
||||
assert state.validators[validator_index].effective_balance == 0
|
||||
|
||||
validator = state.validators[validator_index]
|
||||
balance = state.balances[validator_index]
|
||||
current_epoch = spec.get_current_epoch(state)
|
||||
assert spec.is_fully_withdrawable_validator(validator, balance, current_epoch)
|
||||
|
||||
if is_post_eip7251(spec):
|
||||
has_execution_withdrawal = spec.has_execution_withdrawal_credential(validator)
|
||||
is_withdrawable = validator.withdrawable_epoch <= current_epoch
|
||||
has_non_zero_balance = pending_balance_deposit.amount > 0
|
||||
# NOTE: directly compute `is_fully_withdrawable_validator` conditions here
|
||||
# to work around how the epoch processing changed balance updates
|
||||
assert has_execution_withdrawal and is_withdrawable and has_non_zero_balance
|
||||
else:
|
||||
assert spec.is_fully_withdrawable_validator(validator, balance, current_epoch)
|
||||
|
Loading…
x
Reference in New Issue
Block a user