changelog
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
2024-04-02 20:25:20 +02:00
parent 52d16e0fe7
commit dd39b374bf
17 changed files with 268 additions and 349 deletions

View File

@ -234,7 +234,7 @@ mod alloc_mod {
mod tests {
use super::*;
use crate::events::{EventU32, Severity};
use crate::pus::test_util::TEST_COMPONENT_ID;
use crate::pus::test_util::TEST_COMPONENT_ID_0;
use crate::pus::tests::CommonTmInfo;
use crate::pus::{ChannelWithId, PusTmVariant};
use crate::ComponentId;
@ -344,7 +344,7 @@ mod tests {
) {
let mut sender = TestSender::default();
let reporter =
EventReporter::new(TEST_COMPONENT_ID.id(), EXAMPLE_APID, max_event_aux_data_buf);
EventReporter::new(TEST_COMPONENT_ID_0.id(), EXAMPLE_APID, max_event_aux_data_buf);
assert!(reporter.is_some());
let mut reporter = reporter.unwrap();
let time_stamp_empty: [u8; 7] = [0; 7];
@ -374,7 +374,7 @@ mod tests {
assert_eq!(tm_info.common.msg_counter, 0);
assert_eq!(tm_info.common.apid, EXAMPLE_APID);
assert_eq!(tm_info.event, event);
assert_eq!(tm_info.sender_id, TEST_COMPONENT_ID.id());
assert_eq!(tm_info.sender_id, TEST_COMPONENT_ID_0.id());
assert_eq!(tm_info.aux_data, error_copy);
}

View File

@ -84,7 +84,6 @@ impl<
.common
.verif_reporter
.start_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
ecss_tc_and_token.token,
time_stamp,
@ -209,12 +208,7 @@ mod tests {
self.handler
.service_helper
.verif_reporter()
.acceptance_success(
self.handler.service_helper.id(),
self.handler.service_helper.tm_sender(),
init_token,
&[0; 7],
)
.acceptance_success(self.handler.service_helper.tm_sender(), init_token, &[0; 7])
.expect("acceptance success failure")
}

View File

@ -324,7 +324,6 @@ pub trait PusReplyHandler<ActiveRequestInfo: ActiveRequestProvider, ReplyType> {
/// is finished. A finished PUS request will be removed from the active request map.
fn handle_reply(
&mut self,
caller_id: ComponentId,
reply: &GenericMessage<ReplyType>,
active_request: &ActiveRequestInfo,
tm_sender: &impl EcssTmSenderCore,
@ -334,7 +333,6 @@ pub trait PusReplyHandler<ActiveRequestInfo: ActiveRequestProvider, ReplyType> {
fn handle_unrequested_reply(
&mut self,
caller_id: ComponentId,
reply: &GenericMessage<ReplyType>,
tm_sender: &impl EcssTmSenderCore,
) -> Result<(), Self::Error>;
@ -342,7 +340,6 @@ pub trait PusReplyHandler<ActiveRequestInfo: ActiveRequestProvider, ReplyType> {
/// Handle the timeout of an active request.
fn handle_request_timeout(
&mut self,
caller_id: ComponentId,
active_request: &ActiveRequestInfo,
tm_sender: &impl EcssTmSenderCore,
verification_handler: &impl VerificationReportingProvider,
@ -457,7 +454,6 @@ pub mod alloc_mod {
type Error;
fn convert(
&mut self,
caller_id: ComponentId,
token: VerificationToken<TcStateAccepted>,
tc: &PusTcReader,
tm_sender: &(impl EcssTmSenderCore + ?Sized),
@ -1387,9 +1383,12 @@ pub mod test_util {
};
pub const TEST_APID: u16 = 0x101;
pub const TEST_UNIQUE_ID: u32 = 0x05;
pub const TEST_COMPONENT_ID: UniqueApidTargetId =
UniqueApidTargetId::new(TEST_APID, TEST_UNIQUE_ID);
pub const TEST_UNIQUE_ID_0: u32 = 0x05;
pub const TEST_UNIQUE_ID_1: u32 = 0x06;
pub const TEST_COMPONENT_ID_0: UniqueApidTargetId =
UniqueApidTargetId::new(TEST_APID, TEST_UNIQUE_ID_0);
pub const TEST_COMPONENT_ID_1: UniqueApidTargetId =
UniqueApidTargetId::new(TEST_APID, TEST_UNIQUE_ID_1);
pub trait PusTestHarness {
fn init_verification(&mut self, tc: &PusTcCreator) -> VerificationToken<TcStateAccepted>;
@ -1427,7 +1426,7 @@ pub mod tests {
use crate::tmtc::tm_helper::SharedTmPool;
use crate::ComponentId;
use super::test_util::{TEST_APID, TEST_COMPONENT_ID};
use super::test_util::{TEST_APID, TEST_COMPONENT_ID_0};
use super::verification::test_util::TestVerificationReporter;
use super::verification::{
@ -1508,7 +1507,7 @@ pub mod tests {
let (tm_tx, tm_rx) = mpsc::sync_channel(10);
let verif_cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
let verification_handler = VerificationReporter::new(&verif_cfg);
let verification_handler = VerificationReporter::new(TEST_COMPONENT_ID_0.id(), &verif_cfg);
let test_srv_tm_sender = TmInSharedPoolSender::new(shared_tm_pool.clone(), tm_tx);
let in_store_converter =
EcssTcInSharedStoreConverter::new(shared_tc_pool.clone(), 2048);
@ -1596,7 +1595,7 @@ pub mod tests {
let (tm_tx, tm_rx) = mpsc::channel();
let verif_cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
let verification_handler = VerificationReporter::new(&verif_cfg);
let verification_handler = VerificationReporter::new(TEST_COMPONENT_ID_0.id(), &verif_cfg);
let in_store_converter = EcssTcInVecConverter::default();
(
Self {
@ -1616,7 +1615,7 @@ pub mod tests {
}
impl PusServiceHandlerWithVecCommon {
pub fn new_with_test_verif_sender() -> (
pub fn new_with_test_verif_sender(id: ComponentId) -> (
Self,
PusServiceHelper<
MpscTcReceiver,
@ -1629,7 +1628,7 @@ pub mod tests {
let (tm_tx, tm_rx) = mpsc::channel();
let in_store_converter = EcssTcInVecConverter::default();
let verification_handler = TestVerificationReporter::default();
let verification_handler = TestVerificationReporter::new(id);
(
Self {
current_tm: None,
@ -1638,7 +1637,7 @@ pub mod tests {
//verification_handler: verification_handler.clone(),
},
PusServiceHelper::new(
TEST_COMPONENT_ID.raw(),
id,
test_srv_tc_rx,
tm_tx,
verification_handler,

View File

@ -93,7 +93,6 @@ impl<
.service_helper
.verif_reporter()
.start_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
ecss_tc_and_token.token,
time_stamp,
@ -105,7 +104,6 @@ impl<
self.service_helper
.verif_reporter()
.completion_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
start_token,
time_stamp,
@ -122,7 +120,6 @@ impl<
.service_helper
.verif_reporter()
.start_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
ecss_tc_and_token.token,
time_stamp,
@ -134,7 +131,6 @@ impl<
self.service_helper
.verif_reporter()
.completion_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
start_token,
time_stamp,
@ -151,7 +147,6 @@ impl<
.service_helper
.verif_reporter()
.start_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
ecss_tc_and_token.token,
time_stamp,
@ -165,7 +160,6 @@ impl<
self.service_helper
.verif_reporter()
.completion_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
start_token,
time_stamp,
@ -178,7 +172,6 @@ impl<
.common
.verif_reporter
.start_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
ecss_tc_and_token.token,
time_stamp,
@ -193,7 +186,6 @@ impl<
self.service_helper
.verif_reporter()
.completion_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
start_token,
time_stamp,
@ -321,12 +313,7 @@ mod tests {
self.handler
.service_helper
.verif_reporter()
.acceptance_success(
self.handler.service_helper.id(),
self.handler.service_helper.tm_sender(),
init_token,
&[0; 7],
)
.acceptance_success(self.handler.service_helper.tm_sender(), init_token, &[0; 7])
.expect("acceptance success failure")
}

View File

@ -66,7 +66,6 @@ impl<
.service_helper
.verif_reporter()
.start_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
ecss_tc_and_token.token,
time_stamp,
@ -98,7 +97,6 @@ impl<
.service_helper
.verif_reporter()
.completion_success(
self.service_helper.common.id,
&self.service_helper.common.tm_sender,
start_token,
time_stamp,
@ -208,12 +206,7 @@ mod tests {
self.handler
.service_helper
.verif_reporter()
.acceptance_success(
self.handler.service_helper.id(),
self.handler.service_helper.tm_sender(),
init_token,
&[0; 7],
)
.acceptance_success(self.handler.service_helper.tm_sender(), init_token, &[0; 7])
.expect("acceptance success failure")
}
@ -264,12 +257,7 @@ mod tests {
self.handler
.service_helper
.verif_reporter()
.acceptance_success(
self.handler.service_helper.id(),
self.handler.service_helper.tm_sender(),
init_token,
&[0; 7],
)
.acceptance_success(self.handler.service_helper.tm_sender(), init_token, &[0; 7])
.expect("acceptance success failure")
}

View File

@ -404,6 +404,10 @@ impl<'stamp, 'fargs> FailParamsWithStep<'stamp, 'fargs> {
/// or to swap the actual reporter with a test reporter for unit tests.
/// For general purposes, the [VerificationReporter] should be sufficient.
pub trait VerificationReportingProvider {
/// It is generally assumed that the reporting provider is owned by some PUS service with
/// a unique ID.
fn owner_id(&self) -> ComponentId;
fn set_apid(&mut self, apid: Apid);
fn apid(&self) -> Apid;
@ -418,7 +422,6 @@ pub trait VerificationReportingProvider {
fn acceptance_success(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateNone>,
time_stamp: &[u8],
@ -426,7 +429,6 @@ pub trait VerificationReportingProvider {
fn acceptance_failure(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateNone>,
params: FailParams,
@ -434,7 +436,6 @@ pub trait VerificationReportingProvider {
fn start_success(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateAccepted>,
time_stamp: &[u8],
@ -442,7 +443,6 @@ pub trait VerificationReportingProvider {
fn start_failure(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateAccepted>,
params: FailParams,
@ -450,7 +450,6 @@ pub trait VerificationReportingProvider {
fn step_success(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: &VerificationToken<TcStateStarted>,
time_stamp: &[u8],
@ -459,7 +458,6 @@ pub trait VerificationReportingProvider {
fn step_failure(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateStarted>,
params: FailParamsWithStep,
@ -467,7 +465,6 @@ pub trait VerificationReportingProvider {
fn completion_success<TcState: WasAtLeastAccepted + Copy>(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcState>,
time_stamp: &[u8],
@ -475,7 +472,6 @@ pub trait VerificationReportingProvider {
fn completion_failure<TcState: WasAtLeastAccepted + Copy>(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcState>,
params: FailParams,
@ -944,15 +940,17 @@ pub mod alloc_mod {
pub struct VerificationReporter<
VerificationHook: VerificationHookProvider = DummyVerificationHook,
> {
owner_id: ComponentId,
source_data_buf: RefCell<alloc::vec::Vec<u8>>,
pub reporter_creator: VerificationReportCreator,
pub tm_hook: VerificationHook,
}
impl VerificationReporter<DummyVerificationHook> {
pub fn new(cfg: &VerificationReporterCfg) -> Self {
pub fn new(owner_id: ComponentId, cfg: &VerificationReporterCfg) -> Self {
let reporter = VerificationReportCreator::new(cfg.apid).unwrap();
Self {
owner_id,
source_data_buf: RefCell::new(alloc::vec![
0;
RequestId::SIZE_AS_BYTES
@ -969,9 +967,14 @@ pub mod alloc_mod {
impl<VerificationHook: VerificationHookProvider> VerificationReporter<VerificationHook> {
/// The provided [VerificationHookProvider] can be used to modify a verification packet
/// before it is sent.
pub fn new_with_hook(cfg: &VerificationReporterCfg, tm_hook: VerificationHook) -> Self {
pub fn new_with_hook(
owner_id: ComponentId,
cfg: &VerificationReporterCfg,
tm_hook: VerificationHook,
) -> Self {
let reporter = VerificationReportCreator::new(cfg.apid).unwrap();
Self {
owner_id,
source_data_buf: RefCell::new(alloc::vec![
0;
RequestId::SIZE_AS_BYTES
@ -1012,10 +1015,13 @@ pub mod alloc_mod {
}
);
fn owner_id(&self) -> ComponentId {
self.owner_id
}
/// Package and send a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard
fn acceptance_success(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateNone>,
time_stamp: &[u8],
@ -1026,14 +1032,13 @@ pub mod alloc_mod {
.acceptance_success(source_data_buf.as_mut_slice(), token, 0, 0, time_stamp)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(token)
}
/// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard
fn acceptance_failure(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateNone>,
params: FailParams,
@ -1044,7 +1049,7 @@ pub mod alloc_mod {
.acceptance_failure(buf.as_mut_slice(), token, 0, 0, params)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(())
}
@ -1053,7 +1058,6 @@ pub mod alloc_mod {
/// Requires a token previously acquired by calling [Self::acceptance_success].
fn start_success(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateAccepted>,
time_stamp: &[u8],
@ -1064,7 +1068,7 @@ pub mod alloc_mod {
.start_success(buf.as_mut_slice(), token, 0, 0, time_stamp)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(started_token)
}
@ -1074,7 +1078,6 @@ pub mod alloc_mod {
/// the token because verification handling is done.
fn start_failure(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateAccepted>,
params: FailParams,
@ -1085,7 +1088,7 @@ pub mod alloc_mod {
.start_failure(buf.as_mut_slice(), token, 0, 0, params)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(())
}
@ -1094,7 +1097,6 @@ pub mod alloc_mod {
/// Requires a token previously acquired by calling [Self::start_success].
fn step_success(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: &VerificationToken<TcStateStarted>,
time_stamp: &[u8],
@ -1106,7 +1108,7 @@ pub mod alloc_mod {
.step_success(buf.as_mut_slice(), token, 0, 0, time_stamp, step)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(())
}
@ -1116,7 +1118,6 @@ pub mod alloc_mod {
/// token because verification handling is done.
fn step_failure(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateStarted>,
params: FailParamsWithStep,
@ -1127,7 +1128,7 @@ pub mod alloc_mod {
.step_failure(buf.as_mut_slice(), token, 0, 0, params)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(())
}
@ -1137,7 +1138,7 @@ pub mod alloc_mod {
/// token because verification handling is done.
fn completion_success<TcState: WasAtLeastAccepted + Copy>(
&self,
sender_id: ComponentId,
// sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcState>,
time_stamp: &[u8],
@ -1148,7 +1149,7 @@ pub mod alloc_mod {
.completion_success(buf.as_mut_slice(), token, 0, 0, time_stamp)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id, PusTmVariant::Direct(tm_creator))?;
Ok(())
}
@ -1158,7 +1159,6 @@ pub mod alloc_mod {
/// token because verification handling is done.
fn completion_failure<TcState: WasAtLeastAccepted + Copy>(
&self,
sender_id: ComponentId,
sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcState>,
params: FailParams,
@ -1169,7 +1169,7 @@ pub mod alloc_mod {
.completion_failure(buf.as_mut_slice(), token, 0, 00, params)
.map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator);
sender.send_tm(sender_id, PusTmVariant::Direct(tm_creator))?;
sender.send_tm(self.owner_id(), PusTmVariant::Direct(tm_creator))?;
Ok(())
}
}
@ -1204,11 +1204,6 @@ pub mod test_util {
use super::*;
#[derive(Default)]
pub struct TestVerificationReporter {
pub report_queue: RefCell<VecDeque<(RequestId, VerificationReportInfo)>>,
}
#[derive(Debug, PartialEq)]
pub struct SuccessData {
pub sender: ComponentId,
@ -1236,6 +1231,20 @@ pub mod test_util {
CompletionFailure(FailureData),
}
pub struct TestVerificationReporter {
pub id: ComponentId,
pub report_queue: RefCell<VecDeque<(RequestId, VerificationReportInfo)>>,
}
impl TestVerificationReporter {
pub fn new(id: ComponentId) -> Self {
Self {
id,
report_queue: Default::default(),
}
}
}
impl VerificationReportingProvider for TestVerificationReporter {
fn set_apid(&mut self, _apid: Apid) {}
@ -1255,7 +1264,6 @@ pub mod test_util {
fn acceptance_success(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateNone>,
time_stamp: &[u8],
@ -1263,7 +1271,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::AcceptanceSuccess(SuccessData {
sender: sender_id,
sender: self.owner_id(),
time_stamp: time_stamp.to_vec(),
}),
));
@ -1275,7 +1283,6 @@ pub mod test_util {
fn acceptance_failure(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateNone>,
params: FailParams,
@ -1283,7 +1290,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::AcceptanceFailure(FailureData {
sender: sender_id,
sender: self.owner_id(),
error_enum: params.failure_code.value(),
fail_data: params.failure_data.to_vec(),
time_stamp: params.time_stamp.to_vec(),
@ -1294,7 +1301,6 @@ pub mod test_util {
fn start_success(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateAccepted>,
time_stamp: &[u8],
@ -1302,7 +1308,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::StartedSuccess(SuccessData {
sender: sender_id,
sender: self.owner_id(),
time_stamp: time_stamp.to_vec(),
}),
));
@ -1314,7 +1320,6 @@ pub mod test_util {
fn start_failure(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<super::TcStateAccepted>,
params: FailParams,
@ -1322,7 +1327,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::StartedFailure(FailureData {
sender: sender_id,
sender: self.owner_id(),
error_enum: params.failure_code.value(),
fail_data: params.failure_data.to_vec(),
time_stamp: params.time_stamp.to_vec(),
@ -1333,7 +1338,6 @@ pub mod test_util {
fn step_success(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: &VerificationToken<TcStateStarted>,
time_stamp: &[u8],
@ -1343,7 +1347,7 @@ pub mod test_util {
token.request_id(),
VerificationReportInfo::StepSuccess {
data: SuccessData {
sender: sender_id,
sender: self.owner_id(),
time_stamp: time_stamp.to_vec(),
},
step: step.value() as u16,
@ -1354,7 +1358,6 @@ pub mod test_util {
fn step_failure(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcStateStarted>,
params: FailParamsWithStep,
@ -1362,7 +1365,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::StepFailure(FailureData {
sender: sender_id,
sender: self.owner_id(),
error_enum: params.common.failure_code.value(),
fail_data: params.common.failure_data.to_vec(),
time_stamp: params.common.time_stamp.to_vec(),
@ -1373,7 +1376,6 @@ pub mod test_util {
fn completion_success<TcState: super::WasAtLeastAccepted + Copy>(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcState>,
time_stamp: &[u8],
@ -1381,7 +1383,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::CompletionSuccess(SuccessData {
sender: sender_id,
sender: self.owner_id(),
time_stamp: time_stamp.to_vec(),
}),
));
@ -1390,7 +1392,6 @@ pub mod test_util {
fn completion_failure<TcState: WasAtLeastAccepted + Copy>(
&self,
sender_id: ComponentId,
_sender: &(impl EcssTmSenderCore + ?Sized),
token: VerificationToken<TcState>,
params: FailParams,
@ -1398,7 +1399,7 @@ pub mod test_util {
self.report_queue.borrow_mut().push_back((
token.request_id(),
VerificationReportInfo::CompletionFailure(FailureData {
sender: sender_id,
sender: self.owner_id(),
error_enum: params.failure_code.value(),
fail_data: params.failure_data.to_vec(),
time_stamp: params.time_stamp.to_vec(),
@ -1406,6 +1407,10 @@ pub mod test_util {
));
Ok(())
}
fn owner_id(&self) -> ComponentId {
self.id
}
}
impl TestVerificationReporter {
@ -1627,7 +1632,7 @@ pub mod test_util {
#[cfg(test)]
pub mod tests {
use crate::pool::{StaticMemoryPool, StaticPoolConfig};
use crate::pus::test_util::{TEST_APID, TEST_COMPONENT_ID};
use crate::pus::test_util::{TEST_APID, TEST_COMPONENT_ID_0};
use crate::pus::tests::CommonTmInfo;
use crate::pus::verification::{
EcssTmSenderCore, EcssTmtcError, FailParams, FailParamsWithStep, RequestId, TcStateNone,
@ -1739,21 +1744,22 @@ pub mod tests {
tc: Vec<u8>,
}
fn base_reporter() -> VerificationReporter {
fn base_reporter(id: ComponentId) -> VerificationReporter {
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
VerificationReporter::new(&cfg)
VerificationReporter::new(id, &cfg)
}
fn reporter_with_hook<VerificationHook: VerificationHookProvider>(
id: ComponentId,
hook: VerificationHook,
) -> VerificationReporter<VerificationHook> {
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
VerificationReporter::new_with_hook(&cfg, hook)
VerificationReporter::new_with_hook(id, &cfg, hook)
}
impl<VerificiationHook: VerificationHookProvider> VerificationReporterTestbench<VerificiationHook> {
fn new_with_hook(id: ComponentId, tc: PusTcCreator, tm_hook: VerificiationHook) -> Self {
let reporter = reporter_with_hook(tm_hook);
let reporter = reporter_with_hook(id, tm_hook);
Self {
id,
sender: TestSender::default(),
@ -1778,7 +1784,7 @@ pub mod tests {
time_stamp: &[u8],
) -> Result<VerificationToken<TcStateAccepted>, EcssTmtcError> {
self.reporter
.acceptance_success(self.id, &self.sender, token, time_stamp)
.acceptance_success(&self.sender, token, time_stamp)
}
fn acceptance_failure(
@ -1787,7 +1793,7 @@ pub mod tests {
params: FailParams,
) -> Result<(), EcssTmtcError> {
self.reporter
.acceptance_failure(self.id, &self.sender, token, params)
.acceptance_failure(&self.sender, token, params)
}
fn start_success(
@ -1795,8 +1801,7 @@ pub mod tests {
token: VerificationToken<TcStateAccepted>,
time_stamp: &[u8],
) -> Result<VerificationToken<TcStateStarted>, EcssTmtcError> {
self.reporter
.start_success(self.id, &self.sender, token, time_stamp)
self.reporter.start_success(&self.sender, token, time_stamp)
}
fn start_failure(
@ -1804,8 +1809,7 @@ pub mod tests {
token: VerificationToken<TcStateAccepted>,
params: FailParams,
) -> Result<(), EcssTmtcError> {
self.reporter
.start_failure(self.id, &self.sender, token, params)
self.reporter.start_failure(&self.sender, token, params)
}
fn step_success(
@ -1815,7 +1819,7 @@ pub mod tests {
step: impl EcssEnumeration,
) -> Result<(), EcssTmtcError> {
self.reporter
.step_success(self.id, &self.sender, token, time_stamp, step)
.step_success(&self.sender, token, time_stamp, step)
}
fn step_failure(
@ -1823,8 +1827,7 @@ pub mod tests {
token: VerificationToken<TcStateStarted>,
params: FailParamsWithStep,
) -> Result<(), EcssTmtcError> {
self.reporter
.step_failure(self.id, &self.sender, token, params)
self.reporter.step_failure(&self.sender, token, params)
}
fn completion_success<TcState: WasAtLeastAccepted + Copy>(
@ -1833,7 +1836,7 @@ pub mod tests {
time_stamp: &[u8],
) -> Result<(), EcssTmtcError> {
self.reporter
.completion_success(self.id, &self.sender, token, time_stamp)
.completion_success(&self.sender, token, time_stamp)
}
fn completion_failure<TcState: WasAtLeastAccepted + Copy>(
@ -1842,7 +1845,7 @@ pub mod tests {
params: FailParams,
) -> Result<(), EcssTmtcError> {
self.reporter
.completion_failure(self.id, &self.sender, token, params)
.completion_failure(&self.sender, token, params)
}
fn completion_success_check(&mut self, incrementing_couters: bool) {
@ -1904,7 +1907,7 @@ pub mod tests {
impl VerificationReporterTestbench<DummyVerificationHook> {
fn new(id: ComponentId, tc: PusTcCreator) -> Self {
let reporter = base_reporter();
let reporter = base_reporter(id);
Self {
id,
sender: TestSender::default(),
@ -2336,7 +2339,7 @@ pub mod tests {
#[test]
fn test_complete_success_sequence() {
let mut testbench =
VerificationReporterTestbench::new(TEST_COMPONENT_ID.id(), create_generic_ping());
VerificationReporterTestbench::new(TEST_COMPONENT_ID_0.id(), create_generic_ping());
let token = testbench.init();
let accepted_token = testbench
.acceptance_success(token, &EMPTY_STAMP)
@ -2353,7 +2356,7 @@ pub mod tests {
#[test]
fn test_packet_manipulation() {
let mut testbench = VerificationReporterTestbench::new_with_hook(
TEST_COMPONENT_ID.id(),
TEST_COMPONENT_ID_0.id(),
create_generic_ping(),
SequenceCounterHook::default(),
);