add first unittest for action reply handler
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2024-03-06 15:47:02 +01:00
parent 11c529dceb
commit 0fa1503a88
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 24 additions and 6 deletions

View File

@ -21,6 +21,7 @@ impl ActionRequest {
#[non_exhaustive] #[non_exhaustive]
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug)]
pub enum ActionRequestVariant { pub enum ActionRequestVariant {
NoData,
StoreData(StoreAddr), StoreData(StoreAddr),
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]

View File

@ -376,7 +376,7 @@ pub mod std_mod {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use core::cell::RefCell; use core::{cell::RefCell, time::Duration};
use alloc::collections::VecDeque; use alloc::collections::VecDeque;
use delegate::delegate; use delegate::delegate;
@ -398,8 +398,8 @@ mod tests {
TestConverter, TestRouter, TestRoutingErrorHandler, APP_DATA_TOO_SHORT, TEST_APID, TestConverter, TestRouter, TestRoutingErrorHandler, APP_DATA_TOO_SHORT, TEST_APID,
}, },
verification::{ verification::{
tests::{TestVerificationReporter, SharedVerificationMap}, FailParams, RequestId, tests::{SharedVerificationMap, TestVerificationReporter},
VerificationReportingProvider, FailParams, RequestId, VerificationReportingProvider,
}, },
EcssTcInVecConverter, GenericRoutingError, MpscTcReceiver, PusPacketHandlerResult, EcssTcInVecConverter, GenericRoutingError, MpscTcReceiver, PusPacketHandlerResult,
PusPacketHandlingError, TmAsVecSenderWithMpsc, PusPacketHandlingError, TmAsVecSenderWithMpsc,
@ -624,8 +624,25 @@ mod tests {
#[test] #[test]
fn test_reply_handler() { fn test_reply_handler() {
let reply_handler_hook = TestReplyHandlerHook::default(); let reply_handler_hook = TestReplyHandlerHook::default();
let test_verif_reporter = TestVerificationReporter::default(); let shared_verif_map = SharedVerificationMap::default();
//let reply_handler = PusService8ReplyHandler::new(verification_reporter, fail_data_buf_size, user_hook) let mut test_verif_reporter = TestVerificationReporter::new(shared_verif_map.clone());
let mut reply_handler =
PusService8ReplyHandler::new(test_verif_reporter.clone(), 128, reply_handler_hook);
let request_id = 0x02;
let action_id = 0x03;
// let action_req = ActionRequest::new(action_id, ActionRequestVariant::NoData);
let token = test_verif_reporter.add_tc_with_req_id(request_id.into());
let token = test_verif_reporter
.acceptance_success(token, &[])
.expect("acceptance success failure");
let token = test_verif_reporter
.start_success(token, &[])
.expect("start success failure");
reply_handler.add_routed_request(
request_id.into(),
action_id,
token,
Duration::from_millis(1),
);
} }
} }