v0.5.2-pre.006-fix-004
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: ks-wallet/tests/transfer.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! External migration and secret import/export contract tests.
|
||||
|
||||
@@ -277,3 +277,42 @@ async fn import_rejects_invalid_sources_without_creating_native_destination() {
|
||||
assert_eq!(base58_error.code(), "wallet_import_base58_invalid");
|
||||
assert!(!directory.path().join("invalid-base58.kswallet").exists());
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn transfer_inspection_exposes_only_public_identity_for_supported_formats() {
|
||||
let directory = tempfile::tempdir()
|
||||
.unwrap_or_else(|error| panic!("temporary directory must exist: {error}"));
|
||||
make_directory_private(directory.path());
|
||||
let keypair = solana_keypair::Keypair::new();
|
||||
let expected_public_key = keypair.pubkey().to_string();
|
||||
let mut keypair_bytes = keypair.to_bytes();
|
||||
let mut json = serde_json::to_vec(keypair_bytes.as_slice())
|
||||
.unwrap_or_else(|error| panic!("Solana JSON fixture must encode: {error}"));
|
||||
let json_path = directory.path().join("inspect.json");
|
||||
write_private_file(&json_path, json.as_slice());
|
||||
let json_inspection = ks_wallet::inspect_transfer_file(
|
||||
&json_path,
|
||||
ks_wallet::WalletTransferFormat::SolanaCliJson,
|
||||
)
|
||||
.await
|
||||
.unwrap_or_else(|error| panic!("Solana JSON inspection must succeed: {error}"));
|
||||
assert_eq!(json_inspection.public_key(), expected_public_key);
|
||||
assert_eq!(json_inspection.format().code(), "solana_cli_json");
|
||||
json.zeroize();
|
||||
let mut base58 = bs58::encode(keypair_bytes.as_slice()).into_string();
|
||||
let base58_path = directory.path().join("inspect.txt");
|
||||
write_private_file(&base58_path, base58.as_bytes());
|
||||
let base58_inspection = ks_wallet::inspect_transfer_file(
|
||||
&base58_path,
|
||||
ks_wallet::WalletTransferFormat::SolanaPrivateKeyBase58,
|
||||
)
|
||||
.await
|
||||
.unwrap_or_else(|error| panic!("Base58 inspection must succeed: {error}"));
|
||||
assert_eq!(base58_inspection.public_key(), expected_public_key);
|
||||
assert_eq!(base58_inspection.format().code(), "solana_private_key_base58");
|
||||
let formats = ks_wallet::WalletTransferFormat::supported();
|
||||
assert_eq!(formats.len(), 2);
|
||||
assert_eq!(formats[0].default_extension(), "json");
|
||||
assert_eq!(formats[1].default_extension(), "txt");
|
||||
base58.zeroize();
|
||||
keypair_bytes.zeroize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user