v0.2.5-pre.010.fix.001
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// file: crates/ksp-wallet-lib/unit_tests/transfer.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt; // rust-rules: derive-import
|
||||
use zeroize::Zeroize; // rust-rules: derive-import
|
||||
use std::os::unix::fs::PermissionsExt; // rust-rules: trait-import
|
||||
use zeroize::Zeroize; // rust-rules: trait-import
|
||||
|
||||
fn runtime() -> tokio::runtime::Runtime {
|
||||
return tokio::runtime::Builder::new_current_thread().build().expect("Wallet transfer test runtime must build");
|
||||
@@ -41,7 +41,6 @@ fn in_memory_inspection_accepts_cli_json_and_canonical_base58_without_exposing_s
|
||||
crate::inspect_wallet_transfer(json.as_slice(), crate::WalletTransferFormat::SolanaCliJson).expect("Solana CLI JSON inspection must succeed");
|
||||
let base58_inspection =
|
||||
crate::inspect_wallet_transfer(base58.as_bytes(), crate::WalletTransferFormat::SolanaKeypairBase58).expect("canonical Base58 inspection must succeed");
|
||||
|
||||
assert_eq!(json_inspection.pubkey(), base58_inspection.pubkey());
|
||||
assert_eq!(json_inspection.format(), crate::WalletTransferFormat::SolanaCliJson);
|
||||
assert_eq!(base58_inspection.format(), crate::WalletTransferFormat::SolanaKeypairBase58);
|
||||
@@ -63,7 +62,6 @@ fn external_seed7_transfer_canary_matches_known_solana_keypair_encodings() {
|
||||
assert_eq!(actual_keypair_bytes, expected_keypair_bytes);
|
||||
let mut actual_base58 = keypair.to_base58_string();
|
||||
assert_eq!(actual_base58, expected_base58);
|
||||
|
||||
let mut json = serde_json::to_vec(expected_keypair_bytes.as_slice()).expect("external keypair canary must encode as JSON");
|
||||
let json_inspection =
|
||||
crate::inspect_wallet_transfer(json.as_slice(), crate::WalletTransferFormat::SolanaCliJson).expect("external Solana CLI JSON canary must inspect");
|
||||
@@ -71,7 +69,6 @@ fn external_seed7_transfer_canary_matches_known_solana_keypair_encodings() {
|
||||
.expect("external Base58 canary must inspect");
|
||||
assert_eq!(json_inspection.pubkey().to_string(), expected_pubkey);
|
||||
assert_eq!(base58_inspection.pubkey().to_string(), expected_pubkey);
|
||||
|
||||
json.zeroize();
|
||||
actual_base58.zeroize();
|
||||
actual_keypair_bytes.zeroize();
|
||||
@@ -84,7 +81,6 @@ fn transfer_decoders_reject_short_inconsistent_or_noncanonical_sources() {
|
||||
crate::inspect_wallet_transfer(short_json, crate::WalletTransferFormat::SolanaCliJson).expect_err("short Solana CLI JSON must fail").code(),
|
||||
crate::ERROR_CODE_KEY_MATERIAL_INVALID
|
||||
);
|
||||
|
||||
let keypair = test_keypair();
|
||||
let mut bytes = keypair.to_bytes();
|
||||
bytes[63] ^= 0x01;
|
||||
@@ -97,7 +93,6 @@ fn transfer_decoders_reject_short_inconsistent_or_noncanonical_sources() {
|
||||
);
|
||||
bytes.zeroize();
|
||||
inconsistent_json.zeroize();
|
||||
|
||||
assert_eq!(
|
||||
crate::inspect_wallet_transfer(b"not valid base58 !!!", crate::WalletTransferFormat::SolanaKeypairBase58)
|
||||
.expect_err("invalid Base58 must fail")
|
||||
@@ -136,7 +131,6 @@ fn cli_json_import_creates_new_no_clobber_wallet_with_imported_identity_and_meta
|
||||
.expect("Solana CLI JSON import must succeed");
|
||||
assert_eq!(owner.pubkey(), expected.pubkey());
|
||||
assert_eq!(owner.alias(), std::option::Option::Some("imported-wallet"));
|
||||
|
||||
let second_password = crate::OwnerPassword::new(std::string::String::from("pre008-second-owner-password"));
|
||||
let second = runtime.block_on(crate::import_wallet_transfer_v1(
|
||||
destination.as_path(),
|
||||
@@ -172,7 +166,6 @@ fn transfer_file_import_is_non_destructive_and_bounded() {
|
||||
))
|
||||
.expect("transfer-file import must succeed");
|
||||
assert_eq!(std::fs::read(source_path.as_path()).expect("source must survive import"), original);
|
||||
|
||||
let oversized_path = directory.path().join("oversized.json");
|
||||
std::fs::write(oversized_path.as_path(), std::vec![b'1'; crate::KSPWALLET_TRANSFER_MAX_SOLANA_CLI_JSON_BYTES + 1])
|
||||
.expect("oversized transfer fixture must be writable");
|
||||
@@ -202,13 +195,11 @@ fn owner_exports_cli_json_and_base58_that_roundtrip_to_the_same_imported_keypair
|
||||
crate::WalletCreateMetadataV1::default(),
|
||||
))
|
||||
.expect("Base58 import must succeed");
|
||||
|
||||
let mut exported_json = owner.export_transfer(crate::WalletTransferFormat::SolanaCliJson).expect("OWNER JSON export must succeed");
|
||||
let mut decoded_json: std::vec::Vec<u8> = serde_json::from_slice(exported_json.as_slice()).expect("OWNER JSON export must be valid JSON");
|
||||
assert_eq!(decoded_json.as_slice(), expected_bytes.as_slice());
|
||||
let mut exported_base58 = owner.export_transfer(crate::WalletTransferFormat::SolanaKeypairBase58).expect("OWNER Base58 export must succeed");
|
||||
assert_eq!(exported_base58.as_slice(), source_base58.as_bytes());
|
||||
|
||||
exported_json.zeroize();
|
||||
decoded_json.zeroize();
|
||||
exported_base58.zeroize();
|
||||
@@ -233,7 +224,6 @@ fn owner_transfer_file_export_is_no_clobber() {
|
||||
let second = runtime.block_on(owner.export_transfer_file(export_path.as_path(), crate::WalletTransferFormat::SolanaCliJson));
|
||||
assert_eq!(second.expect_err("OWNER transfer-file export must not overwrite").code(), crate::ERROR_CODE_DESTINATION_EXISTS);
|
||||
assert_eq!(std::fs::read(export_path.as_path()).expect("first export must remain intact"), first);
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let mode = std::fs::metadata(export_path.as_path()).expect("export metadata must be readable").permissions().mode() & 0o777;
|
||||
|
||||
Reference in New Issue
Block a user