From f2d3d72c334a06dbb8eea2dfc763904a4e24e90c Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Fri, 24 May 2024 14:37:48 +0300 Subject: [PATCH] Remove new_mock use optional parameter in new --- hex_assignments/src/footfall.rs | 13 +++---------- hex_assignments/src/landtype.rs | 13 +++---------- hex_assignments/src/lib.rs | 6 +++--- hex_assignments/src/urbanization.rs | 13 +++---------- mobile_verifier/src/boosting_oracles/data_sets.rs | 6 +++--- 5 files changed, 15 insertions(+), 36 deletions(-) diff --git a/hex_assignments/src/footfall.rs b/hex_assignments/src/footfall.rs index bd9ece9e0..be092800e 100644 --- a/hex_assignments/src/footfall.rs +++ b/hex_assignments/src/footfall.rs @@ -9,16 +9,9 @@ pub struct Footfall { } impl Footfall { - pub fn new() -> Self { + pub fn new(footfall: Option) -> Self { Self { - footfall: None, - timestamp: None, - } - } - - pub fn new_mock(footfall: DiskTreeMap) -> Self { - Self { - footfall: Some(footfall), + footfall, timestamp: None, } } @@ -26,7 +19,7 @@ impl Footfall { impl Default for Footfall { fn default() -> Self { - Self::new() + Self::new(None) } } diff --git a/hex_assignments/src/landtype.rs b/hex_assignments/src/landtype.rs index 533bb6f21..29ba9b645 100644 --- a/hex_assignments/src/landtype.rs +++ b/hex_assignments/src/landtype.rs @@ -9,16 +9,9 @@ pub struct Landtype { } impl Landtype { - pub fn new() -> Self { + pub fn new(landtype: Option) -> Self { Self { - landtype: None, - timestamp: None, - } - } - - pub fn new_mock(landtype: DiskTreeMap) -> Self { - Self { - landtype: Some(landtype), + landtype, timestamp: None, } } @@ -26,7 +19,7 @@ impl Landtype { impl Default for Landtype { fn default() -> Self { - Self::new() + Self::new(None) } } diff --git a/hex_assignments/src/lib.rs b/hex_assignments/src/lib.rs index 20d15b2b3..da87d9e5d 100644 --- a/hex_assignments/src/lib.rs +++ b/hex_assignments/src/lib.rs @@ -214,9 +214,9 @@ mod tests { footfall.to_disktree(Cursor::new(&mut footfall_buff), |w, v| w.write_all(&[*v]))?; landtype.to_disktree(Cursor::new(&mut landtype_buf), |w, v| w.write_all(&[*v]))?; - let footfall = Footfall::new_mock(DiskTreeMap::with_buf(footfall_buff)?); - let landtype = Landtype::new_mock(DiskTreeMap::with_buf(landtype_buf)?); - let urbanization = Urbanization::new_mock(DiskTreeMap::with_buf(urbanized_buf)?); + let footfall = Footfall::new(Some(DiskTreeMap::with_buf(footfall_buff)?)); + let landtype = Landtype::new(Some(DiskTreeMap::with_buf(landtype_buf)?)); + let urbanization = Urbanization::new(Some(DiskTreeMap::with_buf(urbanized_buf)?)); // Let the testing commence let data = HexBoostData::builder() diff --git a/hex_assignments/src/urbanization.rs b/hex_assignments/src/urbanization.rs index c4a2c0943..2cc2ca79f 100644 --- a/hex_assignments/src/urbanization.rs +++ b/hex_assignments/src/urbanization.rs @@ -9,16 +9,9 @@ pub struct Urbanization { } impl Urbanization { - pub fn new() -> Self { + pub fn new(urbanized: Option) -> Self { Self { - urbanized: None, - timestamp: None, - } - } - - pub fn new_mock(urbanized: DiskTreeMap) -> Self { - Self { - urbanized: Some(urbanized), + urbanized, timestamp: None, } } @@ -26,7 +19,7 @@ impl Urbanization { impl Default for Urbanization { fn default() -> Self { - Self::new() + Self::new(None) } } diff --git a/mobile_verifier/src/boosting_oracles/data_sets.rs b/mobile_verifier/src/boosting_oracles/data_sets.rs index 2a3034383..e0065e055 100644 --- a/mobile_verifier/src/boosting_oracles/data_sets.rs +++ b/mobile_verifier/src/boosting_oracles/data_sets.rs @@ -262,9 +262,9 @@ impl DataSetDownloaderDaemon { .create() .await?; - let urbanization = Urbanization::new(); - let footfall = Footfall::new(); - let landtype = Landtype::new(); + let urbanization = Urbanization::new(None); + let footfall = Footfall::new(None); + let landtype = Landtype::new(None); let hex_boost_data = HexBoostData::builder() .footfall(footfall) .landtype(landtype)