fix: format code
This commit is contained in:
parent
39ace002e9
commit
59169be873
|
@ -21,8 +21,7 @@ pub struct Branches<Id> {
|
|||
tips: HashSet<Id>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
pub struct Branch<Id> {
|
||||
id: Id,
|
||||
parent: Id,
|
||||
|
@ -47,8 +46,8 @@ impl<Id: Copy> Branch<Id> {
|
|||
}
|
||||
|
||||
impl<Id> Branches<Id>
|
||||
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<Id> {
|
|||
}
|
||||
|
||||
impl<Id> Cryptarchia<Id>
|
||||
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<Id> Cryptarchia<Id>
|
|||
|
||||
#[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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue