v0.3.13-pre.011
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// file: crates/ksp-worker-raw-transaction-ingest-lib/tests/hardening.rs
|
||||
// version: 22
|
||||
// version: 23
|
||||
|
||||
//! External public, security, redaction and release-boundary hardening canaries for `pre.010`.
|
||||
//! External public, security, redaction and release-boundary hardening canaries through `pre.011`.
|
||||
|
||||
fn network(value: &'static str) -> std::option::Option<ksp_store_lib::RawNetworkId> {
|
||||
let result = ksp_store_lib::RawNetworkId::new(value);
|
||||
@@ -854,3 +854,81 @@ fn v0_3_13_pre_010_multi_source_health_is_conservative_counted_and_redacted() {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_13_pre_011_shutdown_races_are_bounded_joined_atomic_and_counter_safe() {
|
||||
let runtime = include_str!("../src/runtime.rs");
|
||||
let resources = include_str!("../src/runtime_resources.rs");
|
||||
let supervisor = match runtime.split_once("async fn run_supervisor<Spawner>(") {
|
||||
std::option::Option::Some((_, tail)) => match tail.split_once("fn spawn_persistence(") {
|
||||
std::option::Option::Some((value, _)) => value,
|
||||
std::option::Option::None => "",
|
||||
},
|
||||
std::option::Option::None => "",
|
||||
};
|
||||
let active_shutdown = match supervisor.split_once("let mut fault = supervise_until_stop(") {
|
||||
std::option::Option::Some((_, value)) => value,
|
||||
std::option::Option::None => "",
|
||||
};
|
||||
let stop_position = active_shutdown.find("source_stop_sender.send_replace(true);");
|
||||
let stopping_position = active_shutdown.find("begin_stopping(");
|
||||
let drain_position = active_shutdown.find("drain_owned_work(");
|
||||
let terminal_position = active_shutdown.find("match fault {");
|
||||
assert!(matches!((stop_position, stopping_position), (std::option::Option::Some(stop), std::option::Option::Some(stopping)) if stop < stopping));
|
||||
assert!(matches!((stopping_position, drain_position), (std::option::Option::Some(stopping), std::option::Option::Some(drain)) if stopping < drain));
|
||||
assert!(matches!((drain_position, terminal_position), (std::option::Option::Some(drain), std::option::Option::Some(terminal)) if drain < terminal));
|
||||
for required in [
|
||||
"tokio::time::timeout(settings.shutdown_drain_timeout(), drain).await",
|
||||
"persistence.abort_all()",
|
||||
"children.abort_all()",
|
||||
"while persistence.join_next().await.is_some() {}",
|
||||
"while children.join_next().await.is_some() {}",
|
||||
] {
|
||||
assert!(runtime.contains(required), "required pre.011 bounded-drain guard missing: {required}");
|
||||
}
|
||||
let registry_publish = match resources.split_once("fn publish_and_remove(&self, key: &RawTransactionIngestHydrationKey") {
|
||||
std::option::Option::Some((_, tail)) => match tail.split_once("type RawTransactionIngestHydrationTasks") {
|
||||
std::option::Option::Some((value, _)) => value,
|
||||
std::option::Option::None => "",
|
||||
},
|
||||
std::option::Option::None => "",
|
||||
};
|
||||
let notify_position = registry_publish.find("sender.send_replace(std::option::Option::Some(result));");
|
||||
let remove_position = registry_publish.find("pending.remove(key);");
|
||||
assert!(matches!((notify_position, remove_position), (std::option::Option::Some(notify), std::option::Option::Some(remove)) if notify < remove));
|
||||
let inventory = match resources.split_once("impl RawTransactionIngestSourceInventory {") {
|
||||
std::option::Option::Some((_, tail)) => match tail.split_once("impl RawTransactionIngestSourceInventoryPublisher") {
|
||||
std::option::Option::Some((value, _)) => value,
|
||||
std::option::Option::None => "",
|
||||
},
|
||||
std::option::Option::None => "",
|
||||
};
|
||||
for required in [
|
||||
"checked_add(projection.hydration_pending())",
|
||||
"checked_add(projection.source_continuity_gap_total())",
|
||||
"checked_add(projection.source_reconnect_total())",
|
||||
"checked_add(projection.source_replay_attempt_total())",
|
||||
"source.inventory_entry_missing",
|
||||
"source.inventory_key_mismatch",
|
||||
"source.inventory_projection_missing",
|
||||
] {
|
||||
assert!(inventory.contains(required), "required pre.011 inventory guard missing: {required}");
|
||||
}
|
||||
assert!(!inventory.contains("saturating_add"), "pre.011 source inventory must not silently saturate aggregate counters");
|
||||
for source_marker in [
|
||||
"impl crate::RawTransactionIngestYellowstoneSource",
|
||||
"impl crate::RawTransactionIngestHeliusTransactionSource",
|
||||
"impl crate::RawTransactionIngestHttpBlockPollingSource",
|
||||
"impl crate::RawTransactionIngestStandardBlockSource",
|
||||
"impl crate::RawTransactionIngestStandardLogsSource",
|
||||
] {
|
||||
let tail = match resources.split_once(source_marker) {
|
||||
std::option::Option::Some((_, value)) => value,
|
||||
std::option::Option::None => "",
|
||||
};
|
||||
assert!(tail.contains("stop_receiver.changed()"), "pre.011 source lacks stop-preemptible wait: {source_marker}");
|
||||
}
|
||||
assert!(!runtime.contains("unbounded_channel"));
|
||||
assert!(!resources.contains("unbounded_channel"));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user