From 3033e3e7243ddbb93225aa036248f047b0163326 Mon Sep 17 00:00:00 2001 From: 0xmountaintop <37070449+0xmountaintop@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:13:51 +0800 Subject: [PATCH] refactor: refactor test coordinator connection (#37) Co-authored-by: Zhuo Zhang --- src/prover/mod.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/prover/mod.rs b/src/prover/mod.rs index 10ba6b2..e262254 100644 --- a/src/prover/mod.rs +++ b/src/prover/mod.rs @@ -37,16 +37,11 @@ impl Prover { assert!(self.l2geth_client.is_some()); } - // Use the first coordinator client to test the connection - match self.coordinator_clients[0].get_token(true).await { - Ok(_) => {} - Err(e) => { - panic!("Failed to login: {:?}", e); - } - }; + self.test_coordinator_connection().await; let app = Router::new().route("/", get(|| async { "OK" })); - let addr = SocketAddr::from_str(&self.health_listener_addr).expect("Failed to parse socket address"); + let addr = SocketAddr::from_str(&self.health_listener_addr) + .expect("Failed to parse socket address"); let server = axum::Server::bind(&addr).serve(app.into_make_service()); let health_check_server_task = tokio::spawn(server); @@ -65,6 +60,13 @@ impl Prover { } } + async fn test_coordinator_connection(&self) { + self.coordinator_clients[0] + .get_token(true) + .await + .expect("Failed to login to coordinator"); + } + #[instrument(skip(self))] async fn working_loop(&self, i: usize) { loop {