// file: crates/ksp-wallet-lib/tests/dependency_boundary.rs // version: 1 //! Wallet-specific dependency and ownership canaries. fn crate_root() -> std::path::PathBuf { return std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); } fn rust_source_files(directory: &std::path::Path) -> std::vec::Vec { let entries = std::fs::read_dir(directory).expect("Wallet source directory must be readable during integration tests"); let mut files = std::vec::Vec::new(); for entry in entries { let entry = entry.expect("Wallet source directory entry must be readable"); let path = entry.path(); if path.is_dir() { files.extend(rust_source_files(path.as_path())); } else if path.extension() == std::option::Option::Some(std::ffi::OsStr::new("rs")) { files.push(path); } } return files; } #[test] fn wallet_manifest_preserves_dependency_firewall() { let manifest = std::fs::read_to_string(crate_root().join("Cargo.toml")).expect("Wallet manifest must be readable during integration tests"); assert!(manifest.contains("ksp-core-lib")); assert!(manifest.contains("ksp-logging-lib")); assert!(manifest.contains("zeroize.workspace = true")); for forbidden in [ "ksp-config-lib", "ksp-onchain-transport-lib", "ksp-execution-policy-api", "ksp-store-api", "ksp-store-lib", "tauri", "tracing =", "solana-pubkey", ] { assert!(!manifest.contains(forbidden), "forbidden direct Wallet dependency detected: {forbidden}"); } } #[test] fn wallet_sources_use_core_pubkey_logging_facade_and_no_environment() { let source_files = rust_source_files(crate_root().join("src").as_path()); let mut all_source = std::string::String::new(); for source_file in source_files { let source = std::fs::read_to_string(source_file.as_path()).expect("Wallet Rust source must be readable during integration tests"); all_source.push_str(source.as_str()); } assert!(all_source.contains("ksp_core_lib::Pubkey")); assert!(all_source.contains("ksp_logging_lib::trace!")); assert!(all_source.contains("pub(crate) const TRACING_TARGET: &str = \"ksp-wallet-lib\";")); assert!(!all_source.contains("solana_pubkey::")); assert!(!all_source.contains("std::env::")); assert!(!all_source.contains("tracing::")); }