add test for sync aggregate with proposer in sync committee

This commit is contained in:
Alex Stokes 2021-07-01 17:36:30 -07:00
parent 49c433746d
commit f9b4d7f287
No known key found for this signature in database
GPG Key ID: 99B3D88FD6C55A69
1 changed files with 36 additions and 0 deletions

View File

@ -415,6 +415,42 @@ def test_proposer_in_committee_without_participation(spec, state):
) )
if proposer_is_in_sync_committee: if proposer_is_in_sync_committee:
assert state.validators[block.proposer_index].pubkey in state.current_sync_committee.pubkeys
yield from run_sync_committee_processing(spec, state, block)
return
else:
state_transition_and_sign_block(spec, state, block)
raise AssertionError("failed to find a proposer in the sync committee set; check test setup")
@with_altair_and_later
@spec_state_test
@always_bls
@with_presets([MINIMAL], reason="prefer short search to find matching proposer")
def test_proposer_in_committee_with_participation(spec, state):
committee_indices = compute_committee_indices(spec, state, state.current_sync_committee)
participation = [True for _ in committee_indices]
# NOTE: seem to reliably be getting a matching proposer in the first epoch w/ ``MINIMAL`` preset.
for _ in range(spec.SLOTS_PER_EPOCH):
block = build_empty_block_for_next_slot(spec, state)
proposer_index = block.proposer_index
proposer_pubkey = state.validators[proposer_index].pubkey
proposer_is_in_sync_committee = proposer_pubkey in state.current_sync_committee.pubkeys
# Valid sync committee signature here...
block.body.sync_aggregate = spec.SyncAggregate(
sync_committee_bits=participation,
sync_committee_signature=compute_aggregate_sync_committee_signature(
spec,
state,
block.slot - 1,
committee_indices,
)
)
if proposer_is_in_sync_committee:
assert state.validators[block.proposer_index].pubkey in state.current_sync_committee.pubkeys
yield from run_sync_committee_processing(spec, state, block) yield from run_sync_committee_processing(spec, state, block)
return return
else: else: