Skip to content

Commit c37ce0d

Browse files
chore: Improve test coverage
1 parent 4913ed3 commit c37ce0d

File tree

3 files changed

+8
-43
lines changed

3 files changed

+8
-43
lines changed

rs/replicated_state/src/canister_state.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -336,18 +336,6 @@ impl CanisterState {
336336
)
337337
}
338338

339-
pub fn from_parts(
340-
execution_state: Option<ExecutionState>,
341-
system_state: SystemState,
342-
scheduler_state: SchedulerState,
343-
) -> Self {
344-
Self {
345-
system_state,
346-
execution_state,
347-
scheduler_state,
348-
}
349-
}
350-
351339
/// Checks the constraints that a canister should always respect.
352340
/// These invariants will be verified at the end of each execution round.
353341
pub fn check_invariants(&self, default_limit: NumBytes) -> Result<(), StateError> {
@@ -596,28 +584,4 @@ pub fn num_bytes_try_from(pages: NumWasmPages) -> Result<NumBytes, String> {
596584

597585
pub mod testing {
598586
pub use super::queues::testing::{new_canister_queues_for_test, CanisterQueuesTesting};
599-
use super::*;
600-
601-
/// Exposes `CanisterState` internals for use in other crates' unit tests.
602-
pub trait CanisterStateTesting {
603-
/// Testing only: Publicly exposes `CanisterState::push_input()`.
604-
fn push_input(
605-
&mut self,
606-
msg: RequestOrResponse,
607-
) -> Result<(), (StateError, RequestOrResponse)>;
608-
}
609-
610-
impl CanisterStateTesting for CanisterState {
611-
fn push_input(
612-
&mut self,
613-
msg: RequestOrResponse,
614-
) -> Result<(), (StateError, RequestOrResponse)> {
615-
(self as &mut CanisterState).push_input(
616-
msg,
617-
&mut (i64::MAX / 2),
618-
SubnetType::Application,
619-
InputQueueType::RemoteSubnet,
620-
)
621-
}
622-
}
623587
}

rs/replicated_state/src/metadata_state.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,12 @@ impl TryFrom<pb_metadata::NetworkTopology> for NetworkTopology {
275275
try_from_option_field(entry.subnet_topology, "NetworkTopology::subnets::V")?,
276276
);
277277
}
278-
// NetworkTopology.nns_subnet_id will be removed in the following PR
279-
// Currently, initialise nns_subnet_id with dummy value in case not found
280-
let nns_subnet_id =
281-
match try_from_option_field(item.nns_subnet_id, "NetworkTopology::nns_subnet_id") {
282-
Ok(subnet_id) => subnet_id_try_from_protobuf(subnet_id)?,
283-
Err(_) => SubnetId::new(PrincipalId::new_anonymous()),
284-
};
278+
279+
let nns_subnet_id = subnet_id_try_from_protobuf(try_from_option_field(
280+
item.nns_subnet_id,
281+
"NetworkTopology::nns_subnet_id",
282+
)?)?;
283+
285284
let mut ecdsa_signing_subnets = BTreeMap::new();
286285
for entry in item.ecdsa_signing_subnets {
287286
let mut subnet_ids = vec![];

rs/replicated_state/src/metadata_state/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ fn roundtrip_encoding() {
456456
system_metadata.node_public_keys = btreemap! {
457457
node_test_id(1) => pk_der,
458458
};
459+
system_metadata.bitcoin_get_successors_follow_up_responses =
460+
btreemap! { 10.into() => vec![vec![1], vec![2]] };
459461

460462
// Decoding a `SystemMetadata` with no `canister_allocation_ranges` succeeds.
461463
let mut proto = pb::SystemMetadata::from(&system_metadata);

0 commit comments

Comments
 (0)