Skip to content

Commit 6bd2660

Browse files
authored
Add cosmo ignition target (#445)
Updated per RFD 142
1 parent 66d8ea1 commit 6bd2660

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

gateway-messages/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub const HF_PAGE_SIZE: usize = 256;
6969
/// for more detail and discussion.
7070
pub mod version {
7171
pub const MIN: u32 = 2;
72-
pub const CURRENT: u32 = 20;
72+
pub const CURRENT: u32 = 21;
7373

7474
/// MGS protocol version in which SP watchdog messages were added
7575
pub const WATCHDOG_VERSION: u32 = 12;

gateway-messages/src/sp_to_mgs/ignition.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub enum SystemType {
113113
Sidecar,
114114
Psc,
115115
Unknown(u16),
116+
Cosmo,
116117
}
117118

118119
impl From<u16> for SystemType {
@@ -121,6 +122,7 @@ impl From<u16> for SystemType {
121122
raw_system_type::GIMLET => Self::Gimlet,
122123
raw_system_type::SIDECAR => Self::Sidecar,
123124
raw_system_type::PSC => Self::Psc,
125+
raw_system_type::COSMO => Self::Cosmo,
124126
_ => Self::Unknown(val),
125127
}
126128
}
@@ -131,6 +133,7 @@ mod raw_system_type {
131133
pub(super) const GIMLET: u16 = 0b0000_0000_0001_0001;
132134
pub(super) const SIDECAR: u16 = 0b0000_0000_0001_0010;
133135
pub(super) const PSC: u16 = 0b0000_0000_0001_0011;
136+
pub(super) const COSMO: u16 = 0b0000_0000_0000_0100;
134137
}
135138

136139
#[derive(

gateway-messages/tests/versioning/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod v17;
2626
mod v18;
2727
mod v19;
2828
mod v20;
29+
mod v21;
2930

3031
pub fn assert_serialized<T: Serialize + SerializedSize + std::fmt::Debug>(
3132
expected: &[u8],
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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::ignition::SystemType;
20+
21+
#[test]
22+
fn cosmo_ignition() {
23+
// We technically only need `Cosmo` but test everything else
24+
// here again for good measure
25+
for (system_type, system_type_val) in [
26+
(SystemType::Gimlet, &[0_u8] as &[_]),
27+
(SystemType::Sidecar, &[1]),
28+
(SystemType::Psc, &[2]),
29+
(SystemType::Unknown(0xa0a1), &[3, 0xa1, 0xa0]),
30+
(SystemType::Cosmo, &[4]),
31+
] {
32+
assert_serialized(&system_type_val, &system_type);
33+
}
34+
}

0 commit comments

Comments
 (0)