Skip to content

Commit 44a8ecf

Browse files
committed
Clippy fixes
1 parent 0f01fdb commit 44a8ecf

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

src/bitcoin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ impl BitcoinNodeCluster {
286286
let mut cluster = Self {
287287
inner: Vec::with_capacity(n_nodes),
288288
};
289-
for config in ctx.config.bitcoin.iter() {
289+
for config in &ctx.config.bitcoin {
290290
let node = BitcoinNode::new(config, Arc::clone(&ctx.docker)).await?;
291-
cluster.inner.push(node)
291+
cluster.inner.push(node);
292292
}
293293

294294
Ok(cluster)
@@ -327,7 +327,7 @@ impl BitcoinNodeCluster {
327327
if i != j {
328328
let ip = match &to_node.spawn_output {
329329
SpawnOutput::Container(container) => container.ip.clone(),
330-
_ => "127.0.0.1".to_string(),
330+
SpawnOutput::Child(_) => "127.0.0.1".to_string(),
331331
};
332332

333333
let add_node_arg = format!("{}:{}", ip, to_node.config.p2p_port);

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Client {
1919

2020
impl Client {
2121
pub fn new(host: &str, port: u16) -> Result<Self> {
22-
let host = format!("http://{}:{}", host, port);
22+
let host = format!("http://{host}:{port}");
2323
let client = HttpClientBuilder::default()
2424
.request_timeout(Duration::from_secs(120))
2525
.build(host)?;

src/docker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl DockerEnv {
7474
}
7575

7676
async fn create_network(docker: &Docker, test_case_id: &str) -> Result<(String, String)> {
77-
let network_name = format!("test_network_{}", test_case_id);
77+
let network_name = format!("test_network_{test_case_id}");
7878
let options = CreateNetworkOptions {
7979
name: network_name.clone(),
8080
check_duplicate: true,
@@ -95,15 +95,15 @@ impl DockerEnv {
9595
let exposed_ports: HashMap<String, HashMap<(), ()>> = config
9696
.ports
9797
.iter()
98-
.map(|port| (format!("{}/tcp", port), HashMap::new()))
98+
.map(|port| (format!("{port}/tcp"), HashMap::new()))
9999
.collect();
100100

101101
let port_bindings: HashMap<String, Option<Vec<PortBinding>>> = config
102102
.ports
103103
.iter()
104104
.map(|port| {
105105
(
106-
format!("{}/tcp", port),
106+
format!("{port}/tcp"),
107107
Some(vec![PortBinding {
108108
host_ip: Some("0.0.0.0".to_string()),
109109
host_port: Some(port.to_string()),
@@ -196,7 +196,7 @@ impl DockerEnv {
196196
return Ok(());
197197
}
198198

199-
println!("Pulling image: {}", image);
199+
println!("Pulling image: {image}");
200200
let options = Some(CreateImageOptions {
201201
from_image: image,
202202
..Default::default()
@@ -207,7 +207,7 @@ impl DockerEnv {
207207
match result {
208208
Ok(info) => {
209209
if let (Some(status), Some(progress)) = (info.status, info.progress) {
210-
print!("\r{}: {} ", status, progress);
210+
print!("\r{status}: {progress} ");
211211
stdout().flush().unwrap();
212212
}
213213
}

src/node.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ impl<C: Config> Node<C> {
7777
let kind = C::node_kind();
7878

7979
config.node_config().map_or(Ok(Vec::new()), |node_config| {
80-
let config_path = dir.join(format!("{}_config.toml", kind));
80+
let config_path = dir.join(format!("{kind}_config.toml"));
8181
config_to_file(node_config, &config_path)
82-
.with_context(|| format!("Error writing {} config to file", kind))?;
82+
.with_context(|| format!("Error writing {kind} config to file"))?;
8383

8484
Ok(vec![
85-
format!("--{}-config-path", kind),
85+
format!("--{kind}-config-path"),
8686
config_path.display().to_string(),
8787
])
8888
})
@@ -102,7 +102,7 @@ impl<C: Config> Node<C> {
102102
// Handle full node not having any node config
103103
let node_config_args = Self::get_node_config_args(config)?;
104104

105-
let rollup_config_path = dir.join(format!("{}_rollup_config.toml", kind));
105+
let rollup_config_path = dir.join(format!("{kind}_rollup_config.toml"));
106106
config_to_file(&config.rollup_config(), &rollup_config_path)?;
107107

108108
Command::new(citrea)
@@ -120,7 +120,7 @@ impl<C: Config> Node<C> {
120120
.stderr(Stdio::from(stderr_file))
121121
.kill_on_drop(true)
122122
.spawn()
123-
.context(format!("Failed to spawn {} process", kind))
123+
.context(format!("Failed to spawn {kind} process"))
124124
.map(SpawnOutput::Child)
125125
}
126126

@@ -229,7 +229,7 @@ where
229229
async fn start(&mut self, new_config: Option<Self::Config>) -> Result<()> {
230230
let config = self.config_mut();
231231
if let Some(new_config) = new_config {
232-
*config = new_config
232+
*config = new_config;
233233
}
234234
*self.spawn_output() = Self::spawn(config)?;
235235
self.wait_for_ready(None).await

src/test_case.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This module provides the TestCaseRunner and TestCase trait for running and defining test cases.
1+
//! This module provides the `TestCaseRunner` and `TestCase` trait for running and defining test cases.
22
//! It handles setup, execution, and cleanup of test environments.
33
44
use std::{
@@ -36,7 +36,7 @@ use crate::{
3636
pub struct TestCaseRunner<T: TestCase>(T);
3737

3838
impl<T: TestCase> TestCaseRunner<T> {
39-
/// Creates a new TestCaseRunner with the given test case.
39+
/// Creates a new `TestCaseRunner`` with the given test case.
4040
pub fn new(test_case: T) -> Self {
4141
Self(test_case)
4242
}
@@ -85,7 +85,7 @@ impl<T: TestCase> TestCaseRunner<T> {
8585

8686
if let Err(_) | Ok(Err(_)) = result {
8787
if let Err(e) = f.dump_log() {
88-
eprintln!("Error dumping log: {}", e);
88+
eprintln!("Error dumping log: {e}");
8989
}
9090
}
9191

@@ -100,8 +100,7 @@ impl<T: TestCase> TestCaseRunner<T> {
100100
Err(panic_error) => {
101101
let panic_msg = panic_error
102102
.downcast_ref::<String>()
103-
.map(|s| s.to_string())
104-
.unwrap_or_else(|| "Unknown panic".to_string());
103+
.map_or_else(|| "Unknown panic".to_string(), ToString::to_string);
105104
bail!(panic_msg)
106105
}
107106
}
@@ -138,7 +137,7 @@ impl<T: TestCase> TestCaseRunner<T> {
138137
env: env.bitcoin().clone(),
139138
idx: i,
140139
..bitcoin.clone()
141-
})
140+
});
142141
}
143142

144143
// Target first bitcoin node as DA for now
@@ -158,7 +157,7 @@ impl<T: TestCase> TestCaseRunner<T> {
158157
..da_config.clone()
159158
},
160159
storage: StorageConfig {
161-
path: dbs_dir.join(format!("{}-db", node_kind)),
160+
path: dbs_dir.join(format!("{node_kind}-db")),
162161
db_max_open_files: None,
163162
},
164163
rpc: RpcConfig {
@@ -193,7 +192,7 @@ impl<T: TestCase> TestCaseRunner<T> {
193192
..da_config.clone()
194193
},
195194
storage: StorageConfig {
196-
path: dbs_dir.join(format!("{}-db", node_kind)),
195+
path: dbs_dir.join(format!("{node_kind}-db")),
197196
db_max_open_files: None,
198197
},
199198
rpc: RpcConfig {
@@ -219,7 +218,7 @@ impl<T: TestCase> TestCaseRunner<T> {
219218
..da_config.clone()
220219
},
221220
storage: StorageConfig {
222-
path: dbs_dir.join(format!("{}-db", node_kind)),
221+
path: dbs_dir.join(format!("{node_kind}-db")),
223222
db_max_open_files: None,
224223
},
225224
rpc: RpcConfig {

src/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ pub fn get_stderr_path(dir: &Path) -> PathBuf {
4242
/// Get genesis path from resources
4343
/// TODO: assess need for customable genesis path in e2e tests
4444
pub fn get_default_genesis_path() -> PathBuf {
45-
let workspace_root = get_workspace_root();
46-
let mut path = workspace_root.to_path_buf();
45+
let mut path = get_workspace_root();
4746
path.push("resources");
4847
path.push("genesis");
4948
path.push("bitcoin-regtest");
@@ -101,7 +100,7 @@ pub fn tail_file(path: &Path, lines: usize) -> Result<()> {
101100
}
102101

103102
for line in last_lines {
104-
println!("{}", line);
103+
println!("{line}");
105104
}
106105

107106
Ok(())

0 commit comments

Comments
 (0)