Files
khadhroony-solana-project/crates/ksp-onchain-transport-lib/tests/dependency_boundary.rs

45 lines
2.5 KiB
Rust

// file: crates/ksp-onchain-transport-lib/tests/dependency_boundary.rs
// version: 4
//! Integration canary for the direct dependency firewall of `ksp-onchain-transport-lib`.
#[test]
fn transport_manifest_preserves_ksp_dependency_firewall() {
let manifest_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml");
let manifest = std::fs::read_to_string(manifest_path).expect("transport manifest must be readable during integration tests");
for forbidden in ["ksp-config-lib", "ksp-store-api", "ksp-store-lib", "ksp-program-api", "ksp-program-lib", "tracing =", "tracing."] {
assert!(!manifest.contains(forbidden), "forbidden direct transport dependency detected: {forbidden}");
}
assert!(manifest.contains("ksp-core-lib"));
assert!(manifest.contains("ksp-logging-lib"));
assert!(manifest.contains("reqwest = { workspace = true, features = [\"rustls\"] }"));
assert!(manifest.contains("tokio = { workspace = true, features = [\"macros\", \"sync\", \"time\"] }"));
assert!(manifest.contains("[dev-dependencies]"));
assert!(manifest.contains("tokio = { workspace = true, features = [\"rt\"] }"));
}
#[test]
fn workspace_dependency_table_does_not_activate_consumer_features() {
let manifest_directory = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let workspace_root = manifest_directory.parent().and_then(std::path::Path::parent);
assert!(workspace_root.is_some(), "transport crate must have a workspace root");
let workspace_root = match workspace_root {
std::option::Option::Some(value) => value,
std::option::Option::None => return,
};
let manifest_path = workspace_root.join("Cargo.toml");
let manifest = std::fs::read_to_string(manifest_path.as_path());
assert!(manifest.is_ok(), "workspace manifest must be readable during integration tests");
let manifest = match manifest {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => return,
};
let workspace_dependencies = manifest.split("[workspace.dependencies]").nth(1).and_then(|tail| tail.split("[workspace.lints.rust]").next());
assert!(workspace_dependencies.is_some(), "workspace dependencies section must exist");
let workspace_dependencies = match workspace_dependencies {
std::option::Option::Some(value) => value,
std::option::Option::None => return,
};
assert!(!workspace_dependencies.contains("features ="), "consumer feature activation must stay in member manifests");
}