From 722cdc903b12611de27916a57eeecfa3224f2279 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 27 May 2020 17:34:49 +1000 Subject: [PATCH] Fix broken attestation verification test --- .../tests/attestation_verification.rs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/beacon_node/beacon_chain/tests/attestation_verification.rs b/beacon_node/beacon_chain/tests/attestation_verification.rs index 2243396096..3ec9831f67 100644 --- a/beacon_node/beacon_chain/tests/attestation_verification.rs +++ b/beacon_node/beacon_chain/tests/attestation_verification.rs @@ -87,7 +87,7 @@ fn get_valid_unaggregated_attestation( fn get_valid_aggregated_attestation( chain: &BeaconChain, - aggregate: Attestation, + mut aggregate: Attestation, ) -> (SignedAggregateAndProof, usize, SecretKey) { let state = &chain.head().expect("should get head").beacon_state; let current_slot = chain.slot().expect("should get slot"); @@ -97,10 +97,11 @@ fn get_valid_aggregated_attestation( .expect("should get committees"); let committee_len = committee.committee.len(); - let (aggregator_index, aggregator_sk) = committee + let (aggregator_committee_pos, aggregator_index, aggregator_sk) = committee .committee .iter() - .find_map(|&val_index| { + .enumerate() + .find_map(|(committee_pos, &val_index)| { let aggregator_sk = generate_deterministic_keypair(val_index).sk; let proof = SelectionProof::new::( @@ -112,13 +113,26 @@ fn get_valid_aggregated_attestation( ); if proof.is_aggregator(committee_len, &chain.spec).unwrap() { - Some((val_index, aggregator_sk)) + Some((committee_pos, val_index, aggregator_sk)) } else { None } }) .expect("should find aggregator for committee"); + // FIXME(v0.12): this can be removed once the verification rules are updated for v0.12 + // I needed to add it because the test only *happened* to work because aggregator and attester + // indices were the same before! + aggregate + .sign( + &aggregator_sk, + aggregator_committee_pos, + &state.fork, + chain.genesis_validators_root, + &chain.spec, + ) + .expect("should sign attestation"); + let signed_aggregate = SignedAggregateAndProof::from_aggregate( aggregator_index as u64, aggregate,