From 01a2c7ba0755e79731b42ea1af59b34e898000c9 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Mon, 13 May 2024 15:27:52 +0300 Subject: [PATCH 1/2] Add `test_fork_has_compounding_withdrawal_credential` test case --- .../test/electra/fork/test_electra_fork_basic.py | 14 ++++++++++++++ .../pyspec/eth2spec/test/helpers/electra/fork.py | 2 ++ 2 files changed, 16 insertions(+) diff --git a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py index 3bd6350b34..15961f40e1 100644 --- a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py @@ -80,3 +80,17 @@ def test_fork_random_misc_balances(spec, phases, state): @with_meta_tags(ELECTRA_FORK_TEST_META_TAGS) def test_fork_random_large_validator_set(spec, phases, state): yield from run_fork_test(phases[ELECTRA], state) + + +@with_phases(phases=[DENEB], other_phases=[ELECTRA]) +@spec_test +@with_state +@with_meta_tags(ELECTRA_FORK_TEST_META_TAGS) +def test_fork_has_compounding_withdrawal_credential(spec, phases, state): + post_spec = phases[ELECTRA] + validator = state.validators[0] + state.balances[0] = post_spec.MIN_ACTIVATION_BALANCE + 1 + validator.withdrawal_credentials = post_spec.COMPOUNDING_WITHDRAWAL_PREFIX + validator.withdrawal_credentials[1:] + post_state = yield from run_fork_test(post_spec, state) + + assert len(post_state.pending_balance_deposits) > 0 diff --git a/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py b/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py index 39a43a5233..0067a8cc07 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py +++ b/tests/core/pyspec/eth2spec/test/helpers/electra/fork.py @@ -63,3 +63,5 @@ def run_fork_test(post_spec, pre_state): assert post_state.fork.epoch == post_spec.get_current_epoch(post_state) yield 'post', post_state + + return post_state From 8b264704aa937d2cf8ee3bd42ed32f48a4428c66 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Mon, 13 May 2024 15:37:32 +0300 Subject: [PATCH 2/2] Add `test_fork_pre_activation` test case --- .../test/electra/fork/test_electra_fork_basic.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py index 15961f40e1..852521a32b 100644 --- a/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py +++ b/tests/core/pyspec/eth2spec/test/electra/fork/test_electra_fork_basic.py @@ -82,6 +82,18 @@ def test_fork_random_large_validator_set(spec, phases, state): yield from run_fork_test(phases[ELECTRA], state) +@with_phases(phases=[DENEB], other_phases=[ELECTRA]) +@spec_test +@with_state +@with_meta_tags(ELECTRA_FORK_TEST_META_TAGS) +def test_fork_pre_activation(spec, phases, state): + post_spec = phases[ELECTRA] + state.validators[0].activation_epoch = spec.FAR_FUTURE_EPOCH + post_state = yield from run_fork_test(post_spec, state) + + assert len(post_state.pending_balance_deposits) > 0 + + @with_phases(phases=[DENEB], other_phases=[ELECTRA]) @spec_test @with_state