diff --git a/src/lib.rs b/src/lib.rs index ba4ecef..edafbef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -271,12 +271,18 @@ impl RemoteEntityConfigProvider for alloc::vec::Vec { } impl RemoteEntityConfigProvider for RemoteEntityConfig { - fn get(&self, _remote_id: u64) -> Option<&RemoteEntityConfig> { - Some(self) + fn get(&self, remote_id: u64) -> Option<&RemoteEntityConfig> { + if remote_id == self.entity_id.value() { + return Some(self); + } + None } - fn get_mut(&mut self, _remote_id: u64) -> Option<&mut RemoteEntityConfig> { - Some(self) + fn get_mut(&mut self, remote_id: u64) -> Option<&mut RemoteEntityConfig> { + if remote_id == self.entity_id.value() { + return Some(self); + } + None } fn add_config(&mut self, _cfg: &RemoteEntityConfig) -> bool { @@ -891,6 +897,7 @@ pub(crate) mod tests { use super::*; pub const LOCAL_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(1); + pub const REMOTE_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(2); pub struct FileSegmentRecvdParamsNoSegMetadata { #[allow(dead_code)] @@ -1237,6 +1244,20 @@ pub(crate) mod tests { assert_eq!(check_timer.expiry_time_seconds(), 1); } + #[test] + fn test_remote_cfg_provider_single() { + let remote_entity_cfg = RemoteEntityConfig::new_with_default_values( + REMOTE_ID.into(), + 1024, + true, + false, + TransmissionMode::Unacknowledged, + ChecksumType::Crc32, + ); + let remote_entity_retrieved = remote_entity_cfg.get(REMOTE_ID.value()).unwrap(); + ssert_eq!(remote_entity_retrieved.entity_id, REMOTE_ID.into()); + } + #[test] fn dummy_fault_hook_test() { let mut user_hook_dummy = DummyFaultHook::default(); diff --git a/tests/end-to-end.rs b/tests/end-to-end.rs index fe140f1..bb4a285 100644 --- a/tests/end-to-end.rs +++ b/tests/end-to-end.rs @@ -1,3 +1,4 @@ +//! This is an end-to-end integration tests using the CFDP abstractions provided by the library. use std::{ fs::OpenOptions, io::Write,