diff --git a/crates/agglayer-certificate-orchestrator/src/network_task/tests/status.rs b/crates/agglayer-certificate-orchestrator/src/network_task/tests/status.rs index f78c13f4e..83cb0b222 100644 --- a/crates/agglayer-certificate-orchestrator/src/network_task/tests/status.rs +++ b/crates/agglayer-certificate-orchestrator/src/network_task/tests/status.rs @@ -25,7 +25,7 @@ use crate::{ #[rstest] #[test_log::test(tokio::test)] #[timeout(Duration::from_secs(2))] -async fn from_pending_to_settle() { +async fn from_pending_to_settled() { let tmp = TempDBDir::new(); let storage = new_storage(&tmp.path); @@ -288,7 +288,7 @@ async fn from_proven_to_settled() { #[rstest] #[test_log::test(tokio::test)] #[timeout(Duration::from_secs(2))] -async fn from_candidate_to_settle() { +async fn from_candidate_to_settled() { let tmp = TempDBDir::new(); let storage = new_storage(&tmp.path); @@ -401,7 +401,7 @@ async fn from_candidate_to_settle() { #[rstest] #[test_log::test(tokio::test)] #[timeout(Duration::from_secs(2))] -async fn from_settle_to_settle() { +async fn from_settled_to_settled() { let tmp = TempDBDir::new(); let storage = new_storage(&tmp.path); diff --git a/crates/agglayer-storage/src/error.rs b/crates/agglayer-storage/src/error.rs index 46c2fe3c7..84a0cd274 100644 --- a/crates/agglayer-storage/src/error.rs +++ b/crates/agglayer-storage/src/error.rs @@ -49,6 +49,12 @@ pub enum Error { #[error(transparent)] SettlementCompat(#[from] crate::types::settlement::compat::Error), + + #[error( + "Invalid pending certificate height for network {0}: attempted to insert height {1}, but \ + latest pending height is {2}" + )] + InvalidPendingHeight(NetworkId, Height, Height), } impl From for CertificateStatusError { diff --git a/crates/agglayer-storage/src/stores/pending/mod.rs b/crates/agglayer-storage/src/stores/pending/mod.rs index ca2e10f5a..4274188ea 100644 --- a/crates/agglayer-storage/src/stores/pending/mod.rs +++ b/crates/agglayer-storage/src/stores/pending/mod.rs @@ -73,13 +73,10 @@ impl PendingCertificateWriter for PendingStore { self.get_latest_pending_certificate_for_network(&network_id)? { if latest_height > height { - // TODO: This is technically not Candidate error, - return Err(Error::CertificateCandidateError( - crate::error::CertificateCandidateError::UnexpectedHeight( - network_id, - height, - latest_height, - ), + return Err(Error::InvalidPendingHeight( + network_id, + height, + latest_height, )); } }