0.3.15-pre.012
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-raw-transaction-ingest-desk/unit_tests/route_runtime.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
#[test]
|
||||
fn pre_009_multi_route_runtime_starts_without_workers_or_shared_store_material() {
|
||||
@@ -63,3 +63,70 @@ fn pre_009_late_targeted_stop_waits_while_final_shared_store_is_closing() {
|
||||
let target = state.stop_target(&request);
|
||||
assert!(matches!(target, std::result::Result::Ok(super::RouteStopTarget::TerminalClosing)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_012_stop_racing_start_marks_the_reservation_for_cooperative_stop() {
|
||||
let state = crate::RouteRuntimeState::new();
|
||||
let identity = super::RouteRuntimeIdentity {
|
||||
commitment: crate::RawIngestCommitment::Confirmed,
|
||||
inventory_generation: 12,
|
||||
network: "mainnet".to_owned(),
|
||||
profile_id: "mainnet".to_owned(),
|
||||
route_id: crate::RawIngestRouteId::YellowstoneHydrated,
|
||||
};
|
||||
let inner = state.inner.lock();
|
||||
assert!(inner.is_ok());
|
||||
if let std::result::Result::Ok(mut inner) = inner {
|
||||
inner.network = std::option::Option::Some("mainnet".to_owned());
|
||||
inner.routes.push(super::RouteRuntimeSlot::Starting { identity: identity.clone(), stop_requested: false, token: 12 });
|
||||
}
|
||||
let request = crate::RawIngestRouteStopRequestDto { profile_id: "mainnet".to_owned(), route_id: crate::RawIngestRouteId::YellowstoneHydrated };
|
||||
let target = state.stop_target(&request);
|
||||
assert!(matches!(target, std::result::Result::Ok(super::RouteStopTarget::Starting { token: 12, .. })));
|
||||
let inner = state.inner.lock();
|
||||
assert!(inner.is_ok());
|
||||
if let std::result::Result::Ok(inner) = inner {
|
||||
assert!(matches!(inner.routes.first(), std::option::Option::Some(super::RouteRuntimeSlot::Starting { stop_requested: true, .. })));
|
||||
}
|
||||
let rollback = state.rollback(12);
|
||||
assert!(matches!(rollback, std::result::Result::Ok(std::option::Option::None)));
|
||||
let inner = state.inner.lock();
|
||||
assert!(inner.is_ok());
|
||||
if let std::result::Result::Ok(inner) = inner {
|
||||
assert!(inner.routes.is_empty());
|
||||
assert!(matches!(inner.last_terminals.first(), std::option::Option::Some(value) if value.state == crate::RawIngestRouteState::Stopped));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_012_application_shutdown_is_one_shot_and_marks_starting_routes_before_activation() {
|
||||
let state = crate::RouteRuntimeState::new();
|
||||
let identity = super::RouteRuntimeIdentity {
|
||||
commitment: crate::RawIngestCommitment::Finalized,
|
||||
inventory_generation: 13,
|
||||
network: "mainnet".to_owned(),
|
||||
profile_id: "mainnet".to_owned(),
|
||||
route_id: crate::RawIngestRouteId::HttpBlockPolling,
|
||||
};
|
||||
let inner = state.inner.lock();
|
||||
assert!(inner.is_ok());
|
||||
if let std::result::Result::Ok(mut inner) = inner {
|
||||
inner.network = std::option::Option::Some("mainnet".to_owned());
|
||||
inner.routes.push(super::RouteRuntimeSlot::Starting { identity, stop_requested: false, token: 13 });
|
||||
}
|
||||
let first = state.begin_shutdown();
|
||||
assert!(matches!(first, std::result::Result::Ok(true)));
|
||||
let second = state.begin_shutdown();
|
||||
assert!(matches!(second, std::result::Result::Ok(false)));
|
||||
let admission = state.ensure_start_admission_open();
|
||||
assert!(admission.is_err());
|
||||
if let std::result::Result::Err(error) = admission {
|
||||
assert_eq!(error.code(), crate::ERROR_CODE_ROUTE_RUNTIME_SHUTTING_DOWN);
|
||||
}
|
||||
let inner = state.inner.lock();
|
||||
assert!(inner.is_ok());
|
||||
if let std::result::Result::Ok(inner) = inner {
|
||||
assert!(inner.shutting_down);
|
||||
assert!(matches!(inner.routes.first(), std::option::Option::Some(super::RouteRuntimeSlot::Starting { stop_requested: true, .. })));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user