Skip to content

Commit

Permalink
Clippy got more demanding
Browse files Browse the repository at this point in the history
  • Loading branch information
timorleph committed Aug 12, 2024
1 parent 7795832 commit 566741c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft"
version = "0.37.1"
version = "0.37.2"
edition = "2021"
authors = ["Cardinal Cryptography"]
categories = ["algorithms", "data-structures", "cryptography", "database"]
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/dag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,22 @@ mod test {
let forker_id = NodeIndex(3);
let keychain = keychains.get(forker_id.0).expect("we have the keychain");
let unit = random_full_parent_units_up_to(0, node_count, session_id)
.get(0)
.first()
.expect("we have initial units")
.get(forker_id.0)
.expect("We have the forker")
.clone();
let unit = Signed::sign(unit, keychain);
let mut fork = random_full_parent_units_up_to(0, node_count, session_id)
.get(0)
.first()
.expect("we have initial units")
.get(forker_id.0)
.expect("We have the forker")
.clone();
// we might have randomly created an identical "fork"
while fork.hash() == unit.hash() {
fork = random_full_parent_units_up_to(0, node_count, session_id)
.get(0)
.first()
.expect("we have initial units")
.get(forker_id.0)
.expect("We have the forker")
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/dag/reconstruction/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ mod test {
) -> Vec<Vec<ReconstructedUnit<TestingFullUnit>>> {
let hashes: Vec<_> = dag.iter().map(unit_hashes).collect();
let initial_units: Vec<_> = dag
.get(0)
.first()
.expect("only called on nonempty dags")
.iter()
.map(|unit| ReconstructedUnit::initial(unit.clone()))
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/dag/reconstruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ mod test {
fn requests_single_parent() {
let mut reconstruction = Reconstruction::new();
let dag = random_full_parent_units_up_to(1, NodeCount(4), 43);
for unit in dag.get(0).expect("just created").iter().skip(1) {
for unit in dag.first().expect("just created").iter().skip(1) {
reconstruction.add_unit(unit.clone());
}
let unit = dag
Expand Down Expand Up @@ -335,7 +335,7 @@ mod test {
let node_count = NodeCount(7);
let mut reconstruction = Reconstruction::new();
let dag = random_full_parent_units_up_to(0, node_count, 43);
for unit in dag.get(0).expect("just created") {
for unit in dag.first().expect("just created") {
reconstruction.add_unit(unit.clone());
}
let other_dag = random_full_parent_units_up_to(1, node_count, 43);
Expand All @@ -353,7 +353,7 @@ mod test {
&Request::ParentsOf(unit_hash),
);
let parent_hashes: HashMap<_, _> = other_dag
.get(0)
.first()
.expect("other dag has initial units")
.iter()
.map(|unit| (unit.coord(), unit.hash()))
Expand Down
8 changes: 4 additions & 4 deletions consensus/src/dag/reconstruction/parents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ mod test {
fn requests_single_parent() {
let mut reconstruction = Reconstruction::new();
let dag = random_full_parent_units_up_to(1, NodeCount(4), 43);
for unit in dag.get(0).expect("just created").iter().skip(1) {
for unit in dag.first().expect("just created").iter().skip(1) {
reconstruction.add_unit(unit.clone());
}
let unit = dag
Expand All @@ -316,7 +316,7 @@ mod test {
let mut reconstruction = Reconstruction::new();
let mut dag = random_full_parent_units_up_to(7, NodeCount(4), 43);
dag.reverse();
for unit in dag.get(0).expect("we have the top units") {
for unit in dag.first().expect("we have the top units") {
let ReconstructionResult { units, requests } = reconstruction.add_unit(unit.clone());
assert!(units.is_empty());
assert_eq!(requests.len(), 4);
Expand All @@ -341,7 +341,7 @@ mod test {
fn handles_bad_hash() {
let mut reconstruction = Reconstruction::new();
let dag = random_full_parent_units_up_to(0, NodeCount(4), 43);
for unit in dag.get(0).expect("just created") {
for unit in dag.first().expect("just created") {
reconstruction.add_unit(unit.clone());
}
let other_dag = random_full_parent_units_up_to(1, NodeCount(4), 43);
Expand All @@ -359,7 +359,7 @@ mod test {
&Request::ParentsOf(unit_hash),
);
let parent_hashes: HashMap<_, _> = other_dag
.get(0)
.first()
.expect("other dag has initial units")
.iter()
.map(|unit| (unit.coord(), unit.hash()))
Expand Down
16 changes: 8 additions & 8 deletions consensus/src/dag/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ mod test {
let store = UnitStore::<WrappedSignedUnit>::new(node_count);
let mut validator = Validator::new(UnitValidator::new(session_id, keychains[0], max_round));
let unit = random_full_parent_units_up_to(0, node_count, session_id)
.get(0)
.first()
.expect("we have the first round")
.get(0)
.first()
.expect("we have the initial unit for the zeroth creator")
.clone();
let unit = Signed::sign(unit, &keychains[0]);
Expand All @@ -252,9 +252,9 @@ mod test {
let mut store = UnitStore::new(node_count);
let mut validator = Validator::new(UnitValidator::new(session_id, keychains[0], max_round));
let unit = random_full_parent_units_up_to(0, node_count, session_id)
.get(0)
.first()
.expect("we have the first round")
.get(0)
.first()
.expect("we have the initial unit for the zeroth creator")
.clone();
let unit = Signed::sign(unit, &keychains[0]);
Expand Down Expand Up @@ -290,7 +290,7 @@ mod test {
let fork = random_full_parent_units_up_to(2, node_count, session_id)
.get(2)
.expect("we have the requested round")
.get(0)
.first()
.expect("we have the unit for the zeroth creator")
.clone();
let fork = Signed::sign(fork, &keychains[0]);
Expand Down Expand Up @@ -322,7 +322,7 @@ mod test {
let fork = random_full_parent_units_up_to(2, node_count, session_id)
.get(2)
.expect("we have the requested round")
.get(0)
.first()
.expect("we have the unit for the zeroth creator")
.clone();
let fork = Signed::sign(fork, &keychains[0]);
Expand All @@ -347,7 +347,7 @@ mod test {
let fork = random_full_parent_units_up_to(2, node_count, session_id)
.get(2)
.expect("we have the requested round")
.get(0)
.first()
.expect("we have the unit for the zeroth creator")
.clone();
let fork = Signed::sign(fork, &keychains[0]);
Expand Down Expand Up @@ -395,7 +395,7 @@ mod test {
let fork = random_full_parent_units_up_to(2, node_count, session_id)
.get(2)
.expect("we have the requested round")
.get(0)
.first()
.expect("we have the unit for the zeroth creator")
.clone();
let fork = Signed::sign(fork, &keychains[0]);
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/testing/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl DagFeeder {
) -> DagFeeder {
let units_map = units.iter().map(|u| (u.hash(), u.clone())).collect();
let node_count = units
.get(0)
.first()
.expect("we have at least one unit")
.unit
.control_hash()
Expand Down
10 changes: 5 additions & 5 deletions consensus/src/units/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ mod test {
let node_count = NodeCount(7);
let mut store = UnitStore::new(node_count);
let unit = random_full_parent_units_up_to(0, node_count, 43)
.get(0)
.first()
.expect("we have the first round")
.get(0)
.first()
.expect("we have the initial unit for the zeroth creator")
.clone();
store.insert(unit.clone());
Expand All @@ -174,9 +174,9 @@ mod test {
let variants: HashSet<_> = (0..15)
.map(|_| {
random_full_parent_units_up_to(0, node_count, 43)
.get(0)
.first()
.expect("we have the first round")
.get(0)
.first()
.expect("we have the initial unit for the zeroth creator")
.clone()
})
Expand All @@ -188,7 +188,7 @@ mod test {
for unit in &variants {
assert_eq!(store.unit(&unit.hash()), Some(unit));
}
let canonical_unit = variants.get(0).expect("we have the unit").clone();
let canonical_unit = variants.first().expect("we have the unit").clone();
assert_eq!(
store.canonical_unit(canonical_unit.coord()),
Some(&canonical_unit)
Expand Down

0 comments on commit 566741c

Please sign in to comment.