v0.5.2-pre.007
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: ks-wallet/tests/legacy_characterization.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! External characterization tests for the legacy Solana JSON wallet format.
|
||||
|
||||
@@ -69,6 +69,31 @@ async fn legacy_missing_file_preserves_current_error_contract() {
|
||||
assert_eq!(error.code(), "wallet_file_metadata_failed");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn legacy_errors_and_debug_do_not_disclose_local_path() {
|
||||
let directory = tempfile::tempdir()
|
||||
.unwrap_or_else(|error| panic!("temporary directory must exist: {error}"));
|
||||
let canary_directory = directory.path().join("wallet-path-canary");
|
||||
std::fs::create_dir_all(&canary_directory)
|
||||
.unwrap_or_else(|error| panic!("canary directory must be created: {error}"));
|
||||
let store = ks_wallet::TemporaryWalletStore::new(&canary_directory)
|
||||
.unwrap_or_else(|error| panic!("unexpected store error: {error}"));
|
||||
let debug = format!("{store:?}");
|
||||
assert!(!debug.contains("wallet-path-canary"));
|
||||
assert!(!debug.contains(canary_directory.to_string_lossy().as_ref()));
|
||||
let alias = ks_wallet::WalletAlias::parse("missing-canary")
|
||||
.unwrap_or_else(|error| panic!("unexpected alias error: {error}"));
|
||||
let error = store
|
||||
.load(alias)
|
||||
.await
|
||||
.err()
|
||||
.unwrap_or_else(|| panic!("missing legacy wallet must fail"));
|
||||
let message = error.to_string();
|
||||
assert_eq!(error.code(), "wallet_file_metadata_failed");
|
||||
assert!(!message.contains("wallet-path-canary"));
|
||||
assert!(!message.contains(canary_directory.to_string_lossy().as_ref()));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn legacy_corrupted_json_and_short_keypair_are_distinct() {
|
||||
let directory = tempfile::tempdir()
|
||||
|
||||
Reference in New Issue
Block a user