Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gateway-messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub const ROT_PAGE_SIZE: usize = 512;
/// for more detail and discussion.
pub mod version {
pub const MIN: u32 = 2;
pub const CURRENT: u32 = 15;
pub const CURRENT: u32 = 16;

/// MGS protocol version in which SP watchdog messages were added
pub const WATCHDOG_VERSION: u32 = 12;
Expand Down
1 change: 1 addition & 0 deletions gateway-messages/src/sp_to_mgs/measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ pub enum MeasurementKind {
InputCurrent,
InputVoltage,
Speed,
CpuTctl,
}
1 change: 1 addition & 0 deletions gateway-messages/tests/versioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod v12;
mod v13;
mod v14;
mod v15;
mod v16;

pub fn assert_serialized(
out: &mut [u8],
Expand Down
39 changes: 39 additions & 0 deletions gateway-messages/tests/versioning/v16.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! This source file is named after the protocol version being tested,
//! e.g. v01.rs implements tests for protocol version 1.
//! The tested protocol version is represented by "$VERSION" below.
//!
//! The tests in this module check that the serialized form of messages from MGS
//! protocol version $VERSION have not changed.
//!
//! If a test in this module fails, _do not change the test_! This means you
//! have changed, deleted, or reordered an existing message type or enum
//! variant, and you should revert that change. This will remain true until we
//! bump the `version::MIN` to a value higher than $VERSION, at which point these
//! tests can be removed as we will stop supporting $VERSION.

use super::assert_serialized;
use gateway_messages::measurement::MeasurementKind;
use gateway_messages::SerializedSize;
use gateway_messages::SpResponse;

#[test]
fn measurement_kinds() {
let mut out = [0; SpResponse::MAX_SIZE];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this could be MeasurementKind::MAX_SIZE


for (kind, serialized) in [
(MeasurementKind::Temperature, &[0]),
(MeasurementKind::Power, &[1]),
(MeasurementKind::Current, &[2]),
(MeasurementKind::Voltage, &[3]),
(MeasurementKind::InputCurrent, &[4]),
(MeasurementKind::InputVoltage, &[5]),
(MeasurementKind::Speed, &[6]),
(MeasurementKind::CpuTctl, &[7]),
] {
assert_serialized(&mut out, serialized, &kind);
}
}