From 33c96127dac894f942ed3225400541499fa2ea30 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Tue, 24 Aug 2021 16:21:45 -0700 Subject: [PATCH] fix bug with random sync aggregate helper --- .../pyspec/eth2spec/test/helpers/multi_operations.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py index cfc2c4a0f..83494182e 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py @@ -217,14 +217,18 @@ def run_test_full_random_operations(spec, state, rng=Random(2080)): def get_random_sync_aggregate(spec, state, fraction_participated=1.0, rng=Random(2099)): committee_indices = compute_committee_indices(spec, state, state.current_sync_committee) participant_count = int(len(committee_indices) * fraction_participated) - participants = rng.sample(committee_indices, participant_count) + participant_indices = rng.sample(range(len(committee_indices)), participant_count) + participants = [ + committee_indices[index] + for index in participant_indices + ] signature = compute_aggregate_sync_committee_signature( spec, state, - state.slot, + state.slot - 1, participants, ) return spec.SyncAggregate( - sync_committee_bits=[index in participants for index in committee_indices], + sync_committee_bits=[index in participant_indices for index in range(len(committee_indices))], sync_committee_signature=signature, )