v0.2.5-pre.002

This commit is contained in:
2026-08-19 09:56:01 +02:00
parent c2ccef3849
commit c97a8739ab
19 changed files with 1037 additions and 27 deletions

View File

@@ -0,0 +1,59 @@
// 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<std::path::PathBuf> {
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::"));
}

View File

@@ -0,0 +1,61 @@
// file: crates/ksp-wallet-lib/tests/public_api.rs
// version: 1
//! Public API canaries for the Wallet foundation.
fn accepts_view_handle(_: std::option::Option<&ksp_wallet_lib::WalletView>) {}
fn accepts_owner_handle(_: std::option::Option<&ksp_wallet_lib::WalletOwner>) {}
#[test]
fn capability_and_handle_types_are_available_from_crate_root() {
assert_eq!(ksp_wallet_lib::WalletCapability::View, ksp_wallet_lib::WalletCapability::View);
assert_ne!(ksp_wallet_lib::WalletCapability::View, ksp_wallet_lib::WalletCapability::Owner);
accepts_view_handle(std::option::Option::None);
accepts_owner_handle(std::option::Option::None);
}
#[test]
fn password_types_redact_public_debug_output() {
let view = ksp_wallet_lib::ViewPassword::new(std::string::String::from("PUBLIC-VIEW-CANARY"));
let owner = ksp_wallet_lib::OwnerPassword::new(std::string::String::from("PUBLIC-OWNER-CANARY"));
let view_debug = format!("{view:?}");
let owner_debug = format!("{owner:?}");
assert!(!view_debug.contains("PUBLIC-VIEW-CANARY"));
assert!(!owner_debug.contains("PUBLIC-OWNER-CANARY"));
assert!(std::mem::needs_drop::<ksp_wallet_lib::ViewPassword>());
assert!(std::mem::needs_drop::<ksp_wallet_lib::OwnerPassword>());
}
#[test]
fn metadata_projection_methods_use_core_pubkey_contract() {
let pubkey_method: fn(&ksp_wallet_lib::WalletInfo) -> &ksp_core_lib::Pubkey = ksp_wallet_lib::WalletInfo::pubkey;
let view_pubkey_method: fn(&ksp_wallet_lib::WalletView) -> &ksp_core_lib::Pubkey = ksp_wallet_lib::WalletView::pubkey;
let owner_pubkey_method: fn(&ksp_wallet_lib::WalletOwner) -> &ksp_core_lib::Pubkey = ksp_wallet_lib::WalletOwner::pubkey;
let _ = pubkey_method;
let _ = view_pubkey_method;
let _ = owner_pubkey_method;
}
#[test]
fn wallet_error_codes_are_available_from_crate_root() {
let codes = [
ksp_wallet_lib::ERROR_CODE_FORMAT_INVALID,
ksp_wallet_lib::ERROR_CODE_FORMAT_VERSION_UNSUPPORTED,
ksp_wallet_lib::ERROR_CODE_CRYPTO_PARAMETERS_INVALID,
ksp_wallet_lib::ERROR_CODE_AUTHENTICATION_FAILED,
ksp_wallet_lib::ERROR_CODE_VIEW_UNLOCK_FAILED,
ksp_wallet_lib::ERROR_CODE_OWNER_UNLOCK_FAILED,
ksp_wallet_lib::ERROR_CODE_CAPABILITY_INSUFFICIENT,
ksp_wallet_lib::ERROR_CODE_IO_FAILED,
ksp_wallet_lib::ERROR_CODE_DESTINATION_EXISTS,
ksp_wallet_lib::ERROR_CODE_ATOMIC_PERSISTENCE_FAILED,
ksp_wallet_lib::ERROR_CODE_TRANSFER_FORMAT_UNSUPPORTED,
ksp_wallet_lib::ERROR_CODE_KEY_MATERIAL_INVALID,
ksp_wallet_lib::ERROR_CODE_SIGNATURE_FAILED,
];
assert_eq!(codes.len(), 13);
for code in codes {
assert_eq!(code.domain(), "wallet");
}
}