From 59169be873dec2dd6d3148461af94b878a2ad014 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 30 May 2024 12:44:42 +0200 Subject: [PATCH] fix: format code --- consensus/cryptarchia-engine/src/lib.rs | 47 ++++++++++++++++--------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/consensus/cryptarchia-engine/src/lib.rs b/consensus/cryptarchia-engine/src/lib.rs index ea3f2295..5c7b1e8e 100644 --- a/consensus/cryptarchia-engine/src/lib.rs +++ b/consensus/cryptarchia-engine/src/lib.rs @@ -21,8 +21,7 @@ pub struct Branches { tips: HashSet, } -#[derive(PartialEq)] -#[derive(Clone, Debug)] +#[derive(PartialEq, Clone, Debug)] pub struct Branch { id: Id, parent: Id, @@ -47,8 +46,8 @@ impl Branch { } impl Branches - where - Id: Eq + std::hash::Hash + Copy, +where + Id: Eq + std::hash::Hash + Copy, { pub fn from_genesis(genesis: Id) -> Self { let mut branches = HashMap::new(); @@ -140,8 +139,8 @@ pub enum Error { } impl Cryptarchia - where - Id: Eq + std::hash::Hash + Copy, +where + Id: Eq + std::hash::Hash + Copy, { pub fn from_genesis(id: Id, config: Config) -> Self { Self { @@ -221,7 +220,7 @@ impl Cryptarchia #[cfg(test)] pub mod tests { - use super::{Cryptarchia}; + use super::Cryptarchia; use crate::Config; use std::hash::{DefaultHasher, Hash, Hasher}; @@ -298,7 +297,7 @@ pub mod tests { k, engine.config.s() ) - .id, + .id, long_p ); @@ -328,20 +327,34 @@ pub mod tests { let parent = engine.genesis(); // Get branch directly from HashMap - let branch1 = engine.branches.get(&parent).ok_or("At least one branch should be there"); + let branch1 = engine + .branches + .get(&parent) + .ok_or("At least one branch should be there"); let branches = engine.branches(); // Get branch using getter - let branch2 = branches.get(&parent).ok_or("At least one branch should be there"); + let branch2 = branches + .get(&parent) + .ok_or("At least one branch should be there"); assert_eq!(branch1, branch2); - assert_eq!(branch1.expect("id is set").id(), branch2.expect("id is set").id()); - assert_eq!(branch1.expect("parent is set").parent(), branch2.expect("parent is set").parent()); - assert_eq!(branch1.expect("slot is set").slot(), branch2.expect("slot is set").slot()); - assert_eq!(branch1.expect("length is set").length(), branch2.expect("length is set").length()); - + assert_eq!( + branch1.expect("id is set").id(), + branch2.expect("id is set").id() + ); + assert_eq!( + branch1.expect("parent is set").parent(), + branch2.expect("parent is set").parent() + ); + assert_eq!( + branch1.expect("slot is set").slot(), + branch2.expect("slot is set").slot() + ); + assert_eq!( + branch1.expect("length is set").length(), + branch2.expect("length is set").length() + ); } } - -