35 lines
1.5 KiB
Rust
35 lines
1.5 KiB
Rust
// file: crates/ksp-app-wallet-desk/unit_tests/wallet_secrets.rs
|
|
// version: 1
|
|
|
|
#[test]
|
|
fn filename_secret_label_normalization_is_deterministic_and_never_uses_internal_alias() {
|
|
assert_eq!(super::normalize_wallet_secret_label("wallet-01.kspwallet"), "WALLET_01");
|
|
assert_eq!(super::normalize_wallet_secret_label(" treasury.main .kspwallet"), "TREASURY_MAIN");
|
|
assert_eq!(super::normalize_wallet_secret_label("a___b...c.kspwallet"), "A_B_C");
|
|
assert_eq!(super::normalize_wallet_secret_label(".kspwallet"), "");
|
|
}
|
|
|
|
#[test]
|
|
fn candidate_order_prefers_filename_then_numeric_then_named_labels() {
|
|
let mut names = vec![
|
|
format!("{}TREASURY", super::WALLET_SECRET_PREFIX),
|
|
format!("{}10", super::WALLET_SECRET_PREFIX),
|
|
format!("{}WALLET_01", super::WALLET_SECRET_PREFIX),
|
|
format!("{}02", super::WALLET_SECRET_PREFIX),
|
|
format!("{}01", super::WALLET_SECRET_PREFIX),
|
|
format!("{}ALPHA", super::WALLET_SECRET_PREFIX),
|
|
];
|
|
super::order_wallet_secret_candidate_names("wallet-01.kspwallet", names.as_mut_slice());
|
|
assert_eq!(
|
|
names,
|
|
vec![
|
|
format!("{}WALLET_01", super::WALLET_SECRET_PREFIX),
|
|
format!("{}01", super::WALLET_SECRET_PREFIX),
|
|
format!("{}02", super::WALLET_SECRET_PREFIX),
|
|
format!("{}10", super::WALLET_SECRET_PREFIX),
|
|
format!("{}ALPHA", super::WALLET_SECRET_PREFIX),
|
|
format!("{}TREASURY", super::WALLET_SECRET_PREFIX),
|
|
]
|
|
);
|
|
}
|