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

Commit

Permalink
fix(stress test): ignore InvalidSource errors when sending probes
Browse files Browse the repository at this point in the history
That errors means the node name changed due to relocation but we haven't yet seen the `Relocated` event for it. No reason to abort the test for this. Just skip the node when sending the probes and try again next time.
  • Loading branch information
madadam committed Jan 18, 2021
1 parent 98fc101 commit adabf82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions examples/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/routing/approved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1793,15 +1793,15 @@ 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) {
error!(
"Not sending user message {:?} -> {:?}: direct dst not supported",
src, dst
);
return Err(Error::BadLocation);
return Err(Error::InvalidDestination);
}

let variant = Variant::UserMessage(content);
Expand Down

0 comments on commit adabf82

Please sign in to comment.