diff --git a/gateway-messages/src/sp_to_mgs.rs b/gateway-messages/src/sp_to_mgs.rs index 8fbef08c..2fb46265 100644 --- a/gateway-messages/src/sp_to_mgs.rs +++ b/gateway-messages/src/sp_to_mgs.rs @@ -1233,6 +1233,7 @@ pub enum UpdateError { ImageMismatch, SignatureNotValidated, VersionNotSupported, + RollbackProtection, } impl fmt::Display for UpdateError { @@ -1292,6 +1293,9 @@ impl fmt::Display for UpdateError { Self::InvalidComponent => { write!(f, "invalid component for operation") } + Self::RollbackProtection => { + write!(f, "invalid epoch compared to active image") + } } } } diff --git a/gateway-messages/tests/versioning/mod.rs b/gateway-messages/tests/versioning/mod.rs index b9b737f2..484bc0a1 100644 --- a/gateway-messages/tests/versioning/mod.rs +++ b/gateway-messages/tests/versioning/mod.rs @@ -23,6 +23,7 @@ mod v14; mod v15; mod v16; mod v17; +mod v18; pub fn assert_serialized( expected: &[u8], diff --git a/gateway-messages/tests/versioning/v18.rs b/gateway-messages/tests/versioning/v18.rs new file mode 100644 index 00000000..ce7b90e8 --- /dev/null +++ b/gateway-messages/tests/versioning/v18.rs @@ -0,0 +1,36 @@ +// 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::SerializedSize; +use gateway_messages::SpResponse; +use gateway_messages::UpdateError; + +#[test] +fn error_enums() { + let mut out = [0; SpResponse::MAX_SIZE]; + + let response: [UpdateError; 5] = [ + UpdateError::InvalidArchive, + UpdateError::ImageMismatch, + UpdateError::SignatureNotValidated, + UpdateError::VersionNotSupported, + UpdateError::RollbackProtection, + ]; + let expected = vec![30, 31, 32, 33, 34]; + assert_serialized(&mut out, &expected, &response); +}