From 337726cbaea061e30541280acb88ec453220563e Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 6 Aug 2024 12:04:46 -0500 Subject: [PATCH] adding no compounding test --- .../test_apply_pending_deposit.py | 42 +++++++++++++++++++ .../test_process_pending_deposits.py | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_apply_pending_deposit.py b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_apply_pending_deposit.py index 3b8588ecc..942fe9ab7 100644 --- a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_apply_pending_deposit.py +++ b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_apply_pending_deposit.py @@ -101,6 +101,48 @@ def test_apply_pending_deposit_switch_to_compounding(spec, state): assert current_credentials == compounding_credentials +@with_electra_and_later +@spec_state_test +def test_apply_pending_deposit_switch_to_compounding_no_compounding(spec, state): + amount = 100 + + # choose a value public key that's in the validator set + index = 0 + withdrawal_credentials = ( + spec.ETH1_ADDRESS_WITHDRAWAL_PREFIX + + spec.hash(pubkeys[index])[1:] + ) + # wrong compounding + compounding_credentials = ( + spec.hash(b"wrong compounding address")[:] + ) + # advance the state + next_epoch_via_block(spec, state) + state.validators[index].withdrawal_credentials = withdrawal_credentials + # set validator to be exited by current epoch + state.validators[index].exit_epoch = spec.get_current_epoch(state) - 1 + deposit_data = build_deposit_data(spec, + pubkeys[index], + privkeys[index], + amount, + compounding_credentials, + signed=True) + deposit = spec.PendingDeposit( + pubkey=pubkeys[index], + withdrawal_credentials=compounding_credentials, + amount=amount, + slot=spec.GENESIS_SLOT, + signature=deposit_data.signature, + ) + state.balances[index] = 0 + # run test + spec.apply_pending_deposit(state, deposit) + # validator balance should increase + assert state.balances[index] == amount + current_credentials = state.validators[0].withdrawal_credentials + assert current_credentials == withdrawal_credentials + + @with_electra_and_later @spec_state_test def test_apply_pending_deposit_switch_to_compounding_has_bls(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_deposits.py b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_deposits.py index 8b502c60f..aecfbd35d 100644 --- a/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_deposits.py +++ b/tests/core/pyspec/eth2spec/test/electra/epoch_processing/test_process_pending_deposits.py @@ -137,7 +137,7 @@ def test_new_deposit_non_versioned_withdrawal_credentials(spec, state): def test_pending_deposit_eth1_bridge_pending(spec, state): amount = spec.MIN_ACTIVATION_BALANCE # There are pending Eth1 bridge deposits - # state.eth1_deposit_index < state.deposit_requests_start_index + # state.eth1_deposit_index < state.deposit_requests_start_index state.deposit_requests_start_index = state.eth1_deposit_index + 1 index = 0 withdrawal_credentials = (