Skip to content

Commit 32d875c

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 9c44b5d commit 32d875c

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ resolver = "2"
1515

1616
[workspace.dependencies]
1717
tlvc = { git = "https://github.com/oxidecomputer/tlvc.git", branch = "main" }
18-
hubtools = { git = "https://github.com/oxidecomputer/hubtools.git", branch = "main"}
18+
hubtools = { version = "0.4.6", git = "https://github.com/oxidecomputer/hubtools.git" }
1919
slog-error-chain = { git = "https://github.com/oxidecomputer/slog-error-chain.git", branch = "main", features = ["derive"] }
2020

2121
anyhow = "1.0"

gateway-messages/src/sp_to_mgs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ pub enum UpdateError {
11701170
ImageMismatch,
11711171
SignatureNotValidated,
11721172
VersionNotSupported,
1173+
RollbackProtection,
11731174
}
11741175

11751176
impl fmt::Display for UpdateError {
@@ -1229,6 +1230,9 @@ impl fmt::Display for UpdateError {
12291230
Self::InvalidComponent => {
12301231
write!(f, "invalid component for operation")
12311232
}
1233+
Self::RollbackProtection => {
1234+
write!(f, "invalid epoch compared to active image")
1235+
}
12321236
}
12331237
}
12341238
}

gateway-messages/tests/versioning/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod v13;
2121
mod v14;
2222
mod v15;
2323
mod v16;
24+
mod v17;
2425

2526
pub fn assert_serialized(
2627
out: &mut [u8],
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use super::assert_serialized;
2+
use gateway_messages::SerializedSize;
3+
use gateway_messages::SpResponse;
4+
use gateway_messages::UpdateError;
5+
6+
#[test]
7+
fn error_enums() {
8+
let mut out = [0; SpResponse::MAX_SIZE];
9+
10+
let response: [UpdateError; 5] = [
11+
UpdateError::InvalidArchive,
12+
UpdateError::ImageMismatch,
13+
UpdateError::SignatureNotValidated,
14+
UpdateError::VersionNotSupported,
15+
UpdateError::RollbackProtection,
16+
];
17+
let expected = vec![30, 31, 32, 33, 34];
18+
assert_serialized(&mut out, &expected, &response);
19+
}

0 commit comments

Comments
 (0)