@@ -156,35 +156,49 @@ pub type HarnessAttestations<E> = Vec<(
156156) > ;
157157
158158impl < E : EthSpec > BeaconChainHarness < EphemeralHarnessType < E > > {
159- pub fn new ( eth_spec_instance : E , validator_keypairs : Vec < Keypair > ) -> Self {
159+ pub fn new (
160+ eth_spec_instance : E ,
161+ spec : Option < ChainSpec > ,
162+ validator_keypairs : Vec < Keypair > ,
163+ ) -> Self {
160164 Self :: new_with_store_config (
161165 eth_spec_instance,
166+ spec,
162167 validator_keypairs,
163168 StoreConfig :: default ( ) ,
164169 )
165170 }
166171
167172 pub fn new_with_store_config (
168173 eth_spec_instance : E ,
174+ spec : Option < ChainSpec > ,
169175 validator_keypairs : Vec < Keypair > ,
170176 config : StoreConfig ,
171177 ) -> Self {
172178 // Setting the target aggregators to really high means that _all_ validators in the
173179 // committee are required to produce an aggregate. This is overkill, however with small
174180 // validator counts it's the only way to be certain there is _at least one_ aggregator per
175181 // committee.
176- Self :: new_with_target_aggregators ( eth_spec_instance, validator_keypairs, 1 << 32 , config)
182+ Self :: new_with_target_aggregators (
183+ eth_spec_instance,
184+ spec,
185+ validator_keypairs,
186+ 1 << 32 ,
187+ config,
188+ )
177189 }
178190
179191 /// Instantiate a new harness with a custom `target_aggregators_per_committee` spec value
180192 pub fn new_with_target_aggregators (
181193 eth_spec_instance : E ,
194+ spec : Option < ChainSpec > ,
182195 validator_keypairs : Vec < Keypair > ,
183196 target_aggregators_per_committee : u64 ,
184197 store_config : StoreConfig ,
185198 ) -> Self {
186199 Self :: new_with_chain_config (
187200 eth_spec_instance,
201+ spec,
188202 validator_keypairs,
189203 target_aggregators_per_committee,
190204 store_config,
@@ -196,13 +210,14 @@ impl<E: EthSpec> BeaconChainHarness<EphemeralHarnessType<E>> {
196210 /// `target_aggregators_per_committee` spec value, and a `ChainConfig`
197211 pub fn new_with_chain_config (
198212 eth_spec_instance : E ,
213+ spec : Option < ChainSpec > ,
199214 validator_keypairs : Vec < Keypair > ,
200215 target_aggregators_per_committee : u64 ,
201216 store_config : StoreConfig ,
202217 chain_config : ChainConfig ,
203218 ) -> Self {
204219 let data_dir = tempdir ( ) . expect ( "should create temporary data_dir" ) ;
205- let mut spec = test_spec :: < E > ( ) ;
220+ let mut spec = spec . unwrap_or_else ( test_spec :: < E > ) ;
206221
207222 spec. target_aggregators_per_committee = target_aggregators_per_committee;
208223
@@ -250,11 +265,12 @@ impl<E: EthSpec> BeaconChainHarness<DiskHarnessType<E>> {
250265 /// Instantiate a new harness with `validator_count` initial validators.
251266 pub fn new_with_disk_store (
252267 eth_spec_instance : E ,
268+ spec : Option < ChainSpec > ,
253269 store : Arc < HotColdDB < E , LevelDB < E > , LevelDB < E > > > ,
254270 validator_keypairs : Vec < Keypair > ,
255271 ) -> Self {
256272 let data_dir = tempdir ( ) . expect ( "should create temporary data_dir" ) ;
257- let spec = test_spec :: < E > ( ) ;
273+ let spec = spec . unwrap_or_else ( test_spec :: < E > ) ;
258274
259275 let log = test_logger ( ) ;
260276 let ( shutdown_tx, shutdown_receiver) = futures:: channel:: mpsc:: channel ( 1 ) ;
@@ -294,11 +310,12 @@ impl<E: EthSpec> BeaconChainHarness<DiskHarnessType<E>> {
294310 /// Instantiate a new harness with `validator_count` initial validators.
295311 pub fn resume_from_disk_store (
296312 eth_spec_instance : E ,
313+ spec : Option < ChainSpec > ,
297314 store : Arc < HotColdDB < E , LevelDB < E > , LevelDB < E > > > ,
298315 validator_keypairs : Vec < Keypair > ,
299316 data_dir : TempDir ,
300317 ) -> Self {
301- let spec = test_spec :: < E > ( ) ;
318+ let spec = spec . unwrap_or_else ( test_spec :: < E > ) ;
302319
303320 let log = test_logger ( ) ;
304321 let ( shutdown_tx, shutdown_receiver) = futures:: channel:: mpsc:: channel ( 1 ) ;
0 commit comments