Add BeaconChainHarness::builder (#2707)

## Issue Addressed

NA

## Proposed Changes

This PR is near-identical to https://github.com/sigp/lighthouse/pull/2652, however it is to be merged into `unstable` instead of `merge-f2f`. Please see that PR for reasoning.

I'm making this duplicate PR to merge to `unstable` in an effort to shrink the diff between `unstable` and `merge-f2f` by doing smaller, lead-up PRs.

## Additional Info

NA
This commit is contained in:
Paul Hauner
2021-10-14 02:58:10 +00:00
parent 0a77d783a4
commit e2d09bb8ac
23 changed files with 449 additions and 438 deletions

View File

@@ -1,6 +1,5 @@
#![cfg(test)]
use crate::test_utils::*;
use beacon_chain::store::StoreConfig;
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
use beacon_chain::types::*;
use swap_or_not_shuffle::shuffle_list;
@@ -13,12 +12,11 @@ lazy_static! {
}
fn get_harness<E: EthSpec>(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<E>> {
let harness = BeaconChainHarness::new_with_store_config(
E::default(),
None,
KEYPAIRS[0..validator_count].to_vec(),
StoreConfig::default(),
);
let harness = BeaconChainHarness::builder(E::default())
.default_spec()
.keypairs(KEYPAIRS[0..validator_count].to_vec())
.fresh_ephemeral_store()
.build();
harness.advance_slot();
harness
}

View File

@@ -1,7 +1,6 @@
#![cfg(test)]
use crate::test_utils::*;
use crate::test_utils::{SeedableRng, XorShiftRng};
use beacon_chain::store::config::StoreConfig;
use beacon_chain::test_utils::{
interop_genesis_state, test_spec, BeaconChainHarness, EphemeralHarnessType,
};
@@ -29,12 +28,11 @@ fn get_harness<E: EthSpec>(
validator_count: usize,
slot: Slot,
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
let harness = BeaconChainHarness::new_with_store_config(
E::default(),
None,
KEYPAIRS[0..validator_count].to_vec(),
StoreConfig::default(),
);
let harness = BeaconChainHarness::builder(E::default())
.default_spec()
.keypairs(KEYPAIRS[0..validator_count].to_vec())
.fresh_ephemeral_store()
.build();
let skip_to_slot = slot - SLOT_OFFSET;
if skip_to_slot > Slot::new(0) {