Skip to content

Commit aa5ebb3

Browse files
committed
Apply suggestions by @jtraglia
1 parent a2f9b88 commit aa5ebb3

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_consolidations.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_pending_consolidation_with_pending_deposit(spec, state):
306306

307307
@with_electra_and_later
308308
@spec_state_test
309-
def test_pending_consolidation_source_balance_less_than_effective(spec, state):
309+
def test_pending_consolidation_source_balance_less_than_max_effective(spec, state):
310310
current_epoch = spec.get_current_epoch(state)
311311
source_index = spec.get_active_validator_indices(state, current_epoch)[0]
312312
target_index = spec.get_active_validator_indices(state, current_epoch)[1]
@@ -327,6 +327,8 @@ def test_pending_consolidation_source_balance_less_than_effective(spec, state):
327327

328328
pre_balance_target = state.balances[target_index]
329329

330+
assert state.balances[source_index] < spec.get_max_effective_balance(state.validators[source_index])
331+
330332
yield from run_epoch_processing_with(spec, state, "process_pending_consolidations")
331333

332334
# Pending consolidation was successfully processed
@@ -337,7 +339,7 @@ def test_pending_consolidation_source_balance_less_than_effective(spec, state):
337339

338340
@with_electra_and_later
339341
@spec_state_test
340-
def test_pending_consolidation_source_balance_greater_than_effective(spec, state):
342+
def test_pending_consolidation_source_balance_greater_than_max_effective(spec, state):
341343
current_epoch = spec.get_current_epoch(state)
342344
source_index = spec.get_active_validator_indices(state, current_epoch)[0]
343345
target_index = spec.get_active_validator_indices(state, current_epoch)[1]
@@ -353,16 +355,18 @@ def test_pending_consolidation_source_balance_greater_than_effective(spec, state
353355
)
354356
state.validators[target_index].withdrawal_credentials = eth1_withdrawal_credential
355357
# Set the source balance to be greater than effective_balance
356-
pre_balance_source = state.validators[source_index].effective_balance + spec.EFFECTIVE_BALANCE_INCREMENT // 8
358+
excess_source_balance = spec.EFFECTIVE_BALANCE_INCREMENT // 8
359+
pre_balance_source = state.validators[source_index].effective_balance + excess_source_balance
357360
state.balances[source_index] = pre_balance_source
358361

359362
pre_balance_target = state.balances[target_index]
360363

364+
source_max_effective_balance = spec.get_max_effective_balance(state.validators[source_index])
365+
assert state.balances[source_index] > source_max_effective_balance
366+
361367
yield from run_epoch_processing_with(spec, state, "process_pending_consolidations")
362368

363369
# Pending consolidation was successfully processed
364-
assert state.balances[target_index] == (
365-
pre_balance_target + spec.get_max_effective_balance(state.validators[source_index]))
366-
assert state.balances[source_index] == (
367-
pre_balance_source - spec.get_max_effective_balance(state.validators[source_index]))
370+
assert state.balances[target_index] == pre_balance_target + source_max_effective_balance
371+
assert state.balances[source_index] == excess_source_balance
368372
assert state.pending_consolidations == []

tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_registry_updates.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ def run_test_activation_queue_eligibility(spec, state, validator_index, balance)
3232
@with_electra_and_later
3333
@spec_state_test
3434
def test_activation_queue_eligibility__less_than_min_activation_balance(spec, state):
35-
# move past first two irregular epochs wrt finality
36-
next_epoch(spec, state)
37-
next_epoch(spec, state)
38-
3935
index = 3
4036
balance = spec.MIN_ACTIVATION_BALANCE - spec.EFFECTIVE_BALANCE_INCREMENT
4137
yield from run_test_activation_queue_eligibility(spec, state, index, balance)
@@ -44,10 +40,6 @@ def test_activation_queue_eligibility__less_than_min_activation_balance(spec, st
4440
@with_electra_and_later
4541
@spec_state_test
4642
def test_activation_queue_eligibility__min_activation_balance(spec, state):
47-
# move past first two irregular epochs wrt finality
48-
next_epoch(spec, state)
49-
next_epoch(spec, state)
50-
5143
index = 5
5244
balance = spec.MIN_ACTIVATION_BALANCE
5345
yield from run_test_activation_queue_eligibility(spec, state, index, balance)
@@ -56,10 +48,6 @@ def test_activation_queue_eligibility__min_activation_balance(spec, state):
5648
@with_electra_and_later
5749
@spec_state_test
5850
def test_activation_queue_eligibility__min_activation_balance_eth1_creds(spec, state):
59-
# move past first two irregular epochs wrt finality
60-
next_epoch(spec, state)
61-
next_epoch(spec, state)
62-
6351
index = 7
6452
balance = spec.MIN_ACTIVATION_BALANCE
6553
set_eth1_withdrawal_credential_with_balance(spec, state, index)
@@ -69,10 +57,6 @@ def test_activation_queue_eligibility__min_activation_balance_eth1_creds(spec, s
6957
@with_electra_and_later
7058
@spec_state_test
7159
def test_activation_queue_eligibility__min_activation_balance_compounding_creds(spec, state):
72-
# move past first two irregular epochs wrt finality
73-
next_epoch(spec, state)
74-
next_epoch(spec, state)
75-
7660
index = 11
7761
balance = spec.MIN_ACTIVATION_BALANCE
7862
set_compounding_withdrawal_credential_with_balance(spec, state, index)
@@ -82,10 +66,6 @@ def test_activation_queue_eligibility__min_activation_balance_compounding_creds(
8266
@with_electra_and_later
8367
@spec_state_test
8468
def test_activation_queue_eligibility__greater_than_min_activation_balance(spec, state):
85-
# move past first two irregular epochs wrt finality
86-
next_epoch(spec, state)
87-
next_epoch(spec, state)
88-
8969
index = 13
9070
balance = spec.MIN_ACTIVATION_BALANCE + spec.EFFECTIVE_BALANCE_INCREMENT
9171
set_compounding_withdrawal_credential_with_balance(spec, state, index)

tests/generators/epoch_processing/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
_new_electra_mods_1 = {key: 'eth2spec.test.electra.epoch_processing.test_process_' + key for key in [
4141
'effective_balance_updates',
4242
'pending_consolidations',
43+
'registry_updates',
4344
]}
4445
# This is a trick to allow tests be split into multiple files and use the same test format.
4546
_new_electra_mods_2 = {key: 'eth2spec.test.electra.epoch_processing.' + key for key in [

0 commit comments

Comments
 (0)