diff --git a/libraries/messages/src/lib.rs b/libraries/messages/src/lib.rs index 58c11cf2..8b55dba2 100644 --- a/libraries/messages/src/lib.rs +++ b/libraries/messages/src/lib.rs @@ -24,7 +24,10 @@ pub mod sensor; pub mod sensor_status; pub mod state; -pub const MAX_SIZE: usize = 64; +pub const MAX_HEALTH_SIZE: usize = 47; +pub const MAX_SENSOR_SIZE: usize = 53; +pub const MAX_STATE_SIZE: usize = 13; +pub const MAX_LOGNCOMMAND_SIZE: usize = 15; pub use logging::{ErrorContext, Event, Log, LogLevel}; @@ -70,7 +73,7 @@ impl Message { #[cfg(test)] mod test { - use crate::Message; + use crate::{Message, MAX_HEALTH_SIZE, MAX_LOGNCOMMAND_SIZE, MAX_SENSOR_SIZE, MAX_STATE_SIZE}; use proptest::prelude::*; proptest! { @@ -82,19 +85,19 @@ mod test { // The size of the message should be less than or equal the maximum size. match msg.data { crate::Data::State(_) => { - assert!(dbg!(bytes.len()) <= 13); + assert!(dbg!(bytes.len()) <= MAX_STATE_SIZE); } crate::Data::Sensor(_) => { - assert!(dbg!(bytes.len()) <= 53); + assert!(dbg!(bytes.len()) <= MAX_SENSOR_SIZE); } crate::Data::Log(_) => { - assert!(dbg!(bytes.len()) <= 15); + assert!(dbg!(bytes.len()) <= MAX_LOGNCOMMAND_SIZE); } crate::Data::Command(_) => { - assert!(dbg!(bytes.len()) <= 15); + assert!(dbg!(bytes.len()) <= MAX_LOGNCOMMAND_SIZE); } crate::Data::Health(_) => { - assert!(dbg!(bytes.len()) <= 47); + assert!(dbg!(bytes.len()) <= MAX_HEALTH_SIZE); } } }