From 8b742ff9dae3f416202780edc612dd0a30c229ed Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Tue, 17 Dec 2024 20:23:24 +0000 Subject: [PATCH] Fix clippy --- tooling/nargo/src/foreign_calls/rpc.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tooling/nargo/src/foreign_calls/rpc.rs b/tooling/nargo/src/foreign_calls/rpc.rs index 3ac12df3810..ef4f11b8a48 100644 --- a/tooling/nargo/src/foreign_calls/rpc.rs +++ b/tooling/nargo/src/foreign_calls/rpc.rs @@ -94,6 +94,9 @@ impl ForeignCallExecutor for RPCForeignCallExecutor where F: AcirField + Serialize + for<'a> Deserialize<'a>, { + /// Execute an async call blocking the current thread. + /// This method cannot be called from inside a `tokio` runtime, for that to work + /// we need to offload the execution into a different thread; see the tests. fn execute(&mut self, foreign_call: &ForeignCallWaitInfo) -> ResolveForeignCallResult { let encoded_params = rpc_params!(ResolveForeignCallRequest { session_id: self.id, @@ -112,7 +115,6 @@ where #[cfg(test)] mod tests { - use acvm::{ acir::brillig::ForeignCallParam, brillig_vm::brillig::ForeignCallResult, pwg::ForeignCallWaitInfo, FieldElement, @@ -185,12 +187,14 @@ mod tests { /// Spawn and run the executor in the background until all clients are closed. fn run(mut self) -> RPCForeignCallClient { let (tx, mut rx) = mpsc::unbounded_channel::(); - let _ = tokio::task::spawn_blocking(move || { + let handle = tokio::task::spawn_blocking(move || { while let Some((req, tx)) = rx.blocking_recv() { let res = self.execute(&req); let _ = tx.send(res); } }); + // The task will finish when the client goes out of scope. + drop(handle); RPCForeignCallClient { tx } } }