Skip to content

Commit

Permalink
bugfix and some more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Aug 26, 2024
1 parent 4051180 commit f4c4c66
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/dest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ impl<
) {
Ok(checksum_success) => {
file_delivery_complete = checksum_success;
if !checksum_success {
self.tparams.tstate.delivery_code = DeliveryCode::Incomplete;
self.tparams.tstate.condition_code = ConditionCode::FileChecksumFailure;
}
}
Err(e) => match e {
FilestoreError::ChecksumTypeNotImplemented(_) => {
Expand Down Expand Up @@ -1522,6 +1526,9 @@ mod tests {
let transaction_id = tb.handler.transaction_id().unwrap();
let mut fault_hook = tb.handler.local_cfg.user_fault_hook().borrow_mut();
assert!(fault_hook.notice_of_suspension_queue.is_empty());

// The file checksum failure is ignored by default and check limit handling is now
// performed.
let ignored_queue = &mut fault_hook.ignored_queue;
assert_eq!(ignored_queue.len(), 1);
let cancelled = ignored_queue.pop_front().unwrap();
Expand All @@ -1535,21 +1542,20 @@ mod tests {
TransactionStep::ReceivingFileDataPdusWithCheckLimitHandling,
);
tb.set_check_timer_expired();
tb
.handler
tb.handler
.state_machine_no_packet(&mut user)
.expect("fsm error");
tb.state_check(
State::Busy,
TransactionStep::ReceivingFileDataPdusWithCheckLimitHandling,
);
tb.set_check_timer_expired();
tb
.handler
tb.handler
.state_machine_no_packet(&mut user)
.expect("fsm error");
tb.state_check(State::Idle, TransactionStep::Idle);

// Transaction is cancelled because the check limit is reached.
let mut fault_hook = tb.handler.local_cfg.user_fault_hook().borrow_mut();
let cancelled_queue = &mut fault_hook.notice_of_cancellation_queue;
assert_eq!(cancelled_queue.len(), 1);
Expand All @@ -1567,6 +1573,19 @@ mod tests {
Some(FileDirectiveType::FinishedPdu)
);
let finished_pdu = FinishedPduReader::from_bytes(&sent_pdu.raw_pdu).unwrap();
assert_eq!(finished_pdu.file_status(), FileStatus::Retained);
assert_eq!(
finished_pdu.condition_code(),
ConditionCode::CheckLimitReached
);
assert_eq!(finished_pdu.delivery_code(), DeliveryCode::Incomplete);
assert!(finished_pdu.fault_location().is_some());
assert_eq!(
*finished_pdu.fault_location().unwrap().entity_id(),
REMOTE_ID.into()
);
assert_eq!(finished_pdu.fs_responses_raw(), &[]);
assert!(tb.handler.pdu_sender.queue_empty());
tb.expected_full_data = faulty_file_data.to_vec();
}
}

0 comments on commit f4c4c66

Please sign in to comment.