Add TestingBeaconStateBuilder fn for cloned kps

Allows for faster test setups.

Implemented method for fork choice tests.
This commit is contained in:
Paul Hauner
2019-03-14 15:10:20 +11:00
parent ac6dc81ebf
commit f4959fc03c
2 changed files with 19 additions and 3 deletions

View File

@@ -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();