Skip to content

Commit 3d26bbc

Browse files
mkalininjtraglia
authored andcommitted
Test consolidation with same source and target (#4259)
1 parent d3ff53a commit 3d26bbc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,39 @@ def test_switch_to_compounding_with_pending_consolidations_at_limit(spec, state)
562562
# Tests that should fail
563563

564564

565+
@with_electra_and_later
566+
@with_presets([MINIMAL], "need sufficient consolidation churn limit")
567+
@with_custom_state(
568+
balances_fn=scaled_churn_balances_exceed_activation_exit_churn_limit,
569+
threshold_fn=default_activation_threshold,
570+
)
571+
@spec_test
572+
@single_phase
573+
def test_incorrect_same_source_target(spec, state):
574+
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for consolidation
575+
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
576+
577+
# Set up an otherwise correct consolidation
578+
current_epoch = spec.get_current_epoch(state)
579+
source_index = spec.get_active_validator_indices(state, current_epoch)[0]
580+
# Set source and target to be the same
581+
target_index = source_index
582+
source_address = b"\x22" * 20
583+
# Make source/target a compounding validator (0x02) so this request isn't a
584+
# valid switch to compounding request. To be a valid switch to compounding
585+
# request, the source validator must be an eth1 validator (0x01).
586+
set_compounding_withdrawal_credential_with_balance(
587+
spec, state, target_index, address=source_address
588+
)
589+
consolidation = spec.ConsolidationRequest(
590+
source_address=source_address,
591+
source_pubkey=state.validators[source_index].pubkey,
592+
target_pubkey=state.validators[target_index].pubkey,
593+
)
594+
595+
yield from run_consolidation_processing(spec, state, consolidation, success=False)
596+
597+
565598
@with_electra_and_later
566599
@with_presets([MINIMAL], "need sufficient consolidation churn limit")
567600
@with_custom_state(

0 commit comments

Comments
 (0)