Simplify test helpers

This commit is contained in:
Mikhail Kalinin 2024-10-22 12:36:17 +06:00
parent 5270d7913d
commit f2e45fb774
2 changed files with 8 additions and 10 deletions

View File

@ -4,12 +4,11 @@ from eth2spec.test.helpers.withdrawals import (
def prepare_switch_to_compounding_request(spec, state, validator_index, address=None):
if address is not None:
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
validator = state.validators[validator_index]
if not spec.has_execution_withdrawal_credential(validator):
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index)
# Set the supplied address or the default one if needed
if address is not None or not spec.has_execution_withdrawal_credential(validator):
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
return spec.ConsolidationRequest(
source_address=state.validators[validator_index].withdrawal_credentials[12:],

View File

@ -139,12 +139,11 @@ def prepare_pending_withdrawal(spec, state, validator_index,
def prepare_withdrawal_request(spec, state, validator_index, address=None, amount=None):
if address is not None:
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
validator = state.validators[validator_index]
if not spec.has_execution_withdrawal_credential(validator):
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index)
# Set the supplied address or the default one if needed
if address is not None or not spec.has_execution_withdrawal_credential(validator):
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
if amount is None:
amount = spec.FULL_EXIT_REQUEST_AMOUNT