From c85751a9156644952aef3b4e20131ae53ea50aa0 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 13 Oct 2025 14:56:03 +0200 Subject: [PATCH] fix: fixed port for default local network Additionally, adds a test to check the default values of the module --- crates/icp/src/manifest/mod.rs | 70 ++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/crates/icp/src/manifest/mod.rs b/crates/icp/src/manifest/mod.rs index fcba22a9..e2e97714 100644 --- a/crates/icp/src/manifest/mod.rs +++ b/crates/icp/src/manifest/mod.rs @@ -1,5 +1,5 @@ use crate::{ - network::{Configuration, Connected, Gateway, Managed, Port}, + network::{Configuration, Connected, Managed}, prelude::*, }; use schemars::JsonSchema; @@ -43,12 +43,7 @@ impl Default for Networks { Networks::Networks(vec![ NetworkManifest { name: "local".to_string(), - configuration: Configuration::Managed(Managed { - gateway: Gateway { - host: "localhost".to_string(), - port: Port::Random, - }, - }), + configuration: Configuration::Managed(Managed::default()), }, NetworkManifest { name: "mainnet".to_string(), @@ -127,3 +122,64 @@ impl Locate for Locator { } } } + +#[cfg(test)] +mod tests { + use anyhow::Error; + + use crate::network::{Gateway, Port}; + + use super::*; + + #[test] + fn default_canisters() -> Result<(), Error> { + assert_eq!( + Canisters::default(), + Canisters::Canisters(vec![Item::Path("canisters/*".into())]) + ); + + Ok(()) + } + + #[test] + fn default_networks() -> Result<(), Error> { + assert_eq!( + Networks::default(), + Networks::Networks(vec![ + NetworkManifest { + name: "local".to_string(), + configuration: Configuration::Managed(Managed { + gateway: Gateway { + host: "localhost".to_string(), + port: Port::Fixed(8000), + }, + }), + }, + NetworkManifest { + name: "mainnet".to_string(), + configuration: Configuration::Connected(Connected { + url: "https://ic0.app".to_string(), + root_key: None, + }), + }, + ]) + ); + + Ok(()) + } + + #[test] + fn default_environments() -> Result<(), Error> { + assert_eq!( + Environments::default(), + Environments::Environments(vec![EnvironmentManifest { + name: "local".to_string(), + network: "local".to_string(), + canisters: CanisterSelection::Everything, + settings: None, + }]) + ); + + Ok(()) + } +}