Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix: changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan-DPC committed May 3, 2021
1 parent a8f625b commit a95dbba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Error {
FailedSignature,
#[error("Cannot route.")]
CannotRoute,
#[error("empty recipient list")]
#[error("Empty recipient list")]
EmptyRecipientList,
#[error("The config is invalid")]
InvalidConfig,
Expand Down
26 changes: 7 additions & 19 deletions src/routing/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ impl Comm {

if successes == delivery_group_size {
if failed_recipients.is_empty() {
Ok(SendStatus::MinDeliveryGroupSizeReached(failed_recipients))
} else {
Ok(SendStatus::AllRecipients)
} else {
Ok(SendStatus::MinDeliveryGroupSizeReached(failed_recipients))
}
} else {
Ok(SendStatus::MinDeliveryGroupSizeFailed(failed_recipients))
Expand Down Expand Up @@ -291,8 +291,7 @@ async fn handle_incoming_messages(
}
}

/// Returns the status of the

/// Returns the status of the send operation.
#[derive(Debug, Clone)]
pub enum SendStatus {
AllRecipients,
Expand Down Expand Up @@ -346,10 +345,7 @@ mod tests {
.send(&[peer0.addr, peer1.addr], 1, message.clone())
.await?;

assert_matches!(
status,
SendStatus::AllRecipients | SendStatus::MinDeliveryGroupSizeReached(_)
);
assert_matches!(status, SendStatus::AllRecipients);

assert_eq!(peer0.rx.recv().await, Some(message));

Expand Down Expand Up @@ -380,13 +376,9 @@ mod tests {

assert_matches!(
&status,
&SendStatus::MinDeliveryGroupSizeFailed(_)
&SendStatus::MinDeliveryGroupSizeFailed(_) => vec![invalid_addr]
);

if let SendStatus::MinDeliveryGrupSizeFailed(ref failed_recipients) = status {
assert_eq!(&failed_recipients[..], &[invalid_addr]);
}

Ok(())
}

Expand Down Expand Up @@ -435,13 +427,9 @@ mod tests {

assert_matches!(
status,
SendStatus::MinDeliveryGroupSizeFailed(_)
SendStatus::MinDeliveryGroupSizeFailed(_) => vec![invalid_addr]
);

if let SendStatus::MinDeliveryGroupSizeFailed(failed_recipients) = status.clone() {
assert_eq!(failed_recipients, [invalid_addr]);
assert_eq!(peer.rx.recv().await, Some(message));
}
assert_eq!(peer.rx.recv().await, Some(message));

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/routing/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Dispatcher {
) -> Result<Vec<Command>> {
let msg_bytes = message.serialize()?;

let cmds: Vec<Command> = match message {
let cmds = match message {
MessageType::Ping | MessageType::NodeMessage(_) => {
let status = self
.comm
Expand Down

0 comments on commit a95dbba

Please sign in to comment.