Skip to content

Commit 7589699

Browse files
committed
clippy
1 parent 9570db8 commit 7589699

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

rs/registry/canister/src/invariants/subnet.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,21 @@ pub(crate) fn check_subnet_invariants(
110110
}
111111

112112
// SEV-enabled subnets consist of SEV-enabled nodes only (i.e. nodes with a chip ID in the node record)
113-
if let Some(features) = subnet_record.features.as_ref() {
114-
if features.sev_enabled == Some(true) {
115-
for &node_id in &subnet_members {
116-
// handle missing node record
117-
let node_record = get_node_record_from_snapshot(node_id, snapshot)?
118-
.ok_or_else(|| InvariantCheckError {
119-
msg: format!("Subnet {subnet_id} has node {node_id} in its membership but the node record does not exist"),
120-
source: None,
121-
})?;
122-
123-
// handle missing chip_id
124-
node_record.chip_id.as_ref().ok_or_else(|| InvariantCheckError {
125-
msg: format!("Subnet {subnet_id} is SEV-enabled but at least one of its nodes is not: {node_id} does not have a chip ID in its node record"),
113+
if let Some(features) = subnet_record.features.as_ref()
114+
&& features.sev_enabled == Some(true)
115+
{
116+
for &node_id in &subnet_members {
117+
// handle missing node record
118+
let node_record = get_node_record_from_snapshot(node_id, snapshot)?
119+
.ok_or_else(|| InvariantCheckError {
120+
msg: format!("Subnet {subnet_id} has node {node_id} in its membership but the node record does not exist"),
126121
source: None,
127-
})?;
128-
}
122+
})?;
123+
// handle missing chip_id
124+
node_record.chip_id.as_ref().ok_or_else(|| InvariantCheckError {
125+
msg: format!("Subnet {subnet_id} is SEV-enabled but at least one of its nodes is not: {node_id} does not have a chip ID in its node record"),
126+
source: None,
127+
})?;
129128
}
130129
}
131130
}

rs/registry/canister/src/invariants/subnet/tests.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ fn only_sev_enabled_subnets_consist_of_sev_enabled_nodes() {
7777
check_subnet_invariants(&snapshot).unwrap();
7878

7979
// a non SEV-enabled subnet with some nodes with and some without chip IDs is compliant
80-
let mut test_node_record = NodeRecord::default();
81-
test_node_record.chip_id = Some("a chip id".into());
80+
let test_node_record = NodeRecord {
81+
chip_id: Some("a chip id".into()),
82+
..Default::default()
83+
};
8284
snapshot.insert(
8385
make_node_record_key(test_node_id).into_bytes(),
8486
test_node_record.encode_to_vec(),
@@ -94,8 +96,10 @@ fn only_sev_enabled_subnets_consist_of_sev_enabled_nodes() {
9496
make_subnet_record_key(test_subnet_id).into_bytes(),
9597
test_subnet_record.encode_to_vec(),
9698
);
97-
let mut test_node_record = NodeRecord::default();
98-
test_node_record.chip_id = None;
99+
let test_node_record = NodeRecord {
100+
chip_id: None,
101+
..Default::default()
102+
};
99103
snapshot.insert(
100104
make_node_record_key(test_node_id).into_bytes(),
101105
test_node_record.encode_to_vec(),
@@ -129,8 +133,10 @@ fn only_sev_enabled_subnets_consist_of_sev_enabled_nodes() {
129133
check_subnet_invariants(&snapshot).unwrap();
130134

131135
// an SEV-enabled subnet with some nodes with and some without chip ID is NOT compliant
132-
let mut test_node_record = NodeRecord::default();
133-
test_node_record.chip_id = None;
136+
let test_node_record = NodeRecord {
137+
chip_id: None,
138+
..Default::default()
139+
};
134140
snapshot.insert(
135141
make_node_record_key(test_node_id).into_bytes(),
136142
test_node_record.encode_to_vec(),
@@ -200,7 +206,7 @@ fn setup_minimal_registry_snapshot_for_check_subnet_invariants(
200206
.collect();
201207

202208
let test_subnet_record = SubnetRecord {
203-
membership: membership,
209+
membership,
204210
..Default::default()
205211
};
206212
snapshot.insert(

0 commit comments

Comments
 (0)