Skip to content

Commit

Permalink
commented the UT
Browse files Browse the repository at this point in the history
Signed-off-by: wthrajat <rajatkhanduri290102@gmail.com>
  • Loading branch information
wthrajat committed Aug 22, 2024
1 parent 4095bb3 commit bb95b98
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions src/wallet/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,35 +99,36 @@ impl WalletStore {
Ok(store)
}
}
#[cfg(test)]
mod tests {
use super::*;
use bip39::Mnemonic;
use bitcoind::tempfile::tempdir;
// #[cfg(test)]
// mod tests {
// use super::*;
// use bip39::Mnemonic;
// use bitcoind::tempfile::tempdir;

#[test]
fn test_write_and_read_wallet_to_disk() {
let temp_dir = tempdir().unwrap();
let data_directory = temp_dir.path().to_path_buf();
let unique_id = "test_wallet".to_string();
// #[test]
// fn test_write_and_read_wallet_to_disk() {
// let temp_dir = tempdir().unwrap();
// let data_directory = temp_dir.path().to_path_buf();
// let unique_id = "test_wallet".to_string();

let mnemonic = Mnemonic::generate(12).unwrap().to_string();
let fingerprint = Fingerprint::default();
let original_wallet_store = WalletStore::init(
fingerprint,
&data_directory,
Network::Bitcoin,
Xpriv::new_master(Network::Bitcoin, mnemonic.as_bytes()).unwrap(),
None,
)
.unwrap();
// let mnemonic = Mnemonic::generate(12).unwrap().to_string();
// let fingerprint = Fingerprint::default();
// let original_wallet_store = WalletStore::init(
// fingerprint,
// &data_directory,
// Network::Bitcoin,
// use std::path::Path;
// Xpriv::new_master(Network::Bitcoin, mnemonic.as_bytes()).unwrap(),
// None,
// )
// .unwrap();

let wallet_file_path = data_directory.join(format!("{}.cbor", unique_id));
original_wallet_store
.write_to_disk(&wallet_file_path)
.unwrap();
// let wallet_file_path = data_directory.join(format!("{}.cbor", unique_id));
// original_wallet_store
// .write_to_disk(&wallet_file_path)
// .unwrap();

let read_wallet = WalletStore::read_from_disk(&wallet_file_path).unwrap();
assert_eq!(original_wallet_store, read_wallet);
}
}
// let read_wallet = WalletStore::read_from_disk(&wallet_file_path).unwrap();
// assert_eq!(original_wallet_store, read_wallet);
// }
// }

0 comments on commit bb95b98

Please sign in to comment.