Skip to content

Commit 72667f4

Browse files
committed
Fixed 'mithril-end-to-end' clippy warnings from Rust 1.67.0
1 parent f8a89a8 commit 72667f4

File tree

8 files changed

+52
-59
lines changed

8 files changed

+52
-59
lines changed

mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl PoolNode {
3939
let party_id = content
4040
.split('=')
4141
.nth(1)
42-
.ok_or(format!("could not get party_id from string '{}'", content))?;
42+
.ok_or(format!("could not get party_id from string '{content}'"))?;
4343

4444
Ok(party_id.trim().to_string())
4545
}
@@ -75,7 +75,7 @@ impl Devnet {
7575

7676
if artifacts_target_dir.exists() {
7777
fs::remove_dir_all(&artifacts_target_dir)
78-
.map_err(|e| format!("Previous artifacts dir removal failed: {}", e))?;
78+
.map_err(|e| format!("Previous artifacts dir removal failed: {e}"))?;
7979
}
8080

8181
let mut bootstrap_command = Command::new(&bootstrap_script_path);
@@ -96,10 +96,10 @@ impl Devnet {
9696

9797
bootstrap_command
9898
.spawn()
99-
.map_err(|e| format!("{} failed to start: {}", bootstrap_script, e))?
99+
.map_err(|e| format!("{bootstrap_script} failed to start: {e}"))?
100100
.wait()
101101
.await
102-
.map_err(|e| format!("{} failed to run: {}", bootstrap_script, e))?;
102+
.map_err(|e| format!("{bootstrap_script} failed to run: {e}"))?;
103103

104104
Ok(Devnet {
105105
artifacts_dir: artifacts_target_dir,
@@ -126,27 +126,27 @@ impl Devnet {
126126
let bft_nodes = (1..=self.number_of_bft_nodes)
127127
.into_iter()
128128
.map(|n| BftNode {
129-
db_path: self.artifacts_dir.join(format!("node-bft{}/db", n)),
129+
db_path: self.artifacts_dir.join(format!("node-bft{n}/db")),
130130
socket_path: self
131131
.artifacts_dir
132-
.join(format!("node-bft{}/ipc/node.sock", n)),
132+
.join(format!("node-bft{n}/ipc/node.sock")),
133133
})
134134
.collect::<Vec<_>>();
135135

136136
let pool_nodes = (1..=self.number_of_pool_nodes)
137137
.into_iter()
138138
.map(|n| PoolNode {
139-
db_path: self.artifacts_dir.join(format!("node-pool{}/db", n)),
139+
db_path: self.artifacts_dir.join(format!("node-pool{n}/db")),
140140
socket_path: self
141141
.artifacts_dir
142-
.join(format!("node-pool{}/ipc/node.sock", n)),
143-
pool_env_path: self.artifacts_dir.join(format!("node-pool{}/pool.env", n)),
142+
.join(format!("node-pool{n}/ipc/node.sock")),
143+
pool_env_path: self.artifacts_dir.join(format!("node-pool{n}/pool.env")),
144144
kes_secret_key_path: self
145145
.artifacts_dir
146-
.join(format!("node-pool{}/shelley/kes.skey", n)),
146+
.join(format!("node-pool{n}/shelley/kes.skey")),
147147
operational_certificate_path: self
148148
.artifacts_dir
149-
.join(format!("node-pool{}/shelley/node.cert", n)),
149+
.join(format!("node-pool{n}/shelley/node.cert")),
150150
})
151151
.collect::<Vec<_>>();
152152

@@ -168,10 +168,10 @@ impl Devnet {
168168

169169
run_command
170170
.spawn()
171-
.map_err(|e| format!("Failed to start the devnet: {}", e))?
171+
.map_err(|e| format!("Failed to start the devnet: {e}"))?
172172
.wait()
173173
.await
174-
.map_err(|e| format!("Error while starting the devnet: {}", e))?;
174+
.map_err(|e| format!("Error while starting the devnet: {e}"))?;
175175
Ok(())
176176
}
177177

@@ -187,10 +187,10 @@ impl Devnet {
187187

188188
stop_command
189189
.spawn()
190-
.map_err(|e| format!("Failed to stop the devnet: {}", e))?
190+
.map_err(|e| format!("Failed to stop the devnet: {e}"))?
191191
.wait()
192192
.await
193-
.map_err(|e| format!("Error while stopping the devnet: {}", e))?;
193+
.map_err(|e| format!("Error while stopping the devnet: {e}"))?;
194194
Ok(())
195195
}
196196

@@ -206,10 +206,10 @@ impl Devnet {
206206

207207
run_command
208208
.spawn()
209-
.map_err(|e| format!("Failed to delegate stakes to the pools: {}", e))?
209+
.map_err(|e| format!("Failed to delegate stakes to the pools: {e}"))?
210210
.wait()
211211
.await
212-
.map_err(|e| format!("Error while delegating stakes to the pools: {}", e))?;
212+
.map_err(|e| format!("Error while delegating stakes to the pools: {e}"))?;
213213
Ok(())
214214
}
215215
}

mithril-test-lab/mithril-end-to-end/src/end_to_end_spec.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async fn wait_for_enough_immutable(db_directory: &Path) -> Result<(), String> {
128128
}
129129

130130
async fn wait_for_epoch_settings(aggregator_endpoint: &str) -> Result<EpochSettings, String> {
131-
let url = format!("{}/epoch-settings", aggregator_endpoint);
131+
let url = format!("{aggregator_endpoint}/epoch-settings");
132132
info!("Waiting for the aggregator to expose epoch settings");
133133

134134
match attempt!(20, Duration::from_millis(1000), {
@@ -138,7 +138,7 @@ async fn wait_for_epoch_settings(aggregator_endpoint: &str) -> Result<EpochSetti
138138
let epoch_settings = response
139139
.json::<EpochSettings>()
140140
.await
141-
.map_err(|e| format!("Invalid EpochSettings body : {}", e))?;
141+
.map_err(|e| format!("Invalid EpochSettings body : {e}"))?;
142142
info!("Aggregator ready"; "epoch_settings" => #?epoch_settings);
143143
Ok(Some(epoch_settings))
144144
}
@@ -157,8 +157,7 @@ async fn wait_for_epoch_settings(aggregator_endpoint: &str) -> Result<EpochSetti
157157
AttemptResult::Ok(epoch_settings) => Ok(epoch_settings),
158158
AttemptResult::Err(error) => Err(error),
159159
AttemptResult::Timeout() => Err(format!(
160-
"Timeout exhausted for aggregator to be up, no response from `{}`",
161-
url
160+
"Timeout exhausted for aggregator to be up, no response from `{url}`"
162161
)),
163162
}
164163
}
@@ -183,7 +182,7 @@ async fn wait_for_target_epoch(
183182
}
184183
}
185184
Ok(None) => Ok(None),
186-
Err(err) => Err(format!("Could not query current epoch: {}", err)),
185+
Err(err) => Err(format!("Could not query current epoch: {err}")),
187186
}
188187
}) {
189188
AttemptResult::Ok(_) => {
@@ -242,7 +241,7 @@ async fn update_protocol_parameters(aggregator: &mut Aggregator) -> Result<(), S
242241
}
243242

244243
async fn assert_node_producing_snapshot(aggregator_endpoint: &str) -> Result<String, String> {
245-
let url = format!("{}/snapshots", aggregator_endpoint);
244+
let url = format!("{aggregator_endpoint}/snapshots");
246245
info!("Waiting for the aggregator to produce a snapshot");
247246

248247
// todo: reduce the number of attempts if we can reduce the delay between two immutables
@@ -252,11 +251,11 @@ async fn assert_node_producing_snapshot(aggregator_endpoint: &str) -> Result<Str
252251
StatusCode::OK => match response.json::<Vec<Snapshot>>().await.as_deref() {
253252
Ok([snapshot, ..]) => Ok(Some(snapshot.digest.clone())),
254253
Ok(&[]) => Ok(None),
255-
Err(err) => Err(format!("Invalid snapshot body : {}", err,)),
254+
Err(err) => Err(format!("Invalid snapshot body : {err}",)),
256255
},
257-
s => Err(format!("Unexpected status code from Aggregator: {}", s)),
256+
s => Err(format!("Unexpected status code from Aggregator: {s}")),
258257
},
259-
Err(err) => Err(format!("Request to `{}` failed: {}", url, err)),
258+
Err(err) => Err(format!("Request to `{url}` failed: {err}")),
260259
}
261260
}) {
262261
AttemptResult::Ok(digest) => {
@@ -265,8 +264,7 @@ async fn assert_node_producing_snapshot(aggregator_endpoint: &str) -> Result<Str
265264
}
266265
AttemptResult::Err(error) => Err(error),
267266
AttemptResult::Timeout() => Err(format!(
268-
"Timeout exhausted assert_node_producing_snapshot, no response from `{}`",
269-
url
267+
"Timeout exhausted assert_node_producing_snapshot, no response from `{url}`"
270268
)),
271269
}
272270
}
@@ -276,7 +274,7 @@ async fn assert_signer_is_signing_snapshot(
276274
digest: &str,
277275
expected_epoch_min: Epoch,
278276
) -> Result<String, String> {
279-
let url = format!("{}/snapshot/{}", aggregator_endpoint, digest);
277+
let url = format!("{aggregator_endpoint}/snapshot/{digest}");
280278
info!(
281279
"Asserting the aggregator is signing the snapshot message `{}` with an expected min epoch of `{}`",
282280
digest,
@@ -290,16 +288,15 @@ async fn assert_signer_is_signing_snapshot(
290288
Ok(snapshot) => match snapshot.beacon.epoch {
291289
epoch if epoch >= expected_epoch_min => Ok(Some(snapshot)),
292290
epoch => Err(format!(
293-
"Minimum expected snapshot epoch not reached : {} < {}",
294-
epoch, expected_epoch_min
291+
"Minimum expected snapshot epoch not reached : {epoch} < {expected_epoch_min}"
295292
)),
296293
},
297-
Err(err) => Err(format!("Invalid snapshot body : {}", err,)),
294+
Err(err) => Err(format!("Invalid snapshot body : {err}",)),
298295
},
299296
StatusCode::NOT_FOUND => Ok(None),
300-
s => Err(format!("Unexpected status code from Aggregator: {}", s)),
297+
s => Err(format!("Unexpected status code from Aggregator: {s}")),
301298
},
302-
Err(err) => Err(format!("Request to `{}` failed: {}", url, err)),
299+
Err(err) => Err(format!("Request to `{url}` failed: {err}")),
303300
}
304301
}) {
305302
AttemptResult::Ok(snapshot) => {
@@ -309,8 +306,7 @@ async fn assert_signer_is_signing_snapshot(
309306
}
310307
AttemptResult::Err(error) => Err(error),
311308
AttemptResult::Timeout() => Err(format!(
312-
"Timeout exhausted assert_signer_is_signing_snapshot, no response from `{}`",
313-
url
309+
"Timeout exhausted assert_signer_is_signing_snapshot, no response from `{url}`"
314310
)),
315311
}
316312
}
@@ -320,19 +316,19 @@ async fn assert_is_creating_certificate_with_enough_signers(
320316
certificate_hash: &str,
321317
total_signers_expected: usize,
322318
) -> Result<(), String> {
323-
let url = format!("{}/certificate/{}", aggregator_endpoint, certificate_hash);
319+
let url = format!("{aggregator_endpoint}/certificate/{certificate_hash}");
324320

325321
match attempt!(10, Duration::from_millis(1000), {
326322
match reqwest::get(url.clone()).await {
327323
Ok(response) => match response.status() {
328324
StatusCode::OK => match response.json::<Certificate>().await {
329325
Ok(certificate) => Ok(Some(certificate)),
330-
Err(err) => Err(format!("Invalid snapshot body : {}", err,)),
326+
Err(err) => Err(format!("Invalid snapshot body : {err}",)),
331327
},
332328
StatusCode::NOT_FOUND => Ok(None),
333-
s => Err(format!("Unexpected status code from Aggregator: {}", s)),
329+
s => Err(format!("Unexpected status code from Aggregator: {s}")),
334330
},
335-
Err(err) => Err(format!("Request to `{}` failed: {}", url, err)),
331+
Err(err) => Err(format!("Request to `{url}` failed: {err}")),
336332
}
337333
}) {
338334
AttemptResult::Ok(certificate) => {
@@ -354,8 +350,7 @@ async fn assert_is_creating_certificate_with_enough_signers(
354350
}
355351
AttemptResult::Err(error) => Err(error),
356352
AttemptResult::Timeout() => Err(format!(
357-
"Timeout exhausted assert_is_creating_certificate, no response from `{}`",
358-
url
353+
"Timeout exhausted assert_is_creating_certificate, no response from `{url}`"
359354
)),
360355
}
361356
}

mithril-test-lab/mithril-end-to-end/src/mithril/aggregator.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ impl Aggregator {
7878
Ok(())
7979
} else {
8080
Err(match status.code() {
81-
Some(c) => format!(
82-
"`mithril-aggregator genesis bootstrap` exited with code: {}",
83-
c
84-
),
81+
Some(c) => {
82+
format!("`mithril-aggregator genesis bootstrap` exited with code: {c}")
83+
}
8584
None => {
8685
"`mithril-aggregator genesis bootstrap` was terminated with a signal"
8786
.to_string()
@@ -98,7 +97,7 @@ impl Aggregator {
9897
process
9998
.kill()
10099
.await
101-
.map_err(|e| format!("Could not kill aggregator: {:?}", e))?;
100+
.map_err(|e| format!("Could not kill aggregator: {e:?}"))?;
102101
}
103102
Ok(())
104103
}

mithril-test-lab/mithril-end-to-end/src/mithril/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ impl Client {
5858
Ok(())
5959
} else {
6060
self.command
61-
.tail_logs(Some(format!("mithril-client {:?}", args).as_str()), 20)
61+
.tail_logs(Some(format!("mithril-client {args:?}").as_str()), 20)
6262
.await?;
6363

6464
Err(match status.code() {
65-
Some(c) => format!("mithril-client exited with code: {}", c),
65+
Some(c) => format!("mithril-client exited with code: {c}"),
6666
None => "mithril-client was terminated with a signal".to_string(),
6767
})
6868
}

mithril-test-lab/mithril-end-to-end/src/mithril/signer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Signer {
2424
) -> Result<Self, String> {
2525
let party_id = pool_node.party_id()?;
2626
let magic_id = DEVNET_MAGIC_ID.to_string();
27-
let data_stores_path = format!("./stores/signer-{}", party_id);
27+
let data_stores_path = format!("./stores/signer-{party_id}");
2828
let mut env = HashMap::from([
2929
("NETWORK", "devnet"),
3030
("RUN_INTERVAL", "300"),
@@ -53,7 +53,7 @@ impl Signer {
5353
let args = vec!["-vvv"];
5454

5555
let mut command = MithrilCommand::new("mithril-signer", work_dir, bin_dir, env, &args)?;
56-
command.set_log_name(format!("mithril-signer-{}", party_id).as_str());
56+
command.set_log_name(format!("mithril-signer-{party_id}").as_str());
5757

5858
Ok(Self {
5959
party_id,

mithril-test-lab/mithril-end-to-end/src/utils/file_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub async fn tail(file_path: &Path, number_of_line: u64) -> Result<String, Strin
1818
.map_err(|e| format!("Failed to tail file `{}`: {}", file_path.display(), e))?;
1919

2020
String::from_utf8(tail_result.stdout)
21-
.map_err(|e| format!("Failed to parse tail output to utf8: {}", e))
21+
.map_err(|e| format!("Failed to parse tail output to utf8: {e}"))
2222
}
2323

2424
#[cfg(test)]
@@ -35,17 +35,17 @@ mod tests {
3535
.join(subfolder_name);
3636
if temp_dir.exists() {
3737
fs::remove_dir_all(&temp_dir)
38-
.unwrap_or_else(|_| panic!("Could not remove dir {:?}", temp_dir));
38+
.unwrap_or_else(|_| panic!("Could not remove dir {temp_dir:?}"));
3939
}
4040
fs::create_dir_all(&temp_dir)
41-
.unwrap_or_else(|_| panic!("Could not create dir {:?}", temp_dir));
41+
.unwrap_or_else(|_| panic!("Could not create dir {temp_dir:?}"));
4242

4343
temp_dir
4444
}
4545

4646
fn write_file(path: &Path, file_content: &str) {
4747
let mut source_file = File::create(path).unwrap();
48-
write!(source_file, "{}", file_content).unwrap();
48+
write!(source_file, "{file_content}").unwrap();
4949
}
5050

5151
#[tokio::test]

mithril-test-lab/mithril-end-to-end/src/utils/mithril_command.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl MithrilCommand {
2323
default_args: &[&str],
2424
) -> Result<MithrilCommand, String> {
2525
let process_path = bin_dir.canonicalize().unwrap().join(name);
26-
let log_path = work_dir.join(format!("{}.log", name));
26+
let log_path = work_dir.join(format!("{name}.log"));
2727

2828
// ugly but it's far easier for callers to manipulate string literals
2929
let mut env_vars: HashMap<String, String> = env_vars
@@ -53,7 +53,7 @@ impl MithrilCommand {
5353
}
5454

5555
pub fn set_log_name(&mut self, name: &str) {
56-
self.log_path = self.work_dir.join(format!("{}.log", name));
56+
self.log_path = self.work_dir.join(format!("{name}.log"));
5757
}
5858

5959
pub fn set_env_var(&mut self, name: &str, value: &str) {

mithril-test-lab/mithril-end-to-end/src/utils/spec_utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ mod tests {
9898
let elapsed = now.elapsed().as_millis();
9999
assert!(
100100
(10..=12).contains(&elapsed),
101-
"Failure, after one loop the elapsed time was not ~10ms, elapsed: {}",
102-
elapsed
101+
"Failure, after one loop the elapsed time was not ~10ms, elapsed: {elapsed}"
103102
);
104103
}
105104
}

0 commit comments

Comments
 (0)