v0.2.5-pre.002-fix.002

This commit is contained in:
2026-08-19 10:08:47 +02:00
parent 51b5114ae2
commit bcda6db11f
3 changed files with 166 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-wallet-lib/tests/dependency_boundary.rs
// version: 1
// version: 2
//! Wallet-specific dependency and ownership canaries.
@@ -7,24 +7,37 @@ 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<std::path::PathBuf> {
let entries = std::fs::read_dir(directory).expect("Wallet source directory must be readable during integration tests");
fn rust_source_files(directory: &std::path::Path) -> std::io::Result<std::vec::Vec<std::path::PathBuf>> {
let entries = match std::fs::read_dir(directory) {
std::result::Result::Ok(entries) => entries,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
let mut files = std::vec::Vec::new();
for entry in entries {
let entry = entry.expect("Wallet source directory entry must be readable");
let entry = match entry {
std::result::Result::Ok(entry) => entry,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
let path = entry.path();
if path.is_dir() {
files.extend(rust_source_files(path.as_path()));
let nested_files = match rust_source_files(path.as_path()) {
std::result::Result::Ok(nested_files) => nested_files,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
files.extend(nested_files);
} else if path.extension() == std::option::Option::Some(std::ffi::OsStr::new("rs")) {
files.push(path);
}
}
return files;
return std::result::Result::Ok(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");
fn wallet_manifest_preserves_dependency_firewall() -> std::io::Result<()> {
let manifest = match std::fs::read_to_string(crate_root().join("Cargo.toml")) {
std::result::Result::Ok(manifest) => manifest,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
assert!(manifest.contains("ksp-core-lib"));
assert!(manifest.contains("ksp-logging-lib"));
assert!(manifest.contains("zeroize.workspace = true"));
@@ -40,14 +53,21 @@ fn wallet_manifest_preserves_dependency_firewall() {
] {
assert!(!manifest.contains(forbidden), "forbidden direct Wallet dependency detected: {forbidden}");
}
return std::result::Result::Ok(());
}
#[test]
fn wallet_sources_use_core_pubkey_logging_facade_and_no_environment() {
let source_files = rust_source_files(crate_root().join("src").as_path());
fn wallet_sources_use_core_pubkey_logging_facade_and_no_environment() -> std::io::Result<()> {
let source_files = match rust_source_files(crate_root().join("src").as_path()) {
std::result::Result::Ok(source_files) => source_files,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
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");
let source = match std::fs::read_to_string(source_file.as_path()) {
std::result::Result::Ok(source) => source,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
all_source.push_str(source.as_str());
}
assert!(all_source.contains("ksp_core_lib::Pubkey"));
@@ -56,4 +76,5 @@ fn wallet_sources_use_core_pubkey_logging_facade_and_no_environment() {
assert!(!all_source.contains("solana_pubkey::"));
assert!(!all_source.contains("std::env::"));
assert!(!all_source.contains("tracing::"));
return std::result::Result::Ok(());
}