Files
khadhroony-solana-project/crates/ksp-app-raw-transaction-ingest-desk/tests/dependency_boundary.rs
2026-09-13 09:57:39 +02:00

71 lines
2.4 KiB
Rust

// file: crates/ksp-app-raw-transaction-ingest-desk/tests/dependency_boundary.rs
// version: 1
//! Dependency-boundary canaries for the Raw Transaction Ingest Desk scaffold.
#![forbid(unsafe_code)]
#![deny(unreachable_pub)]
#![warn(missing_docs)]
fn app_root() -> std::path::PathBuf {
return std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
}
fn read_text(path: &std::path::Path) -> String {
let source = std::fs::read_to_string(path);
assert!(source.is_ok(), "unable to read {}", path.display());
return match source {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => String::new(),
};
}
#[test]
fn pre_005_manifest_is_scaffold_only_and_backend_neutral() {
let manifest = read_text(app_root().join("Cargo.toml").as_path());
for required in ["ksp-config-lib", "ksp-core-lib", "ksp-logging-lib", "tauri-plugin-tracing"] {
assert!(manifest.contains(required), "missing scaffold dependency {required}");
}
for forbidden in [
"ksp-onchain-transport-lib",
"ksp-store-lib",
"ksp-store-api",
"ksp-store-postgres-lib",
"ksp-worker-api",
"ksp-worker-raw-transaction-ingest-lib",
"ksp-job-backfill-lib",
"reqwest",
"tokio-postgres",
"tonic",
"yellowstone-grpc",
] {
assert!(!manifest.contains(forbidden), "scaffold opens forbidden dependency {forbidden}");
}
}
#[test]
fn pre_005_production_sources_do_not_construct_transport_store_or_worker_runtime() {
let root = app_root().join("src");
let entries = std::fs::read_dir(root.as_path());
assert!(entries.is_ok());
if let std::result::Result::Ok(entries) = entries {
for entry in entries.flatten() {
let path = entry.path();
if path.extension().and_then(std::ffi::OsStr::to_str) != std::option::Option::Some("rs") {
continue;
}
let source = read_text(path.as_path());
for forbidden in [
"HttpTransportPool",
"WsTransportSettings",
"YellowstoneGrpcChannel",
"ksp_store_lib::Store",
"RawTransactionIngestWorker",
"RawTransactionIngestRuntimeResources",
] {
assert!(!source.contains(forbidden), "{} contains premature runtime marker {forbidden}", path.display());
}
}
}
}