Skip to content

Commit f2e45fb

Browse files
committed
Simplify test helpers
1 parent 5270d79 commit f2e45fb

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

tests/core/pyspec/eth2spec/test/helpers/consolidations.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55

66
def prepare_switch_to_compounding_request(spec, state, validator_index, address=None):
7-
if address is not None:
8-
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
9-
107
validator = state.validators[validator_index]
11-
if not spec.has_execution_withdrawal_credential(validator):
12-
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index)
8+
9+
# Set the supplied address or the default one if needed
10+
if address is not None or not spec.has_execution_withdrawal_credential(validator):
11+
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
1312

1413
return spec.ConsolidationRequest(
1514
source_address=state.validators[validator_index].withdrawal_credentials[12:],

tests/core/pyspec/eth2spec/test/helpers/withdrawals.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,11 @@ def prepare_pending_withdrawal(spec, state, validator_index,
139139

140140

141141
def prepare_withdrawal_request(spec, state, validator_index, address=None, amount=None):
142-
if address is not None:
143-
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
144-
145142
validator = state.validators[validator_index]
146-
if not spec.has_execution_withdrawal_credential(validator):
147-
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index)
143+
144+
# Set the supplied address or the default one if needed
145+
if address is not None or not spec.has_execution_withdrawal_credential(validator):
146+
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
148147

149148
if amount is None:
150149
amount = spec.FULL_EXIT_REQUEST_AMOUNT

0 commit comments

Comments
 (0)