Continue CFDP handlers #90

Merged
muellerr merged 34 commits from continue_cfdp_handlers into main 2024-01-29 23:42:04 +01:00
Showing only changes of commit 0ecb718416 - Show all commits

View File

@ -309,7 +309,7 @@ impl DestinationHandler {
self.tparams.tstate.metadata_params = *metadata_pdu.metadata_params(); self.tparams.tstate.metadata_params = *metadata_pdu.metadata_params();
let remote_cfg = self let remote_cfg = self
.remote_cfg_table .remote_cfg_table
.get_remote_config(metadata_pdu.dest_id().value()); .get_remote_config(metadata_pdu.source_id().value());
if remote_cfg.is_none() { if remote_cfg.is_none() {
return Err(DestError::NoRemoteCfgFound(metadata_pdu.dest_id())); return Err(DestError::NoRemoteCfgFound(metadata_pdu.dest_id()));
} }
@ -632,11 +632,6 @@ mod tests {
const LOCAL_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(1); const LOCAL_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(1);
const REMOTE_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(2); const REMOTE_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(2);
const SRC_NAME: &str = "__cfdp__source-file";
const DEST_NAME: &str = "__cfdp__dest-file";
static ATOMIC_COUNTER: AtomicU8 = AtomicU8::new(0);
#[derive(Default)] #[derive(Default)]
struct TestCfdpUser { struct TestCfdpUser {
next_expected_seq_num: u64, next_expected_seq_num: u64,
@ -831,16 +826,13 @@ mod tests {
} }
fn init_full_filenames() -> (PathBuf, PathBuf) { fn init_full_filenames() -> (PathBuf, PathBuf) {
let mut file_path = temp_dir(); (
let mut src_path = file_path.clone(); tempfile::TempPath::from_path("/tmp/test.txt").to_path_buf(),
// Atomic counter used to allow concurrent tests. tempfile::NamedTempFile::new()
let unique_counter = ATOMIC_COUNTER.fetch_add(1, Ordering::Relaxed); .unwrap()
// Create unique test filenames. .into_temp_path()
let src_name_unique = format!("{SRC_NAME}{}.txt", unique_counter); .to_path_buf(),
let dest_name_unique = format!("{DEST_NAME}{}.txt", unique_counter); )
src_path.push(src_name_unique);
file_path.push(dest_name_unique);
(src_path, file_path)
} }
fn basic_remote_cfg_table() -> StdRemoteEntityConfigProvider { fn basic_remote_cfg_table() -> StdRemoteEntityConfigProvider {
@ -867,7 +859,7 @@ mod tests {
}; };
DestinationHandler::new( DestinationHandler::new(
local_entity_cfg, local_entity_cfg,
Box::new(NativeFilestore::default()), Box::<NativeFilestore>::default(),
Box::new(basic_remote_cfg_table()), Box::new(basic_remote_cfg_table()),
Box::new(TestCheckTimerCreator::new(2, 2)), Box::new(TestCheckTimerCreator::new(2, 2)),
) )