Skip to content

Commit

Permalink
Remove new_mock use optional parameter in new
Browse files Browse the repository at this point in the history
  • Loading branch information
kurotych committed May 24, 2024
1 parent 86d651b commit f2d3d72
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
13 changes: 3 additions & 10 deletions hex_assignments/src/footfall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,17 @@ pub struct Footfall {
}

impl Footfall {
pub fn new() -> Self {
pub fn new(footfall: Option<DiskTreeMap>) -> Self {
Self {
footfall: None,
timestamp: None,
}
}

pub fn new_mock(footfall: DiskTreeMap) -> Self {
Self {
footfall: Some(footfall),
footfall,
timestamp: None,
}
}
}

impl Default for Footfall {
fn default() -> Self {
Self::new()
Self::new(None)
}
}

Expand Down
13 changes: 3 additions & 10 deletions hex_assignments/src/landtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,17 @@ pub struct Landtype {
}

impl Landtype {
pub fn new() -> Self {
pub fn new(landtype: Option<DiskTreeMap>) -> Self {
Self {
landtype: None,
timestamp: None,
}
}

pub fn new_mock(landtype: DiskTreeMap) -> Self {
Self {
landtype: Some(landtype),
landtype,
timestamp: None,
}
}
}

impl Default for Landtype {
fn default() -> Self {
Self::new()
Self::new(None)
}
}

Expand Down
6 changes: 3 additions & 3 deletions hex_assignments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 3 additions & 10 deletions hex_assignments/src/urbanization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,17 @@ pub struct Urbanization {
}

impl Urbanization {
pub fn new() -> Self {
pub fn new(urbanized: Option<DiskTreeMap>) -> Self {
Self {
urbanized: None,
timestamp: None,
}
}

pub fn new_mock(urbanized: DiskTreeMap) -> Self {
Self {
urbanized: Some(urbanized),
urbanized,
timestamp: None,
}
}
}

impl Default for Urbanization {
fn default() -> Self {
Self::new()
Self::new(None)
}
}

Expand Down
6 changes: 3 additions & 3 deletions mobile_verifier/src/boosting_oracles/data_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ impl DataSetDownloaderDaemon<Footfall, Landtype, Urbanization> {
.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)
Expand Down

0 comments on commit f2d3d72

Please sign in to comment.