// file: crates/ksp-wallet-lib/unit_tests/metadata.rs // version: 2 fn test_pubkey() -> ksp_core_lib::Pubkey { return ksp_core_lib::PRGIDPK_SOLANA_SYSTEM; } #[test] fn authorized_info_exposes_metadata_after_authorization() { let note = crate::WalletNote { id: std::string::String::from("purpose"), text: std::string::String::from("devnet test wallet") }; let info = crate::WalletInfo { format_version: 1, capability: crate::WalletCapability::View, pubkey: test_pubkey(), alias: std::option::Option::Some(std::string::String::from("devnet-owner")), notes: std::vec![note], }; assert_eq!(info.format_version(), 1); assert_eq!(info.capability(), crate::WalletCapability::View); assert_eq!(info.pubkey(), &test_pubkey()); assert_eq!(info.alias(), std::option::Option::Some("devnet-owner")); assert_eq!(info.notes()[0].id(), "purpose"); assert_eq!(info.notes()[0].text(), "devnet test wallet"); } #[test] fn authorized_info_debug_redacts_alias_and_note_text() { let note = crate::WalletNote { id: std::string::String::from("NOTE-ID-CANARY"), text: std::string::String::from("NOTE-SECRET-CANARY"), }; let info = crate::WalletInfo { format_version: 1, capability: crate::WalletCapability::Owner, pubkey: test_pubkey(), alias: std::option::Option::Some(std::string::String::from("ALIAS-SECRET-CANARY")), notes: std::vec![note], }; let rendered = format!("{info:?}"); assert!(rendered.contains("")); assert!(rendered.contains("note_count")); assert!(!rendered.contains("ALIAS-SECRET-CANARY")); assert!(!rendered.contains("NOTE-ID-CANARY")); assert!(!rendered.contains("NOTE-SECRET-CANARY")); } #[test] fn locked_info_does_not_carry_authorized_identity_or_metadata() { let info = crate::LockedWalletInfo { format_version: 1, view_enabled: true }; assert_eq!(info.format_version(), 1); assert!(info.view_enabled()); let rendered = format!("{info:?}"); assert!(!rendered.contains("Pubkey")); assert!(!rendered.contains("alias")); assert!(!rendered.contains("notes")); }