Skip to content

Commit 9d0a9fa

Browse files
committed
fix: update open_message.is_expired UT to reveal get_current_non_certified_open_message impl issue.
The open_message.is_expired condition was never verified.
1 parent fa9e594 commit 9d0a9fa

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

mithril-aggregator/src/runtime/runner.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,10 @@ impl AggregatorRunnerTrait for AggregatorRunner {
188188
.await
189189
.with_context(|| format!("AggregatorRunner can not get current open message for signed entity type: '{}'", &signed_entity_type))?
190190
{
191-
if !open_message.is_certified {
191+
if !open_message.is_certified && !open_message.is_expired {
192192
return Ok(Some(open_message));
193193
}
194-
if open_message.is_certified || open_message.is_expired {
195-
continue;
196-
}
194+
continue;
197195
}
198196
let protocol_message = self.compute_protocol_message(&signed_entity_type).await.with_context(|| format!("AggregatorRunner can not compute protocol message for signed_entity_type: '{signed_entity_type}'"))?;
199197
let open_message_new = self.create_open_message(&signed_entity_type, &protocol_message)
@@ -1120,26 +1118,36 @@ pub mod tests {
11201118
}
11211119

11221120
#[tokio::test]
1123-
async fn test_get_current_non_certified_open_message_should_return_existing_open_message_if_all_open_message_already_expired(
1121+
async fn test_get_current_non_certified_open_message_should_return_first_not_certified_and_not_expired_open_message(
11241122
) {
11251123
let time_point = TimePoint::dummy();
1124+
let open_message_mithril_stake_distribution_expired = OpenMessage {
1125+
signed_entity_type: SignedEntityType::MithrilStakeDistribution(time_point.epoch),
1126+
is_certified: false,
1127+
is_expired: true,
1128+
..OpenMessage::dummy()
1129+
};
11261130
let open_message_expired_cardano_immutable_files = OpenMessage {
11271131
signed_entity_type: SignedEntityType::CardanoImmutableFilesFull(fake_data::beacon()),
11281132
is_certified: false,
1129-
is_expired: true,
1133+
is_expired: false,
11301134
..OpenMessage::dummy()
11311135
};
11321136
let open_message_expected = open_message_expired_cardano_immutable_files.clone();
11331137

11341138
let mut mock_certifier_service = MockCertifierService::new();
1139+
mock_certifier_service
1140+
.expect_get_open_message()
1141+
.return_once(|_| Ok(Some(open_message_mithril_stake_distribution_expired)))
1142+
.times(1);
11351143
mock_certifier_service
11361144
.expect_get_open_message()
11371145
.return_once(|_| Ok(Some(open_message_expired_cardano_immutable_files)))
11381146
.times(1);
11391147
mock_certifier_service
11401148
.expect_mark_open_message_if_expired()
1141-
.return_once(|_| Ok(None))
1142-
.times(1);
1149+
.returning(|_| Ok(None))
1150+
.times(2);
11431151
mock_certifier_service.expect_create_open_message().never();
11441152

11451153
let mut deps = initialize_dependencies().await;

0 commit comments

Comments
 (0)