going towards unittest completion
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
2024-03-29 16:20:06 +01:00
parent 9144a9f9a3
commit 5c1acfe912
8 changed files with 170 additions and 106 deletions

View File

@ -31,7 +31,7 @@ pub struct ModeReplyHandler {}
impl PusReplyHandler<ActivePusRequestStd, ModeReply> for ModeReplyHandler {
type Error = EcssTmtcError;
fn handle_unexpected_reply(
fn handle_unrequested_reply(
&mut self,
reply: &satrs::request::GenericMessage<ModeReply>,
_tm_sender: &impl EcssTmSenderCore,
@ -199,15 +199,19 @@ impl PusTcToRequestConverter<ActivePusRequestStd, ModeRequest> for ModeRequestCo
#[cfg(test)]
mod tests {
use satrs::{
mode::{ModeAndSubmode, ModeRequest},
mode::{ModeAndSubmode, ModeReply, ModeRequest},
pus::mode::Subservice,
request::GenericMessage,
spacepackets::{
ecss::tc::{PusTcCreator, PusTcSecondaryHeader},
SpHeader,
},
};
use crate::pus::tests::{PusConverterTestbench, TEST_APID, TEST_APID_TARGET_ID};
use crate::pus::{
mode::ModeReplyHandler,
tests::{PusConverterTestbench, ReplyHandlerTestbench, TEST_APID, TEST_APID_TARGET_ID},
};
use super::ModeRequestConverter;
@ -276,5 +280,23 @@ mod tests {
assert_eq!(req, ModeRequest::AnnounceModeRecursive);
}
// TODO: Add reply handler tests.
#[test]
fn reply_handling_unrequested_reply() {
let mut testbench = ReplyHandlerTestbench::new(ModeReplyHandler::default());
let mode_reply = ModeReply::ModeInfo(ModeAndSubmode::new(5, 1));
let unrequested_reply = GenericMessage::new(10_u32, 15_u64, mode_reply);
// Right now this function does not do a lot. We simply check that it does not panic or do
// weird stuff.
let result = testbench.handle_unrequested_reply(&unrequested_reply);
assert!(result.is_ok());
}
#[test]
fn reply_handling_reply_timeout() {
let mut testbench = ReplyHandlerTestbench::new(ModeReplyHandler::default());
// TODO: Start a request, then time it out with the API and check verification completion
// failure.
// testbench.reply_handler.handle_request_timeout(active_request, verification_handler, time_stamp, tm_sender)
// testbench.default_timeout = Duration::from_millis(50);
}
}