Skip to content

Commit 1f25b69

Browse files
committed
Add UpdateError::RollbackProtection
Use hubtools 0.4.6 until release engineering tools handle epoch management. Update the UpdateError enum serialization tests to cover recent additions.
1 parent 3a686ca commit 1f25b69

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

gateway-messages/src/sp_to_mgs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,7 @@ pub enum UpdateError {
12331233
ImageMismatch,
12341234
SignatureNotValidated,
12351235
VersionNotSupported,
1236+
RollbackProtection,
12361237
}
12371238

12381239
impl fmt::Display for UpdateError {
@@ -1292,6 +1293,9 @@ impl fmt::Display for UpdateError {
12921293
Self::InvalidComponent => {
12931294
write!(f, "invalid component for operation")
12941295
}
1296+
Self::RollbackProtection => {
1297+
write!(f, "invalid epoch compared to active image")
1298+
}
12951299
}
12961300
}
12971301
}

gateway-messages/tests/versioning/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod v14;
2323
mod v15;
2424
mod v16;
2525
mod v17;
26+
mod v18;
2627

2728
pub fn assert_serialized<T: Serialize + SerializedSize + std::fmt::Debug>(
2829
expected: &[u8],
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! This source file is named after the protocol version being tested,
6+
//! e.g. v01.rs implements tests for protocol version 1.
7+
//! The tested protocol version is represented by "$VERSION" below.
8+
//!
9+
//! The tests in this module check that the serialized form of messages from MGS
10+
//! protocol version $VERSION have not changed.
11+
//!
12+
//! If a test in this module fails, _do not change the test_! This means you
13+
//! have changed, deleted, or reordered an existing message type or enum
14+
//! variant, and you should revert that change. This will remain true until we
15+
//! bump the `version::MIN` to a value higher than $VERSION, at which point these
16+
//! tests can be removed as we will stop supporting $VERSION.
17+
18+
use super::assert_serialized;
19+
use gateway_messages::SerializedSize;
20+
use gateway_messages::SpResponse;
21+
use gateway_messages::UpdateError;
22+
23+
#[test]
24+
fn error_enums() {
25+
let mut out = [0; SpResponse::MAX_SIZE];
26+
27+
let response: [UpdateError; 5] = [
28+
UpdateError::InvalidArchive,
29+
UpdateError::ImageMismatch,
30+
UpdateError::SignatureNotValidated,
31+
UpdateError::VersionNotSupported,
32+
UpdateError::RollbackProtection,
33+
];
34+
let expected = vec![30, 31, 32, 33, 34];
35+
assert_serialized(&mut out, &expected, &response);
36+
}

0 commit comments

Comments
 (0)