This commit is contained in:
Potuz 2022-11-04 09:13:21 -03:00
parent 9973e9f29f
commit e15b02d16f
2 changed files with 6 additions and 6 deletions

View File

@ -299,7 +299,7 @@ def get_expected_withdrawals(state: BeaconState) -> Sequence[Withdrawal]:
address=ExecutionAddress(val.withdrawal_credentials[12:]), address=ExecutionAddress(val.withdrawal_credentials[12:]),
amount=balance, amount=balance,
)) ))
withdrawal_index += 1 withdrawal_index += WithdrawalIndex(1)
elif is_partially_withdrawable_validator(val, balance): elif is_partially_withdrawable_validator(val, balance):
withdrawals.append(Withdrawal( withdrawals.append(Withdrawal(
index=withdrawal_index, index=withdrawal_index,
@ -307,7 +307,7 @@ def get_expected_withdrawals(state: BeaconState) -> Sequence[Withdrawal]:
address=ExecutionAddress(val.withdrawal_credentials[12:]), address=ExecutionAddress(val.withdrawal_credentials[12:]),
amount=balance - MAX_EFFECTIVE_BALANCE, amount=balance - MAX_EFFECTIVE_BALANCE,
)) ))
withdrawal_index += 1 withdrawal_index += WithdrawalIndex(1)
if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD: if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD:
break break
return withdrawals return withdrawals

View File

@ -23,6 +23,7 @@ from eth2spec.test.helpers.withdrawals import (
set_validator_partially_withdrawable, set_validator_partially_withdrawable,
) )
def prepare_expected_withdrawals(spec, state, def prepare_expected_withdrawals(spec, state,
num_full_withdrawals=0, num_partial_withdrawals=0, rng=random.Random(5566)): num_full_withdrawals=0, num_partial_withdrawals=0, rng=random.Random(5566)):
assert num_full_withdrawals + num_partial_withdrawals <= len(state.validators) assert num_full_withdrawals + num_partial_withdrawals <= len(state.validators)
@ -297,6 +298,7 @@ def test_fail_a_lot_partially_withdrawable_too_few_in_withdrawals(spec, state):
yield from run_withdrawals_processing(spec, state, execution_payload, valid=False) yield from run_withdrawals_processing(spec, state, execution_payload, valid=False)
@with_capella_and_later @with_capella_and_later
@spec_state_test @spec_state_test
def test_fail_a_lot_mixed_withdrawable_in_queue_too_few_in_withdrawals(spec, state): def test_fail_a_lot_mixed_withdrawable_in_queue_too_few_in_withdrawals(spec, state):
@ -310,7 +312,6 @@ def test_fail_a_lot_mixed_withdrawable_in_queue_too_few_in_withdrawals(spec, sta
yield from run_withdrawals_processing(spec, state, execution_payload, valid=False) yield from run_withdrawals_processing(spec, state, execution_payload, valid=False)
# #
# Failure cases in which the withdrawals in the execution_payload are incorrect # Failure cases in which the withdrawals in the execution_payload are incorrect
# #
@ -794,7 +795,6 @@ def test_random_partial_withdrawals_5(spec, state):
# Tests with multiple blocks # Tests with multiple blocks
@with_capella_and_later @with_capella_and_later
@spec_state_test @spec_state_test
def test_success_two_payloads(spec, state): def test_success_two_payloads(spec, state):
@ -817,6 +817,7 @@ def test_success_two_payloads(spec, state):
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices) verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
assert state.next_withdrawal_index == next_withdrawal_index + spec.MAX_WITHDRAWALS_PER_PAYLOAD * 2 assert state.next_withdrawal_index == next_withdrawal_index + spec.MAX_WITHDRAWALS_PER_PAYLOAD * 2
@with_capella_and_later @with_capella_and_later
@spec_state_test @spec_state_test
def test_fail_second_payload_isnt_compatible(spec, state): def test_fail_second_payload_isnt_compatible(spec, state):
@ -836,5 +837,4 @@ def test_fail_second_payload_isnt_compatible(spec, state):
execution_payload = build_empty_execution_payload(spec, state) execution_payload = build_empty_execution_payload(spec, state)
state.next_withdrawal_index += 1 state.next_withdrawal_index += 1
yield from run_withdrawals_processing(spec, state, execution_payload) yield from run_withdrawals_processing(spec, state, execution_payload, valid=False)