@@ -254,7 +254,7 @@ impl Context {
254254 artifacts : Arc :: new ( crate :: store_artifact:: MockInMemoryArtifactStore :: new ( ) ) ,
255255 project : Arc :: new ( icp:: MockProjectLoader :: minimal ( ) ) ,
256256 identity : Arc :: new ( icp:: identity:: MockIdentityLoader :: anonymous ( ) ) ,
257- network : Arc :: new ( icp:: network:: MockNetworkAccessor :: localhost ( ) ) ,
257+ network : Arc :: new ( icp:: network:: MockNetworkAccessor :: new ( ) ) ,
258258 agent : Arc :: new ( icp:: agent:: Creator ) ,
259259 builder : Arc :: new ( icp:: canister:: build:: UnimplementedMockBuilder ) ,
260260 syncer : Arc :: new ( icp:: canister:: sync:: UnimplementedMockSyncer ) ,
@@ -543,7 +543,7 @@ mod context_tests {
543543 let ctx = Context {
544544 project : Arc :: new ( MockProjectLoader :: complex ( ) ) ,
545545 network : Arc :: new (
546- MockNetworkAccessor :: localhost ( )
546+ MockNetworkAccessor :: new ( )
547547 . with_network (
548548 "local" ,
549549 NetworkAccess {
@@ -588,6 +588,27 @@ mod context_tests {
588588 ) ) ;
589589 }
590590
591+ #[ tokio:: test]
592+ async fn test_get_agent_for_env_network_not_configured ( ) {
593+ // Environment exists in project but its network not configured in MockNetworkAccessor
594+ let ctx = Context {
595+ project : Arc :: new ( MockProjectLoader :: complex ( ) ) ,
596+ // MockNetworkAccessor has no networks configured
597+ ..Context :: mocked ( )
598+ } ;
599+
600+ let result = ctx
601+ . get_agent_for_env ( & IdentitySelection :: Anonymous , "nonexistent" )
602+ . await ;
603+
604+ assert ! ( matches!(
605+ result,
606+ Err ( GetAgentForEnvError :: NetworkAccess {
607+ source: icp:: network:: AccessError :: Unexpected ( _)
608+ } )
609+ ) ) ;
610+ }
611+
591612 #[ tokio:: test]
592613 async fn test_get_agent_for_network_success ( ) {
593614 use icp:: network:: access:: NetworkAccess ;
@@ -596,7 +617,7 @@ mod context_tests {
596617
597618 let ctx = Context {
598619 project : Arc :: new ( MockProjectLoader :: complex ( ) ) ,
599- network : Arc :: new ( MockNetworkAccessor :: localhost ( ) . with_network (
620+ network : Arc :: new ( MockNetworkAccessor :: new ( ) . with_network (
600621 "local" ,
601622 NetworkAccess {
602623 default_effective_canister_id : None ,
@@ -631,6 +652,27 @@ mod context_tests {
631652 ) ) ;
632653 }
633654
655+ #[ tokio:: test]
656+ async fn test_get_agent_for_network_not_configured ( ) {
657+ // Network exists in project but not configured in MockNetworkAccessor
658+ let ctx = Context {
659+ project : Arc :: new ( MockProjectLoader :: complex ( ) ) ,
660+ // MockNetworkAccessor has no networks configured
661+ ..Context :: mocked ( )
662+ } ;
663+
664+ let result = ctx
665+ . get_agent_for_network ( & IdentitySelection :: Anonymous , "nonexistent" )
666+ . await ;
667+
668+ assert ! ( matches!(
669+ result,
670+ Err ( GetAgentForNetworkError :: NetworkAccess {
671+ source: icp:: network:: AccessError :: Unexpected ( _)
672+ } )
673+ ) ) ;
674+ }
675+
634676 #[ tokio:: test]
635677 async fn test_get_agent_for_url_success ( ) {
636678 let ctx = Context :: mocked ( ) ;
0 commit comments