diff --git a/satrs/src/pus/verification.rs b/satrs/src/pus/verification.rs index 4b88a91..98ba223 100644 --- a/satrs/src/pus/verification.rs +++ b/satrs/src/pus/verification.rs @@ -405,7 +405,9 @@ pub trait VerificationReportingProvider { fn add_tc( &mut self, pus_tc: &(impl CcsdsPacket + IsPusTelecommand), - ) -> VerificationToken; + ) -> VerificationToken { + self.add_tc_with_req_id(RequestId::new(pus_tc)) + } fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken; @@ -1392,7 +1394,7 @@ mod std_mod { } #[cfg(test)] -mod tests { +pub mod tests { use crate::pool::{PoolProviderWithGuards, StaticMemoryPool, StaticPoolConfig}; use crate::pus::tests::CommonTmInfo; use crate::pus::verification::{ @@ -1405,6 +1407,7 @@ mod tests { use crate::ChannelId; use alloc::boxed::Box; use alloc::format; + use hashbrown::HashMap; use spacepackets::ecss::tc::{PusTcCreator, PusTcSecondaryHeader}; use spacepackets::ecss::tm::PusTmReader; use spacepackets::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, PusError, PusPacket}; @@ -1423,6 +1426,105 @@ mod tests { #[allow(dead_code)] fn is_sync(_: &T) {} + pub struct VerificationStatus { + pub accepted: Option, + pub started: Option, + pub step: u32, + pub completed: Option, + } + pub struct TestVerificationReporter { + verification_map: HashMap, + } + + impl VerificationReportingProvider for TestVerificationReporter { + fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken { + self.verification_map.insert( + req_id, + VerificationStatus { + accepted: None, + started: None, + step: 0, + completed: None, + }, + ); + VerificationToken { + state: core::marker::PhantomData, + req_id, + } + } + + fn acceptance_success( + &self, + token: VerificationToken, + time_stamp: Option<&[u8]>, + ) -> Result< + VerificationToken, + super::VerificationOrSendErrorWithToken, + > { + todo!() + } + + fn acceptance_failure( + &self, + token: VerificationToken, + params: FailParams, + ) -> Result<(), super::VerificationOrSendErrorWithToken> { + todo!() + } + + fn start_success( + &self, + token: VerificationToken, + time_stamp: Option<&[u8]>, + ) -> Result< + VerificationToken, + super::VerificationOrSendErrorWithToken, + > { + todo!() + } + + fn start_failure( + &self, + token: VerificationToken, + params: FailParams, + ) -> Result<(), super::VerificationOrSendErrorWithToken> { + todo!() + } + + fn step_success( + &self, + token: &VerificationToken, + time_stamp: Option<&[u8]>, + step: impl spacepackets::ecss::EcssEnumeration, + ) -> Result<(), EcssTmtcError> { + todo!() + } + + fn step_failure( + &self, + token: VerificationToken, + params: FailParamsWithStep, + ) -> Result<(), super::VerificationOrSendErrorWithToken> { + todo!() + } + + fn completion_success( + &self, + token: VerificationToken, + time_stamp: Option<&[u8]>, + ) -> Result<(), super::VerificationOrSendErrorWithToken> { + todo!() + } + + fn completion_failure( + &self, + token: VerificationToken, + params: FailParams, + ) -> Result<(), super::VerificationOrSendErrorWithToken> { + todo!() + } + } + const TEST_APID: u16 = 0x02; const EMPTY_STAMP: [u8; 7] = [0; 7]; @@ -1984,7 +2086,7 @@ mod tests { .expect("Sending start success failed"); b.vr.step_success( &started_token, - &mut sender, + &sender, Some(&EMPTY_STAMP), EcssEnumU8::new(0), ) @@ -2018,16 +2120,12 @@ mod tests { .helper .start_success(accepted_token, Some(&[0, 1, 0, 1, 0, 1, 0])) .expect("Sending start success failed"); - let mut empty = b - .helper + b.helper .step_success(&started_token, Some(&EMPTY_STAMP), EcssEnumU8::new(0)) .expect("Sending completion success failed"); - assert_eq!(empty, ()); - empty = b - .helper + b.helper .step_failure(started_token, fail_params) .expect("Step failure failed"); - assert_eq!(empty, ()); let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap(); check_step_failure(sender, req_id, fail_data_raw); } @@ -2087,12 +2185,12 @@ mod tests { let fail_params = FailParams::new(Some(&EMPTY_STAMP), &fail_code, None); let accepted_token = - b.vr.acceptance_success(tok, &mut sender, Some(&EMPTY_STAMP)) + b.vr.acceptance_success(tok, &sender, Some(&EMPTY_STAMP)) .expect("Sending acceptance success failed"); let started_token = - b.vr.start_success(accepted_token, &mut sender, Some(&[0, 1, 0, 1, 0, 1, 0])) + b.vr.start_success(accepted_token, &sender, Some(&[0, 1, 0, 1, 0, 1, 0])) .expect("Sending start success failed"); - b.vr.completion_failure(started_token, &mut sender, fail_params) + b.vr.completion_failure(started_token, &sender, fail_params) .expect("Completion failure"); completion_fail_check(&mut sender, req_id); }