Skip to content

Commit

Permalink
Remove TestRandom impl for IndexedAttestation
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Jun 17, 2024
1 parent 67ea6c6 commit b123b41
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions consensus/types/src/indexed_attestation.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -208,23 +207,6 @@ impl<E: EthSpec> Decode for IndexedAttestation<E> {
}
}

// TODO(electra): think about how to handle fork variants here
impl<E: EthSpec> TestRandom for IndexedAttestation<E> {
fn random_for_test(rng: &mut impl RngCore) -> Self {
let attesting_indices = VariableList::random_for_test(rng);
// let committee_bits: BitList<E::MaxCommitteesPerSlot> = BitList::random_for_test(rng);
let data = AttestationData::random_for_test(rng);
let signature = AggregateSignature::random_for_test(rng);

Self::Base(IndexedAttestationBase {
attesting_indices,
// committee_bits,
data,
signature,
})
}
}

/// Implementation of non-crypto-secure `Hash`, for use with `HashMap` and `HashSet`.
///
/// Guarantees `att1 == att2 -> hash(att1) == hash(att2)`.
Expand Down Expand Up @@ -333,14 +315,22 @@ mod tests {
assert!(!indexed_vote_first.is_surround_vote(&indexed_vote_second));
}

ssz_and_tree_hash_tests!(IndexedAttestation<MainnetEthSpec>);
mod base {
use super::*;
ssz_and_tree_hash_tests!(IndexedAttestationBase<MainnetEthSpec>);
}
mod electra {
use super::*;
ssz_and_tree_hash_tests!(IndexedAttestationElectra<MainnetEthSpec>);
}

fn create_indexed_attestation(
target_epoch: u64,
source_epoch: u64,
) -> IndexedAttestation<MainnetEthSpec> {
let mut rng = XorShiftRng::from_seed([42; 16]);
let mut indexed_vote = IndexedAttestation::random_for_test(&mut rng);
let mut indexed_vote =
IndexedAttestation::Base(IndexedAttestationBase::random_for_test(&mut rng));

indexed_vote.data_mut().source.epoch = Epoch::new(source_epoch);
indexed_vote.data_mut().target.epoch = Epoch::new(target_epoch);
Expand Down

0 comments on commit b123b41

Please sign in to comment.