diff --git a/kuksa_databroker/databroker/src/broker.rs b/kuksa_databroker/databroker/src/broker.rs index f65e503d..ac94a7e3 100644 --- a/kuksa_databroker/databroker/src/broker.rs +++ b/kuksa_databroker/databroker/src/broker.rs @@ -201,12 +201,12 @@ impl Entry { if let Some(datapoint) = &update.datapoint { self.validate_value(&datapoint.value)?; self.validate_allowed(&datapoint.value)?; - self.validate_timestamp(datapoint.ts)?; + self.validate_timestamp(&datapoint.ts)?; } if let Some(Some(actuatortarget)) = &update.actuator_target { self.validate_value(&actuatortarget.value)?; self.validate_allowed(&actuatortarget.value)?; - self.validate_timestamp(actuatortarget.ts)?; + self.validate_timestamp(&actuatortarget.ts)?; } if let Some(Some(updated_allowed)) = update.allowed.clone() { if Some(updated_allowed.clone()) != self.metadata.allowed { @@ -558,12 +558,12 @@ impl Entry { } } - fn validate_timestamp(&self, timestamp: SystemTime) -> Result<(), UpdateError> { - if self.datapoint.ts > timestamp { + fn validate_timestamp(&self, timestamp: &SystemTime) -> Result<(), UpdateError> { + if self.datapoint.ts > *timestamp { return Err(UpdateError::TimestampTooOld); } if let Some(target) = &self.actuator_target { - if target.ts > timestamp { + if target.ts > *timestamp { return Err(UpdateError::TimestampTooOld); } } @@ -1747,7 +1747,6 @@ mod tests { EntryType::Sensor, "Test datapoint 1".to_owned(), None, - None, ) .await .expect("Register datapoint should succeed"); @@ -1760,7 +1759,6 @@ mod tests { EntryType::Actuator, "Test datapoint 2".to_owned(), None, - None, ) .await .expect("Register datapoint should succeed"); @@ -1783,7 +1781,6 @@ mod tests { data_type: None, description: None, allowed: None, - unit: None, }, )]) .await @@ -1803,7 +1800,6 @@ mod tests { data_type: None, description: None, allowed: None, - unit: None, }, )]) .await @@ -1823,7 +1819,6 @@ mod tests { data_type: None, description: None, allowed: None, - unit: None, }, )]) .await @@ -1854,7 +1849,6 @@ mod tests { data_type: None, description: None, allowed: None, - unit: None, }, )]) .await