Skip to content

Commit 4218b87

Browse files
committed
Add a test for OpenMessageRepository::get_expired_open_message
1 parent 5b8c3cd commit 4218b87

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

mithril-aggregator/src/database/repository/open_message_repository.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,34 @@ mod tests {
209209
}
210210
}
211211

212+
#[tokio::test]
213+
async fn repository_get_expired_open_message() {
214+
let connection = get_connection().await;
215+
let repository = OpenMessageRepository::new(connection.clone());
216+
let epoch = Epoch(1);
217+
let signed_entity_type = SignedEntityType::MithrilStakeDistribution(epoch);
218+
219+
let mut open_message = repository
220+
.create_open_message(epoch, &signed_entity_type, &ProtocolMessage::new())
221+
.await
222+
.unwrap();
223+
224+
let open_message_result = repository
225+
.get_expired_open_message(&signed_entity_type)
226+
.await
227+
.unwrap();
228+
assert!(open_message_result.is_none());
229+
230+
open_message.expires_at = Some(Utc::now() - chrono::Days::new(100));
231+
repository.update_open_message(&open_message).await.unwrap();
232+
233+
let open_message_result = repository
234+
.get_expired_open_message(&signed_entity_type)
235+
.await
236+
.unwrap();
237+
assert!(open_message_result.is_some());
238+
}
239+
212240
#[tokio::test]
213241
async fn repository_create_open_message() {
214242
let connection = get_connection().await;

0 commit comments

Comments
 (0)