Skip to content

Commit

Permalink
Fix file tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbraun96 committed Mar 30, 2024
1 parent 028530e commit 7dbd8e4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 27 deletions.
4 changes: 4 additions & 0 deletions citadel-internal-service/src/kernel/requests/file/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod delete_virtual_file;
pub mod download;
pub mod respond_file_transfer;
pub mod upload;
13 changes: 5 additions & 8 deletions citadel-internal-service/src/kernel/requests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ pub(crate) struct HandledRequestResult {
}

mod connect;
mod delete_virtual_file;
mod disconnect;
mod download_file;
mod get_account_information;
mod get_sessions;
mod message;
mod register;
mod respond_file_transfer;
mod send_file;

mod file;
mod group;
mod local_db;
mod peer;
Expand Down Expand Up @@ -60,19 +57,19 @@ pub async fn handle_request(
}

InternalServiceRequest::SendFile { .. } => {
return send_file::handle(this, uuid, command).await
return file::upload::handle(this, uuid, command).await
}

InternalServiceRequest::RespondFileTransfer { .. } => {
return respond_file_transfer::handle(this, uuid, command).await
return file::respond_file_transfer::handle(this, uuid, command).await
}

InternalServiceRequest::DownloadFile { .. } => {
return download_file::handle(this, uuid, command).await
return file::download::handle(this, uuid, command).await
}

InternalServiceRequest::DeleteVirtualFile { .. } => {
return delete_virtual_file::handle(this, uuid, command).await
return file::delete_virtual_file::handle(this, uuid, command).await
}

InternalServiceRequest::ListRegisteredPeers { .. } => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,16 @@ pub async fn handle(
) -> Result<(), NetworkError> {
let metadata = object_transfer_handle.handle.metadata.clone();
let object_id = metadata.object_id;
let object_transfer_handler = object_transfer_handle.handle;

let (implicated_cid, peer_cid) = if matches!(
object_transfer_handler.orientation,
ObjectTransferOrientation::Receiver {
is_revfs_pull: true
}
) {
// When this is a REVFS pull reception handle, THIS node is the source of the file.
// The other node, i.e. the peer, is the receiver who is requesting the file.
(
object_transfer_handler.source,
object_transfer_handler.receiver,
)
let implicated_cid = object_transfer_handle.implicated_cid;
let peer_cid = if object_transfer_handle.handle.receiver != implicated_cid {
object_transfer_handle.handle.receiver
} else {
(
object_transfer_handler.receiver,
object_transfer_handler.source,
)
object_transfer_handle.handle.source
};
let object_transfer_handler = object_transfer_handle.handle;

citadel_logging::info!(target: "citadel", "Orientation: {:?}", object_transfer_handler.orientation);
info!(target: "citadel", "ObjectTransferHandle has implicated_cid: {implicated_cid:?} and peer_cid {peer_cid:?}");
citadel_logging::info!(target: "citadel", "ObjectTransferHandle has implicated_cid: {implicated_cid:?} and peer_cid {peer_cid:?}");

// When we receive a handle, there are two possibilities:
// A: We are the sender of the file transfer, in which case we can assume the adjacent node
Expand Down
5 changes: 5 additions & 0 deletions citadel-internal-service/tests/file_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ mod tests {
panic!("File Transfer Request failed: {deserialized_service_a_payload_response:?}");
}

citadel_logging::error!(target: "citadel", "AB0");
exhaust_stream_to_file_completion(file_to_send.clone(), from_service_b).await;
citadel_logging::error!(target: "citadel", "AB1");
exhaust_stream_to_file_completion(file_to_send.clone(), from_service_a).await;
citadel_logging::error!(target: "citadel", "AB2");

// Download P2P REVFS file - without delete on pull
let download_file_command = InternalServiceRequest::DownloadFile {
Expand Down Expand Up @@ -425,6 +428,7 @@ mod tests {
let mut is_revfs = false;
loop {
let tick_response = svc.recv().await.unwrap();
citadel_logging::trace!(target: "citadel", "RECV signal {tick_response:?}");
match tick_response {
InternalServiceResponse::FileTransferTickNotification(
FileTransferTickNotification {
Expand Down Expand Up @@ -483,6 +487,7 @@ mod tests {
panic!("File Send Reception Status Yielded Unexpected Response")
}
},

unexpected_response => {
citadel_logging::warn!(target: "citadel", "Unexpected signal {unexpected_response:?}")
}
Expand Down

0 comments on commit 7dbd8e4

Please sign in to comment.