Skip to content

Commit d9b1851

Browse files
committed
refactor(common): remove test only CardanoTransactionsSigningConfig::new
Has its value was low and it was even confusing since both parameters use the same type. This allow to remove the last usage of `cfg_test_tools` in mithril common, beside the one on the test module.
1 parent 909f175 commit d9b1851

File tree

6 files changed

+36
-38
lines changed

6 files changed

+36
-38
lines changed

mithril-aggregator/src/database/query/epoch_settings/get_epoch_settings.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ mod tests {
6969
);
7070

7171
assert_eq!(
72-
CardanoTransactionsSigningConfig::new(BlockNumber(10), BlockNumber(15)),
72+
CardanoTransactionsSigningConfig {
73+
security_parameter: BlockNumber(10),
74+
step: BlockNumber(15)
75+
},
7376
epoch_settings_record.cardano_transactions_signing_config
7477
);
7578

mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ mod tests {
6868

6969
let epoch_settings_send_to_update = AggregatorEpochSettings {
7070
protocol_parameters: fake_data::protocol_parameters(),
71-
cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new(
72-
BlockNumber(24),
73-
BlockNumber(62),
74-
),
71+
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
72+
security_parameter: BlockNumber(24),
73+
step: BlockNumber(62),
74+
},
7575
};
7676
let record_returned_by_update_query = connection
7777
.fetch_first(UpdateEpochSettingsQuery::one(

mithril-aggregator/src/database/test_helper.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ pub fn insert_epoch_settings(
205205
Epoch(1),
206206
AggregatorEpochSettings {
207207
protocol_parameters: ProtocolParameters::new(1, 2, 1.0),
208-
cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new(
209-
BlockNumber(0),
210-
BlockNumber(0),
211-
),
208+
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
209+
security_parameter: BlockNumber(0),
210+
step: BlockNumber(0),
211+
},
212212
},
213213
)
214214
.filters()
@@ -222,7 +222,10 @@ pub fn insert_epoch_settings(
222222
(
223223
epoch,
224224
ProtocolParameters::new(*epoch, epoch + 1, 1.0),
225-
CardanoTransactionsSigningConfig::new(BlockNumber(epoch * 10), BlockNumber(15)),
225+
CardanoTransactionsSigningConfig {
226+
security_parameter: BlockNumber(epoch * 10),
227+
step: BlockNumber(15),
228+
},
226229
)
227230
})
228231
{

mithril-aggregator/src/services/epoch_service.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,10 @@ mod tests {
11251125
async fn inform_epoch_get_signed_entity_config_from_its_dependencies_and_store() {
11261126
let epoch = Epoch(5);
11271127

1128-
let cardano_transactions_signing_config =
1129-
CardanoTransactionsSigningConfig::new(BlockNumber(29), BlockNumber(986));
1128+
let cardano_transactions_signing_config = CardanoTransactionsSigningConfig {
1129+
security_parameter: BlockNumber(29),
1130+
step: BlockNumber(986),
1131+
};
11301132
let allowed_discriminants = BTreeSet::from([
11311133
SignedEntityTypeDiscriminants::CardanoTransactions,
11321134
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,

mithril-aggregator/src/services/message.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -467,17 +467,17 @@ mod tests {
467467
assert_eq!(message.next_signers.len(), 3);
468468
assert_eq!(
469469
message.cardano_transactions_signing_config,
470-
Some(CardanoTransactionsSigningConfig::new(
471-
BlockNumber(0),
472-
BlockNumber(15)
473-
))
470+
Some(CardanoTransactionsSigningConfig {
471+
security_parameter: BlockNumber(0),
472+
step: BlockNumber(15)
473+
})
474474
);
475475
assert_eq!(
476476
message.next_cardano_transactions_signing_config,
477-
Some(CardanoTransactionsSigningConfig::new(
478-
BlockNumber(0),
479-
BlockNumber(15)
480-
))
477+
Some(CardanoTransactionsSigningConfig {
478+
security_parameter: BlockNumber(0),
479+
step: BlockNumber(15)
480+
})
481481
);
482482
}
483483

@@ -561,17 +561,17 @@ mod tests {
561561
#[tokio::test]
562562
async fn get_epoch_settings_message_retrieves_signing_configuration_from_epoch_service() {
563563
let current_epoch_settings = AggregatorEpochSettings {
564-
cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new(
565-
BlockNumber(100),
566-
BlockNumber(15),
567-
),
564+
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
565+
security_parameter: BlockNumber(100),
566+
step: BlockNumber(15),
567+
},
568568
..AggregatorEpochSettings::dummy()
569569
};
570570
let next_epoch_settings = AggregatorEpochSettings {
571-
cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new(
572-
BlockNumber(200),
573-
BlockNumber(15),
574-
),
571+
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
572+
security_parameter: BlockNumber(200),
573+
step: BlockNumber(15),
574+
},
575575
..AggregatorEpochSettings::dummy()
576576
};
577577
let epoch_service = FakeEpochServiceBuilder {

mithril-common/src/entities/signed_entity_config.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,6 @@ pub struct CardanoTransactionsSigningConfig {
112112
}
113113

114114
impl CardanoTransactionsSigningConfig {
115-
cfg_test_tools! {
116-
/// Create a new CardanoTransactionsSigningConfig
117-
pub fn new(security_parameter: BlockNumber, step: BlockNumber) -> Self {
118-
Self {
119-
security_parameter,
120-
step,
121-
}
122-
}
123-
}
124-
125115
/// Compute the block number to be signed based on the chain tip block number.
126116
///
127117
/// The latest block number to be signed is the highest multiple of the step less or equal than the

0 commit comments

Comments
 (0)