109 lines
3.8 KiB
Rust
109 lines
3.8 KiB
Rust
// file: crates/ksp-store-api/tests/dependency_boundary.rs
|
|
// version: 3
|
|
|
|
//! Dependency canaries for the Store API RAW foundation.
|
|
|
|
#[test]
|
|
fn pre_004_manifest_keeps_exact_core_only_runtime_dependency() {
|
|
let manifest = include_str!("../Cargo.toml");
|
|
let dependencies_tail = manifest.split("[dependencies]").nth(1);
|
|
assert!(dependencies_tail.is_some(), "Store API dependencies section must exist");
|
|
let dependencies_tail = match dependencies_tail {
|
|
std::option::Option::Some(value) => value,
|
|
std::option::Option::None => return,
|
|
};
|
|
let dependencies = match dependencies_tail.split("[lints]").next() {
|
|
std::option::Option::Some(value) => value,
|
|
std::option::Option::None => return,
|
|
};
|
|
assert_eq!(manifest_dependency_names(dependencies), std::vec!["ksp-core-lib"]);
|
|
for forbidden in [
|
|
"ksp-config-lib",
|
|
"ksp-interface-lib",
|
|
"ksp-logging-lib",
|
|
"ksp-materializer-api",
|
|
"ksp-offchain-transport-lib",
|
|
"ksp-onchain-transport-lib",
|
|
"ksp-program-api",
|
|
"ksp-program-lib",
|
|
"ksp-store-lib",
|
|
"ksp-store-postgres-lib",
|
|
"ksp-wallet-lib",
|
|
"async-trait",
|
|
"bincode",
|
|
"chrono",
|
|
"postgres",
|
|
"serde",
|
|
"serde_json",
|
|
"sqlx",
|
|
"tauri",
|
|
"tokio",
|
|
"tokio-postgres",
|
|
"tonic",
|
|
"tracing",
|
|
"wincode",
|
|
] {
|
|
assert!(!dependencies.contains(forbidden), "forbidden Store API dependency detected: {forbidden}");
|
|
}
|
|
return;
|
|
}
|
|
|
|
#[test]
|
|
fn pre_004_source_boundary_keeps_raw_models_passive_and_backend_free() {
|
|
let crate_root = include_str!("../src/lib.rs");
|
|
let model_home = include_str!("../src/model.rs");
|
|
let raw_account = include_str!("../src/model/raw_account.rs");
|
|
let raw_primitives = include_str!("../src/model/raw_primitives.rs");
|
|
let raw_transaction = include_str!("../src/model/raw_transaction.rs");
|
|
assert!(crate_root.contains("mod capability;"));
|
|
assert!(crate_root.contains("mod error;"));
|
|
assert!(crate_root.contains("mod model;"));
|
|
assert!(model_home.contains("raw_account"));
|
|
assert!(model_home.contains("raw_primitives"));
|
|
assert!(model_home.contains("raw_transaction"));
|
|
for source in [crate_root, model_home, raw_account, raw_primitives, raw_transaction] {
|
|
for forbidden in [
|
|
"ksp_store_lib",
|
|
"ksp_store_postgres_lib",
|
|
"ksp_onchain_transport_lib",
|
|
"ksp_program_api",
|
|
"serde::",
|
|
"sqlx::",
|
|
"tokio::",
|
|
"tokio_postgres::",
|
|
"std::env::",
|
|
"std::fs::",
|
|
"std::net::",
|
|
] {
|
|
assert!(!source.contains(forbidden), "forbidden Store API dependency/runtime path detected: {forbidden}");
|
|
}
|
|
}
|
|
assert!(!raw_transaction.contains("RawLog"));
|
|
for forbidden in ["TransactionStatusObservation", "RawLogNotification", "RawSlotEvent", "RawVoteEvent", "RawBlock", "YellowstoneEntry"] {
|
|
assert!(!crate_root.contains(forbidden), "deferred pre.004 model leaked into Store API surface: {forbidden}");
|
|
}
|
|
return;
|
|
}
|
|
|
|
fn manifest_dependency_names(section: &str) -> std::vec::Vec<&str> {
|
|
let mut names = std::vec::Vec::new();
|
|
for line in section.lines() {
|
|
let content = match line.split('#').next() {
|
|
std::option::Option::Some(value) => value.trim(),
|
|
std::option::Option::None => continue,
|
|
};
|
|
if content.is_empty() {
|
|
continue;
|
|
}
|
|
let name = match content.split('=').next() {
|
|
std::option::Option::Some(value) => value.trim().trim_end_matches(".workspace"),
|
|
std::option::Option::None => continue,
|
|
};
|
|
if !name.is_empty() {
|
|
names.push(name);
|
|
}
|
|
}
|
|
names.sort_unstable();
|
|
return names;
|
|
}
|