Skip to content

Commit 00a43fc

Browse files
committed
refactor(aggregator): reduce usage of configuration
The configuration struct should not be used outside of the builder, this commit leave only one usage: `dependency_injection::containers::init_state_from_fixture`
1 parent f1c0d13 commit 00a43fc

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

mithril-aggregator/src/runtime/runner.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,14 +586,15 @@ impl AggregatorRunnerTrait for AggregatorRunner {
586586

587587
#[cfg(test)]
588588
pub mod tests {
589+
use crate::dependency_injection::DependenciesBuilder;
589590
use crate::entities::AggregatorEpochSettings;
590591
use crate::services::{FakeEpochService, FakeEpochServiceBuilder, MockUpkeepService};
591592
use crate::{
592593
entities::OpenMessage,
593594
initialize_dependencies,
594595
runtime::{AggregatorRunner, AggregatorRunnerTrait},
595596
services::{MithrilStakeDistributionService, MockCertifierService},
596-
DependencyContainer, MithrilSignerRegisterer, SignerRegistrationRound,
597+
Configuration, DependencyContainer, MithrilSignerRegisterer, SignerRegistrationRound,
597598
};
598599
use async_trait::async_trait;
599600
use chrono::{DateTime, Utc};
@@ -1029,16 +1030,13 @@ pub mod tests {
10291030
.returning(|_| Ok(()))
10301031
.times(1);
10311032

1032-
let mut deps = initialize_dependencies().await;
1033+
let config = Configuration::new_sample();
1034+
let mut deps = DependenciesBuilder::new_with_stdout_logger(config.clone())
1035+
.build_dependency_container()
1036+
.await
1037+
.unwrap();
10331038
deps.certifier_service = Arc::new(mock_certifier_service);
10341039
let epoch_settings_storer = deps.epoch_settings_storer.clone();
1035-
let expected_epoch_settings = AggregatorEpochSettings {
1036-
protocol_parameters: deps.config.protocol_parameters.clone(),
1037-
cardano_transactions_signing_config: deps
1038-
.config
1039-
.cardano_transactions_signing_config
1040-
.clone(),
1041-
};
10421040
let current_epoch = deps.ticker_service.get_current_epoch().await.unwrap();
10431041
let insert_epoch = current_epoch.offset_to_epoch_settings_recording_epoch();
10441042

@@ -1055,7 +1053,15 @@ pub mod tests {
10551053
.unwrap()
10561054
.unwrap_or_else(|| panic!("should have epoch settings for epoch {insert_epoch}",));
10571055

1058-
assert_eq!(expected_epoch_settings, saved_epoch_settings);
1056+
assert_eq!(
1057+
AggregatorEpochSettings {
1058+
protocol_parameters: config.protocol_parameters.clone(),
1059+
cardano_transactions_signing_config: config
1060+
.cardano_transactions_signing_config
1061+
.clone(),
1062+
},
1063+
saved_epoch_settings
1064+
);
10591065
}
10601066

10611067
#[tokio::test]

0 commit comments

Comments
 (0)