@@ -382,15 +382,25 @@ pub trait ConfigurationSource {
382382 fn get_leader_aggregator_epoch_settings_configuration (
383383 & self ,
384384 ) -> StdResult < AggregatorEpochSettings > {
385+ let allowed_discriminants = self . compute_allowed_signed_entity_types_discriminants ( ) ?;
386+
387+ let cardano_transactions_signing_config = if allowed_discriminants
388+ . contains ( & SignedEntityTypeDiscriminants :: CardanoTransactions )
389+ {
390+ let cardano_transactions_signing_config =
391+ self . cardano_transactions_signing_config ( ) . with_context (
392+ || "Configuration `cardano_transactions_signing_config` is mandatory for a Leader Aggregator when `CardanoTransactions` is enabled in `signed_entity_types`"
393+ ) ?;
394+ Some ( cardano_transactions_signing_config)
395+ } else {
396+ None
397+ } ;
398+
385399 Ok ( AggregatorEpochSettings {
386400 protocol_parameters : self . protocol_parameters ( ) . with_context (
387401 || "Configuration `protocol_parameters` is mandatory for a Leader Aggregator" ,
388402 ) ?,
389- cardano_transactions_signing_config : self
390- . cardano_transactions_signing_config ( )
391- . with_context (
392- || "Configuration `cardano_transactions_signing_config` is mandatory for a Leader Aggregator" ,
393- ) ?,
403+ cardano_transactions_signing_config,
394404 } )
395405 }
396406
@@ -1152,6 +1162,7 @@ impl Source for DefaultConfiguration {
11521162#[ cfg( test) ]
11531163mod test {
11541164 use mithril_common:: temp_dir;
1165+ use mithril_common:: test:: double:: fake_data;
11551166
11561167 use super :: * ;
11571168
@@ -1315,6 +1326,80 @@ mod test {
13151326 assert ! ( !config. is_follower_aggregator( ) ) ;
13161327 }
13171328
1329+ mod get_leader_aggregator_epoch_settings_configuration {
1330+ use super :: * ;
1331+
1332+ #[ test]
1333+ fn succeed_when_cardano_transactions_is_disabled_and_cardano_transactions_signing_config_is_not_set ( )
1334+ {
1335+ let epoch_settings = ServeCommandConfiguration {
1336+ signed_entity_types : None ,
1337+ cardano_transactions_signing_config : None ,
1338+ protocol_parameters : Some ( ProtocolParameters :: new ( 1 , 2 , 3.1 ) ) ,
1339+ ..ServeCommandConfiguration :: new_sample ( temp_dir ! ( ) )
1340+ }
1341+ . get_leader_aggregator_epoch_settings_configuration ( )
1342+ . unwrap ( ) ;
1343+
1344+ assert_eq ! (
1345+ AggregatorEpochSettings {
1346+ protocol_parameters: ProtocolParameters :: new( 1 , 2 , 3.1 ) ,
1347+ cardano_transactions_signing_config: None
1348+ } ,
1349+ epoch_settings
1350+ ) ;
1351+ }
1352+
1353+ #[ test]
1354+ fn succeed_when_cardano_transactions_is_enabled_and_cardano_transactions_signing_config_is_set ( )
1355+ {
1356+ let epoch_settings = ServeCommandConfiguration {
1357+ signed_entity_types : Some (
1358+ SignedEntityTypeDiscriminants :: CardanoTransactions . to_string ( ) ,
1359+ ) ,
1360+ cardano_transactions_signing_config : Some ( CardanoTransactionsSigningConfig {
1361+ security_parameter : BlockNumber ( 10 ) ,
1362+ step : BlockNumber ( 30 ) ,
1363+ } ) ,
1364+ protocol_parameters : Some ( ProtocolParameters :: new ( 2 , 3 , 4.1 ) ) ,
1365+ ..ServeCommandConfiguration :: new_sample ( temp_dir ! ( ) )
1366+ }
1367+ . get_leader_aggregator_epoch_settings_configuration ( )
1368+ . unwrap ( ) ;
1369+
1370+ assert_eq ! (
1371+ AggregatorEpochSettings {
1372+ protocol_parameters: ProtocolParameters :: new( 2 , 3 , 4.1 ) ,
1373+ cardano_transactions_signing_config: Some ( CardanoTransactionsSigningConfig {
1374+ security_parameter: BlockNumber ( 10 ) ,
1375+ step: BlockNumber ( 30 ) ,
1376+ } , )
1377+ } ,
1378+ epoch_settings
1379+ ) ;
1380+ }
1381+
1382+ #[ test]
1383+ fn fails_when_cardano_transactions_is_enabled_without_associated_config ( ) {
1384+ let error = ServeCommandConfiguration {
1385+ cardano_transactions_signing_config : None ,
1386+ signed_entity_types : Some (
1387+ SignedEntityTypeDiscriminants :: CardanoTransactions . to_string ( ) ,
1388+ ) ,
1389+ protocol_parameters : Some ( fake_data:: protocol_parameters ( ) ) ,
1390+ ..ServeCommandConfiguration :: new_sample ( temp_dir ! ( ) )
1391+ }
1392+ . get_leader_aggregator_epoch_settings_configuration ( )
1393+ . unwrap_err ( ) ;
1394+
1395+ assert ! (
1396+ error
1397+ . to_string( )
1398+ . contains( "Configuration `cardano_transactions_signing_config` is mandatory" )
1399+ ) ;
1400+ }
1401+ }
1402+
13181403 #[ test]
13191404 fn serialized_ancillary_files_signer_config_use_snake_case_for_keys_and_kebab_case_for_type_value ( )
13201405 {
0 commit comments