From 51355e80284e146107b3258573bed493de10658a Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 22 May 2024 15:42:59 +0200 Subject: [PATCH] more test fixes --- beacon_node/beacon_chain/src/test_utils.rs | 3 ++- .../tests/attestation_verification.rs | 2 -- .../src/per_block_processing/signature_sets.rs | 1 - consensus/types/src/attestation.rs | 18 ------------------ consensus/types/src/indexed_attestation.rs | 15 --------------- .../src/test_utils/test_random/bitfield.rs | 3 +++ 6 files changed, 5 insertions(+), 37 deletions(-) diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index 1e389f42916..783aab99d42 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -2660,7 +2660,9 @@ pub fn generate_rand_block_and_blobs( num_blobs: NumBlobs, rng: &mut impl Rng, ) -> (SignedBeaconBlock>, Vec>) { + println!("randomly generating the beacon block is the trickt part. probably beacuse attestations im guessing?"); let inner = map_fork_name!(fork_name, BeaconBlock, <_>::random_for_test(rng)); + let mut block = SignedBeaconBlock::from_block(inner, types::Signature::random_for_test(rng)); let mut blob_sidecars = vec![]; @@ -2697,7 +2699,6 @@ pub fn generate_rand_block_and_blobs( }; let (bundle, transactions) = execution_layer::test_utils::generate_blobs::(num_blobs).unwrap(); - payload.execution_payload.transactions = <_>::default(); for tx in Vec::from(transactions) { payload.execution_payload.transactions.push(tx).unwrap(); diff --git a/beacon_node/beacon_chain/tests/attestation_verification.rs b/beacon_node/beacon_chain/tests/attestation_verification.rs index e632aa1e301..b63c07a25cd 100644 --- a/beacon_node/beacon_chain/tests/attestation_verification.rs +++ b/beacon_node/beacon_chain/tests/attestation_verification.rs @@ -423,7 +423,6 @@ impl GossipTester { /* * Batch verification */ - println!("desc {}", desc); let mut results = self .harness .chain @@ -772,7 +771,6 @@ async fn aggregated_gossip_verification() { } }, |_, err| { - println!("{:?}", err); assert!(matches!( err, // Naively we should think this condition would trigger this error: diff --git a/consensus/state_processing/src/per_block_processing/signature_sets.rs b/consensus/state_processing/src/per_block_processing/signature_sets.rs index be10398a331..85dbe4da79b 100644 --- a/consensus/state_processing/src/per_block_processing/signature_sets.rs +++ b/consensus/state_processing/src/per_block_processing/signature_sets.rs @@ -437,7 +437,6 @@ where let message = slot.signing_root(domain); let signature = signed_aggregate_and_proof.message().selection_proof(); let validator_index = signed_aggregate_and_proof.message().aggregator_index(); - println!("validator index, {}", validator_index); Ok(SignatureSet::single_pubkey( signature, get_pubkey(validator_index as usize).ok_or(Error::ValidatorUnknown(validator_index))?, diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index 04d031f038d..81107be86df 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -1,7 +1,6 @@ use crate::slot_data::SlotData; use crate::{test_utils::TestRandom, Hash256, Slot}; use derivative::Derivative; -use rand::RngCore; use safe_arith::ArithError; use serde::{Deserialize, Serialize}; use ssz::Decode; @@ -95,23 +94,6 @@ impl Decode for Attestation { } } -// TODO(electra): think about how to handle fork variants here -impl TestRandom for Attestation { - fn random_for_test(rng: &mut impl RngCore) -> Self { - let aggregation_bits: BitList = BitList::random_for_test(rng); - // let committee_bits: BitList = BitList::random_for_test(rng); - let data = AttestationData::random_for_test(rng); - let signature = AggregateSignature::random_for_test(rng); - - Self::Base(AttestationBase { - aggregation_bits, - // committee_bits, - data, - signature, - }) - } -} - impl Hash for Attestation { fn hash(&self, state: &mut H) where diff --git a/consensus/types/src/indexed_attestation.rs b/consensus/types/src/indexed_attestation.rs index 4e7e061b45f..a2265cdd71b 100644 --- a/consensus/types/src/indexed_attestation.rs +++ b/consensus/types/src/indexed_attestation.rs @@ -1,7 +1,6 @@ use crate::{test_utils::TestRandom, AggregateSignature, AttestationData, EthSpec, VariableList}; use core::slice::Iter; use derivative::Derivative; -use rand::RngCore; use serde::{Deserialize, Serialize}; use ssz::Decode; use ssz::Encode; @@ -190,20 +189,6 @@ impl Decode for IndexedAttestation { } } -impl TestRandom for IndexedAttestation { - fn random_for_test(rng: &mut impl RngCore) -> Self { - let attesting_indices = VariableList::random_for_test(rng); - let data = AttestationData::random_for_test(rng); - let signature = AggregateSignature::random_for_test(rng); - - Self::Base(IndexedAttestationBase { - attesting_indices, - data, - signature, - }) - } -} - /// Implementation of non-crypto-secure `Hash`, for use with `HashMap` and `HashSet`. /// /// Guarantees `att1 == att2 -> hash(att1) == hash(att2)`. diff --git a/consensus/types/src/test_utils/test_random/bitfield.rs b/consensus/types/src/test_utils/test_random/bitfield.rs index f73f7c18c5a..ab6ab259deb 100644 --- a/consensus/types/src/test_utils/test_random/bitfield.rs +++ b/consensus/types/src/test_utils/test_random/bitfield.rs @@ -24,8 +24,11 @@ impl TestRandom for BitList { impl TestRandom for BitVector { fn random_for_test(rng: &mut impl RngCore) -> Self { + println!("check {}", N::to_usize()); let mut raw_bytes = smallvec![0; std::cmp::max(1, (N::to_usize() + 7) / 8)]; rng.fill_bytes(&mut raw_bytes); + println!("raw bytes {:?}", raw_bytes); + println!("{:?}", raw_bytes); Self::from_bytes(raw_bytes).expect("we generate a valid BitVector") } }