@@ -163,6 +163,32 @@ def test_pending_withdrawals_exiting_validator(spec, state):
163
163
assert state .pending_partial_withdrawals == []
164
164
165
165
166
+ @with_electra_and_later
167
+ @spec_state_test
168
+ def test_full_pending_withdrawals_but_first_skipped_exiting_validator (spec , state ):
169
+ # Fill the pending withdrawals, plus one which will be skipped
170
+ for index in range (spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP + 1 ):
171
+ # Note, this adds the pending withdrawal to the state
172
+ prepare_pending_withdrawal (spec , state , index )
173
+
174
+ # Ensure that there's one more than the limit, the first will be skipped
175
+ assert len (state .pending_partial_withdrawals ) == spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP + 1
176
+
177
+ # For the first pending withdrawal, set the validator as exiting
178
+ spec .initiate_validator_exit (state , 0 )
179
+
180
+ yield from run_withdrawals_processing (
181
+ spec ,
182
+ state ,
183
+ build_empty_execution_payload (spec , state ),
184
+ # We expect the first pending withdrawal to be skipped
185
+ num_expected_withdrawals = spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP
186
+ )
187
+
188
+ # Ensure all pending withdrawals were processed and the first one was skipped
189
+ assert state .pending_partial_withdrawals == []
190
+
191
+
166
192
@with_electra_and_later
167
193
@spec_state_test
168
194
def test_pending_withdrawals_low_effective_balance (spec , state ):
@@ -179,6 +205,32 @@ def test_pending_withdrawals_low_effective_balance(spec, state):
179
205
assert state .pending_partial_withdrawals == []
180
206
181
207
208
+ @with_electra_and_later
209
+ @spec_state_test
210
+ def test_full_pending_withdrawals_but_first_skipped_low_effective_balance (spec , state ):
211
+ # Fill the pending withdrawals, plus one which will be skipped
212
+ for index in range (spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP + 1 ):
213
+ # Note, this adds the pending withdrawal to the state
214
+ prepare_pending_withdrawal (spec , state , index )
215
+
216
+ # Ensure that there's one more than the limit, the first will be skipped
217
+ assert len (state .pending_partial_withdrawals ) == spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP + 1
218
+
219
+ # For the first pending withdrawal, set the validator to insufficient effective balance
220
+ state .validators [0 ].effective_balance = spec .MIN_ACTIVATION_BALANCE - spec .EFFECTIVE_BALANCE_INCREMENT
221
+
222
+ yield from run_withdrawals_processing (
223
+ spec ,
224
+ state ,
225
+ build_empty_execution_payload (spec , state ),
226
+ # We expect the first pending withdrawal to be skipped
227
+ num_expected_withdrawals = spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP
228
+ )
229
+
230
+ # Ensure all pending withdrawals were processed and the first one was skipped
231
+ assert state .pending_partial_withdrawals == []
232
+
233
+
182
234
@with_electra_and_later
183
235
@spec_state_test
184
236
def test_pending_withdrawals_no_excess_balance (spec , state ):
@@ -193,6 +245,32 @@ def test_pending_withdrawals_no_excess_balance(spec, state):
193
245
assert state .pending_partial_withdrawals == []
194
246
195
247
248
+ @with_electra_and_later
249
+ @spec_state_test
250
+ def test_full_pending_withdrawals_but_first_skipped_no_excess_balance (spec , state ):
251
+ # Fill the pending withdrawals, plus one which will be skipped
252
+ for index in range (spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP + 1 ):
253
+ # Note, this adds the pending withdrawal to the state
254
+ prepare_pending_withdrawal (spec , state , index )
255
+
256
+ # Ensure that there's one more than the limit, the first will be skipped
257
+ assert len (state .pending_partial_withdrawals ) == spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP + 1
258
+
259
+ # For the first pending withdrawal, set the validator to have no excess balance
260
+ state .balances [0 ] = spec .MIN_ACTIVATION_BALANCE
261
+
262
+ yield from run_withdrawals_processing (
263
+ spec ,
264
+ state ,
265
+ build_empty_execution_payload (spec , state ),
266
+ # We expect the first pending withdrawal to be skipped
267
+ num_expected_withdrawals = spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP
268
+ )
269
+
270
+ # Ensure all pending withdrawals were processed and the first one was skipped
271
+ assert state .pending_partial_withdrawals == []
272
+
273
+
196
274
@with_electra_and_later
197
275
@spec_state_test
198
276
def test_pending_withdrawals_with_ineffective_sweep_on_top (spec , state ):
0 commit comments