diff --git a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py index 403100c3b1..8b1e2bc553 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py @@ -8,10 +8,7 @@ from eth2spec.test.helpers.keys import privkeys from eth2spec.utils.ssz.ssz_impl import hash_tree_root from eth2spec.debug.random_value import get_random_bytes_list -from eth2spec.test.helpers.withdrawals import ( - get_expected_withdrawals, - get_random_withdrawal, -) +from eth2spec.test.helpers.withdrawals import get_expected_withdrawals from eth2spec.test.helpers.forks import ( is_post_capella, is_post_deneb, @@ -369,6 +366,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None): def build_randomized_execution_payload(spec, state, rng): + from eth2spec.test.helpers.random import exit_random_validators execution_payload = build_empty_execution_payload(spec, state) execution_payload.fee_recipient = spec.ExecutionAddress(get_random_bytes_list(rng, 20)) execution_payload.state_root = spec.Bytes32(get_random_bytes_list(rng, 32)) @@ -390,12 +388,19 @@ def build_randomized_execution_payload(spec, state, rng): get_random_tx(rng) for _ in range(num_transactions) ] + if is_post_capella(spec): - num_withdrawals = rng.randint(0, spec.MAX_WITHDRAWALS_PER_PAYLOAD) - execution_payload.withdrawals = [ - get_random_withdrawal(spec, state, rng) - for _ in range(num_withdrawals) - ] + current_epoch = spec.get_current_epoch(state) + exit_random_validators( + spec, + state, + rng, + exit_epoch=current_epoch, + withdrawable_epoch=current_epoch, + from_epoch=current_epoch + ) + execution_payload.withdrawals = get_expected_withdrawals(spec, state) + if is_post_deneb(spec): execution_payload.blob_gas_used = rng.randint(0, int(10e10)) execution_payload.excess_blob_gas = rng.randint(0, int(10e10))