Apply PR feedback from @ralexstokes

This commit is contained in:
Hsiao-Wei Wang 2021-10-07 16:04:06 +08:00
parent 4ae8fb182e
commit ff15d0bc39
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
2 changed files with 4 additions and 4 deletions

View File

@ -118,11 +118,11 @@ def combine_mods(dict_1, dict_2):
# The duplicate dict_1 items would be ignored here. # The duplicate dict_1 items would be ignored here.
dict_3 = {**dict_1, **dict_2} dict_3 = {**dict_1, **dict_2}
intersection = list(dict_1.keys() & dict_2.keys()) intersection = dict_1.keys() & dict_2.keys()
for key in intersection: for key in intersection:
# To list # To list
if not isinstance(dict_3[key], List): if not isinstance(dict_3[key], List):
dict_3[key] = [dict_3[key], ] dict_3[key] = [dict_3[key]]
# Append dict_1 value to list # Append dict_1 value to list
if isinstance(dict_1[key], List): if isinstance(dict_1[key], List):
dict_3[key] += dict_1[key] dict_3[key] += dict_1[key]

View File

@ -23,8 +23,8 @@ from eth2spec.test.helpers.inactivity_scores import randomize_inactivity_scores
def run_sync_committee_sanity_test(spec, state, fraction_full=1.0, rng=Random(454545)): def run_sync_committee_sanity_test(spec, state, fraction_full=1.0, rng=Random(454545)):
all_pubkeys = [v.pubkey for v in state.validators] all_pubkeys = [v.pubkey for v in state.validators]
committee = [all_pubkeys.index(pubkey) for pubkey in state.current_sync_committee.pubkeys] committee = [all_pubkeys.index(pubkey) for pubkey in state.current_sync_committee.pubkeys]
selected_indices = rng.sample(list(range(len(committee))), int(len(committee) * fraction_full)) selected_indices = rng.sample(range(len(committee)), int(len(committee) * fraction_full))
sync_committee_bits = [True if i in selected_indices else False for i in range(len(committee))] sync_committee_bits = [i in selected_indices for i in range(len(committee))]
participants = [ participants = [
validator_index validator_index
for i, validator_index in enumerate(committee) for i, validator_index in enumerate(committee)