Skip to content

Commit

Permalink
minor suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww authored Nov 28, 2024
1 parent 99f82e7 commit d2072df
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/core/pyspec/eth2spec/test/electra/sanity/test_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
from eth2spec.test.helpers.state import transition_to


def run_epoch_processing(spec, state, pending_deposits=[], pending_consolidations=[]):
def run_epoch_processing(spec, state, pending_deposits=None, pending_consolidations=None):
if pending_deposits is None:
pending_deposits = []
if pending_consolidations is None:
pending_consolidations = []
# Transition to the last slot of the epoch
slot = state.slot + spec.SLOTS_PER_EPOCH - (state.slot % spec.SLOTS_PER_EPOCH) - 1
transition_to(spec, state, slot)
Expand All @@ -29,7 +33,7 @@ def test_multiple_pending_deposits_same_pubkey(spec, state):
deposit = prepare_pending_deposit(spec, validator_index=index, amount=spec.MIN_ACTIVATION_BALANCE, signed=True)
pending_deposits = [deposit, deposit]

yield from run_epoch_processing(spec, state, pending_deposits)
yield from run_epoch_processing(spec, state, pending_deposits=pending_deposits)

# Check deposit balance is applied correctly
assert state.balances[index] == sum(d.amount for d in pending_deposits)
Expand All @@ -47,7 +51,7 @@ def test_multiple_pending_deposits_same_pubkey_compounding(spec, state):
)
pending_deposits = [deposit, deposit]

yield from run_epoch_processing(spec, state, pending_deposits)
yield from run_epoch_processing(spec, state, pending_deposits=pending_deposits)

# Check deposit balance is applied correctly
assert state.balances[index] == sum(d.amount for d in pending_deposits)
Expand All @@ -69,7 +73,7 @@ def test_multiple_pending_deposits_same_pubkey_below_upward_threshold(spec, stat
)
pending_deposits = [deposit_0, deposit_1]

yield from run_epoch_processing(spec, state, pending_deposits)
yield from run_epoch_processing(spec, state, pending_deposits=pending_deposits)

# Check deposit balance is applied correctly
assert state.balances[index] == sum(d.amount for d in pending_deposits)
Expand Down Expand Up @@ -116,6 +120,11 @@ def test_pending_consolidation(spec, state):
)
pending_consolidations = [spec.PendingConsolidation(source_index=source_index, target_index=target_index)]

assert state.balances[source_index] == spec.MIN_ACTIVATION_BALANCE
assert state.validators[source_index].effective_balance == spec.MIN_ACTIVATION_BALANCE
assert state.balances[target_index] == spec.MIN_ACTIVATION_BALANCE
assert state.validators[target_index].effective_balance == spec.MIN_ACTIVATION_BALANCE

yield from run_epoch_processing(spec, state, pending_consolidations=pending_consolidations)

# Check the consolidation is processed correctly
Expand Down

0 comments on commit d2072df

Please sign in to comment.