mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Remove TestRandom (#9006)
We have a legacy `TestRandom` trait which generates random types for testing and fuzzing. This function overlaps with `arbitrary` which is used very commonly in the ecosystem. Remove `TestRandom` and generate random type instances using `Arbitrary`. Co-Authored-By: Mac L <mjladson@pm.me> Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -19,5 +19,7 @@ types = { workspace = true }
|
||||
validator_store = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
arbitrary = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
logging = { workspace = true }
|
||||
types = { workspace = true, features = ["arbitrary"] }
|
||||
|
||||
@@ -598,14 +598,12 @@ impl DoppelgangerService {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use arbitrary::Arbitrary;
|
||||
use futures::executor::block_on;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use std::future;
|
||||
use std::time::Duration;
|
||||
use types::{
|
||||
MainnetEthSpec,
|
||||
test_utils::{SeedableRng, TestRandom, XorShiftRng},
|
||||
};
|
||||
use types::MainnetEthSpec;
|
||||
use validator_store::DoppelgangerStatus;
|
||||
|
||||
const DEFAULT_VALIDATORS: usize = 8;
|
||||
@@ -641,12 +639,12 @@ mod test {
|
||||
|
||||
impl TestBuilder {
|
||||
fn build(self) -> TestScenario {
|
||||
let mut rng = XorShiftRng::from_seed([42; 16]);
|
||||
let mut u = types::test_utils::test_unstructured();
|
||||
let slot_clock = TestingSlotClock::new(Slot::new(0), GENESIS_TIME, SLOT_DURATION);
|
||||
|
||||
TestScenario {
|
||||
validators: (0..self.validator_count)
|
||||
.map(|_| PublicKeyBytes::random_for_test(&mut rng))
|
||||
.map(|_| PublicKeyBytes::arbitrary(&mut u).unwrap())
|
||||
.collect(),
|
||||
doppelganger: DoppelgangerService::default(),
|
||||
slot_clock,
|
||||
|
||||
Reference in New Issue
Block a user