Only load Kzg in tests if necessary and only load it once (#5555)

* Only load KZG once if necessary  in tests.
This commit is contained in:
Jimmy Chen
2024-04-12 06:14:11 +10:00
committed by GitHub
parent 34dbb32610
commit 7e49f82726
9 changed files with 46 additions and 40 deletions

View File

@@ -7,15 +7,13 @@ use beacon_chain::data_availability_checker::AvailableBlock;
use beacon_chain::schema_change::migrate_schema;
use beacon_chain::test_utils::{
mock_execution_layer_from_parts, test_spec, AttestationStrategy, BeaconChainHarness,
BlockStrategy, DiskHarnessType,
BlockStrategy, DiskHarnessType, KZG,
};
use beacon_chain::{
data_availability_checker::MaybeAvailableBlock, historical_blocks::HistoricalBlockError,
migrate::MigratorConfig, BeaconChain, BeaconChainError, BeaconChainTypes, BeaconSnapshot,
BlockError, ChainConfig, NotifyExecutionLayer, ServerSentEventHandler, WhenSlotSkipped,
};
use eth2_network_config::TRUSTED_SETUP_BYTES;
use kzg::TrustedSetup;
use lazy_static::lazy_static;
use logging::test_logger;
use maplit::hashset;
@@ -2418,9 +2416,7 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
let store = get_store(&temp2);
let spec = test_spec::<E>();
let seconds_per_slot = spec.seconds_per_slot;
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
.map_err(|e| println!("Unable to read trusted setup file: {}", e))
.unwrap();
let kzg = spec.deneb_fork_epoch.map(|_| KZG.clone());
let mock =
mock_execution_layer_from_parts(&harness.spec, harness.runtime.task_executor.clone());
@@ -2457,7 +2453,7 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
1,
)))
.execution_layer(Some(mock.el))
.trusted_setup(trusted_setup)
.kzg(kzg)
.build()
.expect("should build");