From 6bad9abefaf3e171e8a7c0169ab0063dad58c7e3 Mon Sep 17 00:00:00 2001 From: sfauvel Date: Wed, 27 Nov 2024 16:14:58 +0100 Subject: [PATCH] Add test on certificate pending to verify the new value is overwrite the old one --- .../pending_certificate_repository.rs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/mithril-aggregator/src/database/repository/pending_certificate_repository.rs b/mithril-aggregator/src/database/repository/pending_certificate_repository.rs index 379a47cd62..ccfc3f0ce8 100644 --- a/mithril-aggregator/src/database/repository/pending_certificate_repository.rs +++ b/mithril-aggregator/src/database/repository/pending_certificate_repository.rs @@ -119,9 +119,29 @@ mod test { #[tokio::test] async fn update_certificate_pending() { let store = get_certificate_pending_store(true).await; - let certificate_pending = store.get().await.unwrap().unwrap(); + let old_certificate_pending = CertificatePending::new( + Epoch(2), + SignedEntityType::MithrilStakeDistribution(Epoch(2)), + fake_data::protocol_parameters(), + fake_data::protocol_parameters(), + fake_data::signers(1), + fake_data::signers(2), + ); + assert!(store.save(old_certificate_pending).await.is_ok()); - assert!(store.save(certificate_pending).await.is_ok()); + let new_certificate_pending = CertificatePending::new( + Epoch(4), + SignedEntityType::MithrilStakeDistribution(Epoch(4)), + fake_data::protocol_parameters(), + fake_data::protocol_parameters(), + fake_data::signers(3), + fake_data::signers(1), + ); + + assert!(store.save(new_certificate_pending.clone()).await.is_ok()); + + let certificate_pending = store.get().await.unwrap().unwrap(); + assert_eq!(new_certificate_pending, certificate_pending); } #[tokio::test]