diff --git a/consensus/src/dag/mod.rs b/consensus/src/dag/mod.rs index 106c1c9c..a38f306a 100644 --- a/consensus/src/dag/mod.rs +++ b/consensus/src/dag/mod.rs @@ -362,14 +362,14 @@ 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") @@ -377,7 +377,7 @@ mod test { // 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") diff --git a/consensus/src/dag/reconstruction/dag.rs b/consensus/src/dag/reconstruction/dag.rs index c22159c0..e488b49c 100644 --- a/consensus/src/dag/reconstruction/dag.rs +++ b/consensus/src/dag/reconstruction/dag.rs @@ -145,7 +145,7 @@ mod test { ) -> Vec>> { 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())) diff --git a/consensus/src/dag/reconstruction/mod.rs b/consensus/src/dag/reconstruction/mod.rs index 5a44b648..ec7b8c1e 100644 --- a/consensus/src/dag/reconstruction/mod.rs +++ b/consensus/src/dag/reconstruction/mod.rs @@ -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 @@ -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); @@ -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())) diff --git a/consensus/src/dag/reconstruction/parents.rs b/consensus/src/dag/reconstruction/parents.rs index 8fb6fcd5..ac1ea954 100644 --- a/consensus/src/dag/reconstruction/parents.rs +++ b/consensus/src/dag/reconstruction/parents.rs @@ -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 @@ -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); @@ -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); @@ -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())) diff --git a/consensus/src/dag/validation.rs b/consensus/src/dag/validation.rs index 65f5c62e..66f63547 100644 --- a/consensus/src/dag/validation.rs +++ b/consensus/src/dag/validation.rs @@ -224,9 +224,9 @@ mod test { let 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]); @@ -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]); @@ -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]); @@ -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]); @@ -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]); @@ -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]); diff --git a/consensus/src/testing/dag.rs b/consensus/src/testing/dag.rs index 6e43d07e..770fa628 100644 --- a/consensus/src/testing/dag.rs +++ b/consensus/src/testing/dag.rs @@ -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() diff --git a/consensus/src/units/store.rs b/consensus/src/units/store.rs index ee7b3474..e04adea8 100644 --- a/consensus/src/units/store.rs +++ b/consensus/src/units/store.rs @@ -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()); @@ -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() }) @@ -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)