Skip to content

Commit

Permalink
clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Braun committed Nov 11, 2023
1 parent 2e4ce90 commit a8af842
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
4 changes: 2 additions & 2 deletions citadel_workspace_service/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub async fn register_and_connect_to_server_then_peers(
.send(InternalServiceRequest::PeerRegister {
request_id: Uuid::new_v4(),
cid: *cid_a,
peer_cid: (*cid_b).into(),
peer_cid: (*cid_b),
session_security_settings,
connect_after_register: false,
})
Expand All @@ -247,7 +247,7 @@ pub async fn register_and_connect_to_server_then_peers(
.send(InternalServiceRequest::PeerRegister {
request_id: Uuid::new_v4(),
cid: *cid_b,
peer_cid: (*cid_a).into(),
peer_cid: (*cid_a),
session_security_settings,
connect_after_register: false,
})
Expand Down
20 changes: 8 additions & 12 deletions citadel_workspace_service/tests/file_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {
}];
let returned_service_info = register_and_connect_to_server(to_spawn).await;
let mut service_vec = returned_service_info.unwrap();
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0 as usize) {
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0_usize) {
let cmp_path = PathBuf::from("../resources/test.txt");

let file_transfer_command = InternalServiceRequest::SendFile {
Expand Down Expand Up @@ -106,11 +106,9 @@ mod tests {
])
.await?;

let (peer_one, peer_two) = peer_return_handle_vec
.as_mut_slice()
.split_at_mut(1 as usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0 as usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0 as usize).unwrap();
let (peer_one, peer_two) = peer_return_handle_vec.as_mut_slice().split_at_mut(1_usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0_usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0_usize).unwrap();

let file_to_send = PathBuf::from("../resources/test.txt");

Expand Down Expand Up @@ -219,7 +217,7 @@ mod tests {
}];
let returned_service_info = register_and_connect_to_server(to_spawn).await;
let mut service_vec = returned_service_info.unwrap();
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0 as usize) {
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0_usize) {
// Push file to REVFS
let file_to_send = PathBuf::from("../resources/test.txt");
let virtual_path = PathBuf::from("/vfs/test.txt");
Expand Down Expand Up @@ -318,11 +316,9 @@ mod tests {
])
.await?;

let (peer_one, peer_two) = peer_return_handle_vec
.as_mut_slice()
.split_at_mut(1 as usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0 as usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0 as usize).unwrap();
let (peer_one, peer_two) = peer_return_handle_vec.as_mut_slice().split_at_mut(1_usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0_usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0_usize).unwrap();

// Push file to REVFS on peer
let file_to_send = PathBuf::from("../resources/test.txt");
Expand Down
36 changes: 15 additions & 21 deletions citadel_workspace_service/tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod tests {
}];
let returned_service_info = register_and_connect_to_server(to_spawn).await;
let mut service_vec = returned_service_info.unwrap();
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0 as usize) {
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0_usize) {
let disconnect_command = InternalServiceRequest::Disconnect {
cid: *cid,
request_id: Uuid::new_v4(),
Expand Down Expand Up @@ -127,7 +127,7 @@ mod tests {
}];
let returned_service_info = register_and_connect_to_server(to_spawn).await;
let mut service_vec = returned_service_info.unwrap();
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0 as usize) {
if let Some((to_service, from_service, cid)) = service_vec.get_mut(0_usize) {
let serialized_message = bincode2::serialize("Message Test").unwrap();
let message_command = InternalServiceRequest::Message {
message: serialized_message,
Expand Down Expand Up @@ -324,16 +324,14 @@ mod tests {
])
.await?;

let (peer_one, peer_two) = peer_return_handle_vec
.as_mut_slice()
.split_at_mut(1 as usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0 as usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0 as usize).unwrap();
let (peer_one, peer_two) = peer_return_handle_vec.as_mut_slice().split_at_mut(1_usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0_usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0_usize).unwrap();

// Test that service A views the right information
test_list_peers(*cid_a, *cid_b, &to_service_a, from_service_a).await;
test_list_peers(*cid_a, *cid_b, to_service_a, from_service_a).await;
// Test that service B views the right information
test_list_peers(*cid_b, *cid_a, &to_service_b, from_service_b).await;
test_list_peers(*cid_b, *cid_a, to_service_b, from_service_b).await;

Ok(())
}
Expand All @@ -352,11 +350,9 @@ mod tests {
])
.await?;

let (peer_one, peer_two) = peer_return_handle_vec
.as_mut_slice()
.split_at_mut(1 as usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0 as usize).unwrap();
let (_to_service_b, from_service_b, cid_b) = peer_two.get_mut(0 as usize).unwrap();
let (peer_one, peer_two) = peer_return_handle_vec.as_mut_slice().split_at_mut(1_usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0_usize).unwrap();
let (_to_service_b, from_service_b, cid_b) = peer_two.get_mut(0_usize).unwrap();

let service_a_message = Vec::from("Hello World");
let service_a_message_payload = InternalServiceRequest::Message {
Expand Down Expand Up @@ -436,8 +432,8 @@ mod tests {
}];
let returned_service_info = register_and_connect_to_server(to_spawn).await;
let mut service_vec = returned_service_info.unwrap();
if let Some((to_service_a, from_service_a, cid)) = service_vec.get_mut(0 as usize) {
test_kv_for_service(&to_service_a, from_service_a, *cid, None).await
if let Some((to_service_a, from_service_a, cid)) = service_vec.get_mut(0_usize) {
test_kv_for_service(to_service_a, from_service_a, *cid, None).await
} else {
panic!("Service Spawn Error")
}
Expand All @@ -457,11 +453,9 @@ mod tests {
])
.await?;

let (peer_one, peer_two) = peer_return_handle_vec
.as_mut_slice()
.split_at_mut(1 as usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0 as usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0 as usize).unwrap();
let (peer_one, peer_two) = peer_return_handle_vec.as_mut_slice().split_at_mut(1_usize);
let (to_service_a, from_service_a, cid_a) = peer_one.get_mut(0_usize).unwrap();
let (to_service_b, from_service_b, cid_b) = peer_two.get_mut(0_usize).unwrap();

test_kv_for_service(to_service_a, from_service_a, *cid_a, Some(*cid_b)).await?;
test_kv_for_service(to_service_b, from_service_b, *cid_b, Some(*cid_a)).await?;
Expand Down

0 comments on commit a8af842

Please sign in to comment.