94 lines
4.4 KiB
Rust
94 lines
4.4 KiB
Rust
// file: crates/ksp-job-backfill-lib/tests/dependency_boundary.rs
|
|
// version: 6
|
|
|
|
//! Dependency firewall canaries through the concrete cancellation and latest-value runtime tranche.
|
|
|
|
#[test]
|
|
fn pre_009_manifest_uses_only_planned_ksp_edges_and_private_tokio_runtime() {
|
|
let manifest = include_str!("../Cargo.toml");
|
|
for required in [
|
|
"futures-util = { workspace = true, features = [\"std\"] }",
|
|
"ksp-core-lib = { path = \"../ksp-core-lib\" }",
|
|
"ksp-job-api = { path = \"../ksp-job-api\" }",
|
|
"ksp-logging-lib = { path = \"../ksp-logging-lib\" }",
|
|
"ksp-onchain-transport-lib = { path = \"../ksp-onchain-transport-lib\" }",
|
|
"ksp-store-lib = { path = \"../ksp-store-lib\", default-features = false }",
|
|
"serde_json.workspace = true",
|
|
"sha2.workspace = true",
|
|
"tokio = { workspace = true, features = [\"macros\", \"sync\"] }",
|
|
] {
|
|
assert!(manifest.contains(required), "required Backfill dependency missing: {required}");
|
|
}
|
|
for forbidden in [
|
|
"ksp-config-lib",
|
|
"ksp-interface-lib",
|
|
"ksp-program-api",
|
|
"ksp-store-api",
|
|
"ksp-store-postgres-lib",
|
|
"ksp-wallet-lib",
|
|
"solana-",
|
|
"reqwest",
|
|
"serde.workspace = true",
|
|
"serde = {",
|
|
"tonic",
|
|
] {
|
|
assert!(!manifest.contains(forbidden), "forbidden Backfill dependency present: {forbidden}");
|
|
}
|
|
let root = include_str!("../src/lib.rs");
|
|
assert!(!root.contains("tokio::"), "Tokio implementation types must not leak through the public crate root");
|
|
return;
|
|
}
|
|
|
|
#[test]
|
|
fn pre_009_production_sources_keep_transport_store_and_scheduler_ownership_separate() {
|
|
let neutral_sources = [
|
|
include_str!("../src/checkpoint.rs"),
|
|
include_str!("../src/constants.rs"),
|
|
include_str!("../src/discovery.rs"),
|
|
include_str!("../src/error.rs"),
|
|
include_str!("../src/lib.rs"),
|
|
include_str!("../src/request.rs"),
|
|
include_str!("../src/runtime.rs"),
|
|
];
|
|
for source in neutral_sources {
|
|
for forbidden in ["ksp_config_lib::", "ksp_interface_lib::", "ksp_store_api::", "ksp_store_postgres_lib::", "reqwest::", "std::env", "tonic::"] {
|
|
assert!(!source.contains(forbidden), "forbidden concrete Backfill path detected: {forbidden}");
|
|
}
|
|
}
|
|
let conversion = include_str!("../src/conversion.rs");
|
|
assert!(conversion.contains("serde_json::"));
|
|
assert!(conversion.contains("get_transaction_observed"));
|
|
assert!(conversion.contains("SolanaTransactionEncoding::Base64"));
|
|
assert!(conversion.contains("std::option::Option::Some(0)"));
|
|
assert!(conversion.contains("BackfillHydrationOutcome::Missing(reference)"));
|
|
assert!(!conversion.contains("execute_standard_rpc"));
|
|
assert!(!conversion.contains("persist_raw_transaction_acquisition"));
|
|
let persistence = include_str!("../src/persistence.rs");
|
|
assert!(persistence.contains("persist_raw_transaction_acquisition"));
|
|
assert!(persistence.contains("RawTransactionAcquisitionMode::Normal"));
|
|
assert!(persistence.contains("ERROR_CODE_RAW_CONFLICT"));
|
|
assert!(!persistence.contains("record_raw_transaction_observation"));
|
|
assert!(!persistence.contains("RawTransactionAcquisitionMode::ForceRehydrate"));
|
|
let discovery = include_str!("../src/discovery.rs");
|
|
assert!(discovery.contains("get_signatures_for_address"));
|
|
assert!(!discovery.contains("execute_standard_rpc"));
|
|
assert!(!discovery.contains("retry"));
|
|
assert!(!discovery.contains("endpoint_name"));
|
|
let execution = include_str!("../src/execution.rs");
|
|
assert!(execution.contains("FuturesUnordered"));
|
|
assert!(execution.contains("hydrate_backfill_candidate"));
|
|
assert!(execution.contains("persist_backfill_hydration"));
|
|
assert!(execution.contains("request.hydration_concurrency()"));
|
|
for forbidden in ["tokio::spawn", "tokio::time", "retry", "endpoint_name", "provider()", "ForceRehydrate", "get_raw_transaction"] {
|
|
assert!(!execution.contains(forbidden), "forbidden scheduler/policy ownership detected: {forbidden}");
|
|
}
|
|
let runtime = include_str!("../src/runtime.rs");
|
|
assert!(runtime.contains("tokio::sync::watch"));
|
|
assert!(runtime.contains("JobSnapshotSource"));
|
|
assert!(runtime.contains("JobCancellationToken"));
|
|
assert!(!runtime.contains("tokio::spawn"));
|
|
assert!(!runtime.contains("tokio::time"));
|
|
assert!(!runtime.contains("reqwest::"));
|
|
return;
|
|
}
|