diff --git a/examples/stress.rs b/examples/stress.rs index 79b8472b8d..0af63ed89d 100644 --- a/examples/stress.rs +++ b/examples/stress.rs @@ -21,7 +21,8 @@ use rand::{ }; use serde::{Deserialize, Serialize}; use sn_routing::{ - Config, DstLocation, Event as RoutingEvent, Routing, SrcLocation, TransportConfig, + Config, DstLocation, Error as RoutingError, Event as RoutingEvent, Routing, SrcLocation, + TransportConfig, }; use std::{ collections::BTreeMap, @@ -450,10 +451,14 @@ impl Network { }; let bytes = bincode::serialize(&message)?.into(); - node.send_message(SrcLocation::Node(src), DstLocation::Section(dst), bytes) - .await?; - - Ok(true) + match node + .send_message(SrcLocation::Node(src), DstLocation::Section(dst), bytes) + .await + { + Ok(()) => Ok(true), + Err(RoutingError::InvalidSource) => Ok(false), // node name changed + Err(error) => Err(error.into()), + } } fn try_print_status(&mut self) { diff --git a/src/routing/approved.rs b/src/routing/approved.rs index 05608e6e3c..ac7d13b8b0 100644 --- a/src/routing/approved.rs +++ b/src/routing/approved.rs @@ -1793,7 +1793,7 @@ impl Approved { "Not sending user message {:?} -> {:?}: not part of the source location", src, dst ); - return Err(Error::BadLocation); + return Err(Error::InvalidSource); } if matches!(dst, DstLocation::Direct) { @@ -1801,7 +1801,7 @@ impl Approved { "Not sending user message {:?} -> {:?}: direct dst not supported", src, dst ); - return Err(Error::BadLocation); + return Err(Error::InvalidDestination); } let variant = Variant::UserMessage(content);