mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Add TestingBeaconStateBuilder fn for cloned kps
Allows for faster test setups. Implemented method for fork choice tests.
This commit is contained in:
@@ -74,6 +74,22 @@ impl TestingBeaconStateBuilder {
|
||||
TestingBeaconStateBuilder::from_keypairs(keypairs, spec)
|
||||
}
|
||||
|
||||
/// Uses the given keypair for all validators.
|
||||
pub fn from_single_keypair(
|
||||
validator_count: usize,
|
||||
keypair: &Keypair,
|
||||
spec: &ChainSpec,
|
||||
) -> Self {
|
||||
debug!("Generating {} cloned keypairs...", validator_count);
|
||||
|
||||
let mut keypairs = Vec::with_capacity(validator_count);
|
||||
for _ in 0..validator_count {
|
||||
keypairs.push(keypair.clone())
|
||||
}
|
||||
|
||||
TestingBeaconStateBuilder::from_keypairs(keypairs, spec)
|
||||
}
|
||||
|
||||
/// Creates the builder from an existing set of keypairs.
|
||||
pub fn from_keypairs(keypairs: Vec<Keypair>, spec: &ChainSpec) -> Self {
|
||||
let validator_count = keypairs.len();
|
||||
|
||||
Reference in New Issue
Block a user