Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test verifying zero-amount pending withdrawal is correctly processed #4107

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,50 @@ def test_pending_withdrawals_with_ineffective_sweep_on_top(spec, state):
assert state.pending_partial_withdrawals == []


@with_electra_and_later
@spec_state_test
def test_pending_withdrawal_amount_zero_ineffective_sweep(spec, state):
"""
Tests processing of a zero-amount pending withdrawal when the validator is not eligible for sweep.

This test verifies that:
1. A pending withdrawal with amount=0 is still processed if validator meets eligibility requirements
2. The validator is not partially withdrawable via sweep mechanism
3. The pending withdrawal is removed from state after processing

Note: Withdrawal is processed because balance and effective balance are greater than MIN_ACTIVATION_BALANCE,
even though amount is 0 and validator is not eligible for sweep.
"""
validator_index = 0

pending_withdrawal = prepare_pending_withdrawal(
spec, state,
validator_index,
effective_balance=spec.MAX_EFFECTIVE_BALANCE_ELECTRA,
amount=0
)

# Check that validator is not partially withdrawable via sweep mechanism
assert not spec.is_partially_withdrawable_validator(
state.validators[validator_index],
state.balances[validator_index]
)

next_slot(spec, state)
execution_payload = build_empty_execution_payload(spec, state)
# Partial withdrawal should be processed because balance and effective balance are greater than MIN_ACTIVATION_BALANCE
yield from run_withdrawals_processing(
spec, state,
execution_payload,
num_expected_withdrawals=1,
fully_withdrawable_indices=[],
partial_withdrawals_indices=[],
pending_withdrawal_requests=[pending_withdrawal]
)

assert state.pending_partial_withdrawals == []


@with_electra_and_later
@spec_state_test
def test_pending_withdrawals_with_ineffective_sweep_on_top_2(spec, state):
Expand Down
Loading