// file: crates/ksp-app-raw-transaction-ingest-desk/unit_tests/route_runtime.rs // version: 2 #[test] fn pre_009_multi_route_runtime_starts_without_workers_or_shared_store_material() { let state = crate::RouteRuntimeState::new(); let inner = state.inner.lock(); assert!(inner.is_ok()); if let std::result::Result::Ok(inner) = inner { assert!(inner.routes.is_empty()); assert!(inner.store.is_none()); assert!(inner.network.is_none()); assert!(inner.store_opening_token.is_none()); assert!(inner.store_closing_token.is_none()); } } #[test] fn pre_009_late_targeted_stop_returns_only_the_matching_terminal_route() { let state = crate::RouteRuntimeState::new(); let terminal = crate::RawIngestRouteRuntimeDto { commitment: crate::RawIngestCommitment::Confirmed, inventory_generation: 9, network: "mainnet".to_owned(), profile_id: "mainnet".to_owned(), route_id: crate::RawIngestRouteId::YellowstoneHydrated, state: crate::RawIngestRouteState::Faulted, }; let inner = state.inner.lock(); assert!(inner.is_ok()); if let std::result::Result::Ok(mut inner) = inner { inner.last_terminals.push(terminal.clone()); } let request = crate::RawIngestRouteStopRequestDto { profile_id: "mainnet".to_owned(), route_id: crate::RawIngestRouteId::YellowstoneHydrated }; let target = state.stop_target(&request); assert!(target.is_ok()); assert!(matches!(&target, std::result::Result::Ok(super::RouteStopTarget::Terminal(_)))); if let std::result::Result::Ok(super::RouteStopTarget::Terminal(value)) = target { assert_eq!(value.profile_id, terminal.profile_id); assert_eq!(value.route_id, terminal.route_id); assert_eq!(value.state, crate::RawIngestRouteState::Faulted); } } #[test] fn pre_009_late_targeted_stop_waits_while_final_shared_store_is_closing() { let state = crate::RouteRuntimeState::new(); let inner = state.inner.lock(); assert!(inner.is_ok()); if let std::result::Result::Ok(mut inner) = inner { inner.last_terminals.push(crate::RawIngestRouteRuntimeDto { commitment: crate::RawIngestCommitment::Finalized, inventory_generation: 11, network: "mainnet".to_owned(), profile_id: "mainnet".to_owned(), route_id: crate::RawIngestRouteId::HttpBlockPolling, state: crate::RawIngestRouteState::Stopped, }); inner.store_closing_token = std::option::Option::Some(77); } let request = crate::RawIngestRouteStopRequestDto { profile_id: "mainnet".to_owned(), route_id: crate::RawIngestRouteId::HttpBlockPolling }; let target = state.stop_target(&request); assert!(matches!(target, std::result::Result::Ok(super::RouteStopTarget::TerminalClosing))); }