Skip to content

Commit 13d1d9b

Browse files
netsiriusalexisbatykiduartgomezsanity
authored
Add update op to network monitor (#1578)
Co-authored-by: Alexis Batyk <[email protected]> Co-authored-by: nacho.d.g <[email protected]> Co-authored-by: Ian Clarke (aider) <[email protected]>
1 parent 8b1f640 commit 13d1d9b

32 files changed

+1517
-466
lines changed

Cargo.lock

+21-94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/core/src/client_events/combinator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<const N: usize> super::ClientEventsProxy for ClientEventsCombinator<N> {
6868
fn recv(&mut self) -> BoxFuture<'_, Result<OpenRequest<'static>, ClientError>> {
6969
async {
7070
let Some((idx, mut rx, res)) = self.pending_futs.next().await else {
71-
unreachable!();
71+
unreachable!("pending_futs should always have a future unless the combinator is dropped");
7272
};
7373

7474
let res = res

crates/core/src/client_events/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ where
233233
}
234234
res = results.next(), if !results.is_empty() => {
235235
let Some(f_res) = res else {
236-
unreachable!();
236+
unreachable!("results.next() should only return None if results is empty, which is guarded against");
237237
};
238238
match f_res {
239239
(cli_id, Ok(Some(res))) => {
@@ -592,14 +592,14 @@ async fn process_open_request(
592592
})));
593593
}
594594
ClientRequest::Disconnect { .. } => {
595-
unreachable!();
595+
tracing::debug!("Received disconnect from user event");
596596
}
597597
ClientRequest::NodeQueries(_) => {
598598
tracing::debug!("Received node queries from user event");
599599

600600
let Some(tx) = callback_tx else {
601601
tracing::error!("callback_tx not available for NodeQueries");
602-
unreachable!();
602+
unreachable!("callback_tx should always be Some for NodeQueries based on initialization logic");
603603
};
604604

605605
if let Err(err) = op_manager
@@ -1041,7 +1041,9 @@ pub(crate) mod test {
10411041
};
10421042
return Some(request.into());
10431043
}
1044-
_ => unreachable!(),
1044+
_ => unreachable!(
1045+
"gen_range(0..100) should always fall into one of the defined ranges"
1046+
),
10451047
}
10461048
}
10471049
None

crates/core/src/client_events/websocket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ async fn new_client_connection(
407407
match response_recv.recv().await {
408408
Some(HostCallbackResult::NewId { id: client_id, .. }) => Ok((response_recv, client_id)),
409409
None => Err(ErrorKind::NodeUnavailable.into()),
410-
other => unreachable!("received unexpected message: {other:?}"),
410+
other => unreachable!("received unexpected message after NewConnection: {other:?}"),
411411
}
412412
}
413413

crates/core/src/config/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl ConfigPathsArgs {
669669
.unwrap_or_else(|| {
670670
let default_dirs = Self::default_dirs(id)?;
671671
let Either::Left(defaults) = default_dirs else {
672-
unreachable!()
672+
unreachable!("default_dirs should return Left if data_dir is None and id is not set for temp dir")
673673
};
674674
Ok(defaults.data_dir().to_path_buf())
675675
})?;
@@ -712,7 +712,7 @@ impl ConfigPathsArgs {
712712
.unwrap_or_else(|| {
713713
let default_dirs = Self::default_dirs(id)?;
714714
let Either::Left(defaults) = default_dirs else {
715-
unreachable!()
715+
unreachable!("default_dirs should return Left if config_dir is None and id is not set for temp dir")
716716
};
717717
Ok(defaults.config_dir().to_path_buf())
718718
})?;
@@ -968,7 +968,7 @@ impl GlobalExecutor {
968968
} else if let Some(rt) = &*ASYNC_RT {
969969
rt.spawn(f)
970970
} else {
971-
unreachable!("the executor must have been initialized")
971+
unreachable!("ASYNC_RT should be initialized if Handle::try_current fails")
972972
}
973973
}
974974
}

crates/core/src/contract/executor/mock_runtime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Executor<MockRuntime> {
4141
_req: ClientRequest<'_>,
4242
_updates: Option<mpsc::UnboundedSender<Result<HostResponse, WsClientError>>>,
4343
) -> Response {
44-
unreachable!()
44+
unreachable!("MockRuntime does not handle client requests directly")
4545
}
4646
}
4747

@@ -105,7 +105,7 @@ impl ContractExecutor for Executor<MockRuntime> {
105105
.map_err(ExecutorError::other)?;
106106
Ok(UpsertResult::Updated(incoming_state))
107107
}
108-
(update, contract) => unreachable!("{update:?}, {contract:?}"),
108+
(update, contract) => unreachable!("Invalid combination of state/delta and contract presence: {update:?}, {contract:?}"),
109109
}
110110
}
111111

crates/core/src/contract/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ where
113113
ContractHandlerEvent::PutResponse {
114114
new_value: Err(err),
115115
}
116-
}
116+
} // UpsertResult::NotAvailable is not used in this path
117117
};
118118

119119
contract_handler
@@ -228,7 +228,7 @@ where
228228
tracing::debug!(%error, "shutting down contract handler");
229229
})?;
230230
}
231-
_ => unreachable!(),
231+
_ => unreachable!("ContractHandlerEvent enum should be exhaustive here"),
232232
}
233233
}
234234
}

0 commit comments

Comments
 (0)