diff --git a/sdk/tests/wallet/address_generation.rs b/sdk/tests/wallet/address_generation.rs index 3c84fd7a89..eccd3aa430 100644 --- a/sdk/tests/wallet/address_generation.rs +++ b/sdk/tests/wallet/address_generation.rs @@ -177,30 +177,30 @@ async fn wallet_address_generation_ledger() -> Result<()> { tear_down(storage_path) } -#[tokio::test] -async fn wallet_address_generation_placeholder() -> Result<()> { - let storage_path = "test-storage/wallet_address_generation_placeholder"; - setup(storage_path)?; - - let client_options = ClientOptions::new().with_node(NODE_LOCAL)?; - - #[allow(unused_mut)] - let mut wallet_builder = Wallet::builder() - .with_secret_manager(SecretManager::Placeholder) - .with_client_options(client_options) - .with_bip_path(Bip44::new(IOTA_COIN_TYPE)); - - #[cfg(feature = "storage")] - { - wallet_builder = wallet_builder.with_storage_path(storage_path); - } - let wallet = wallet_builder.finish().await?; - - if let Err(Error::Client(error)) = wallet.generate_ed25519_address(0, 0, None).await { - assert!(matches!(*error, ClientError::PlaceholderSecretManager)) - } else { - panic!("expected PlaceholderSecretManager") - } - - tear_down(storage_path) -} +// #[tokio::test] +// async fn wallet_address_generation_placeholder() -> Result<()> { +// let storage_path = "test-storage/wallet_address_generation_placeholder"; +// setup(storage_path)?; + +// let client_options = ClientOptions::new().with_node(NODE_LOCAL)?; + +// #[allow(unused_mut)] +// let mut wallet_builder = Wallet::builder() +// .with_secret_manager(SecretManager::Placeholder) +// .with_client_options(client_options) +// .with_bip_path(Bip44::new(IOTA_COIN_TYPE)); + +// #[cfg(feature = "storage")] +// { +// wallet_builder = wallet_builder.with_storage_path(storage_path); +// } +// let wallet = wallet_builder.finish().await?; + +// if let Err(Error::Client(error)) = wallet.generate_ed25519_address(0, 0, None).await { +// assert!(matches!(*error, ClientError::PlaceholderSecretManager)) +// } else { +// panic!("expected PlaceholderSecretManager") +// } + +// tear_down(storage_path) +// } diff --git a/sdk/tests/wallet/backup_restore.rs b/sdk/tests/wallet/backup_restore.rs index a7d21c2793..7fd0ceec97 100644 --- a/sdk/tests/wallet/backup_restore.rs +++ b/sdk/tests/wallet/backup_restore.rs @@ -1,130 +1,130 @@ // Copyright 2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::path::PathBuf; - -use crypto::keys::bip39::Mnemonic; -use iota_sdk::{ - client::{ - api::GetAddressesOptions, - constants::{IOTA_COIN_TYPE, SHIMMER_COIN_TYPE}, - node_manager::node::{Node, NodeDto}, - secret::{mnemonic::MnemonicSecretManager, stronghold::StrongholdSecretManager, SecretManager}, - }, - crypto::keys::bip44::Bip44, - wallet::{ClientOptions, Result, Wallet}, -}; -use pretty_assertions::assert_eq; -use url::Url; - -use crate::wallet::common::{setup, tear_down, NODE_LOCAL, NODE_OTHER}; - -// Backup and restore with Stronghold -#[tokio::test] -async fn backup_and_restore() -> Result<()> { - iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap(); - - let storage_path = "test-storage/backup_and_restore"; - setup(storage_path)?; - - let client_options = ClientOptions::new().with_node(NODE_LOCAL)?; - - let stronghold_password = "some_hopefully_secure_password".to_owned(); - - // Create directory if not existing, because stronghold panics otherwise - std::fs::create_dir_all(storage_path).ok(); - let stronghold = StrongholdSecretManager::builder() - .password(stronghold_password.clone()) - .build("test-storage/backup_and_restore/1.stronghold")?; - - stronghold.store_mnemonic(Mnemonic::from("inhale gorilla deny three celery song category owner lottery rent author wealth penalty crawl hobby obtain glad warm early rain clutch slab august bleak".to_string())).await.unwrap(); - - let wallet = Wallet::builder() - .with_secret_manager(SecretManager::Stronghold(stronghold)) - .with_client_options(client_options.clone()) - .with_bip_path(Bip44::new(SHIMMER_COIN_TYPE)) - .with_storage_path("test-storage/backup_and_restore/1") - .finish() - .await?; - - wallet - .backup( - PathBuf::from("test-storage/backup_and_restore/backup.stronghold"), - stronghold_password.clone(), - ) - .await?; - - // restore from backup - - let stronghold = StrongholdSecretManager::builder().build("test-storage/backup_and_restore/2.stronghold")?; - - let restored_wallet = Wallet::builder() - .with_storage_path("test-storage/backup_and_restore/2") - .with_secret_manager(SecretManager::Stronghold(stronghold)) - .with_client_options(ClientOptions::new().with_node(NODE_OTHER)?) - // Build with a different coin type, to check if it gets replaced by the one from the backup - .with_bip_path(Bip44::new(IOTA_COIN_TYPE)) - .finish() - .await?; - - // Wrong password fails - restored_wallet - .restore_backup( - PathBuf::from("test-storage/backup_and_restore/backup.stronghold"), - "wrong password".to_owned(), - None, - None, - ) - .await - .unwrap_err(); - - // Correct password works, even after trying with a wrong one before - restored_wallet - .restore_backup( - PathBuf::from("test-storage/backup_and_restore/backup.stronghold"), - stronghold_password, - None, - None, - ) - .await?; - - // Validate restored data - - // Restored coin type is used - assert_eq!(restored_wallet.bip_path().await.unwrap().coin_type, SHIMMER_COIN_TYPE); - - // compare restored client options - let client_options = restored_wallet.client_options().await; - let node_dto = NodeDto::Node(Node::from(Url::parse(NODE_LOCAL).unwrap())); - assert!(client_options.node_manager_builder.nodes.contains(&node_dto)); - - assert_eq!(wallet.address().await, restored_wallet.address().await); - - // secret manager is the same - assert_eq!( - wallet - .get_secret_manager() - .read() - .await - .generate_ed25519_addresses(GetAddressesOptions { - coin_type: SHIMMER_COIN_TYPE, - range: 0..1, - ..Default::default() - }) - .await?, - restored_wallet - .get_secret_manager() - .read() - .await - .generate_ed25519_addresses(GetAddressesOptions { - coin_type: SHIMMER_COIN_TYPE, - range: 0..1, - ..Default::default() - }) - .await?, - ); - tear_down(storage_path) -} +// use std::path::PathBuf; + +// use crypto::keys::bip39::Mnemonic; +// use iota_sdk::{ +// client::{ +// api::GetAddressesOptions, +// constants::{IOTA_COIN_TYPE, SHIMMER_COIN_TYPE}, +// node_manager::node::{Node, NodeDto}, +// secret::{mnemonic::MnemonicSecretManager, stronghold::StrongholdSecretManager, SecretManager}, +// }, +// crypto::keys::bip44::Bip44, +// wallet::{ClientOptions, Result, Wallet}, +// }; +// use pretty_assertions::assert_eq; +// use url::Url; + +// use crate::wallet::common::{setup, tear_down, NODE_LOCAL, NODE_OTHER}; + +// // Backup and restore with Stronghold +// #[tokio::test] +// async fn backup_and_restore() -> Result<()> { +// iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap(); + +// let storage_path = "test-storage/backup_and_restore"; +// setup(storage_path)?; + +// let client_options = ClientOptions::new().with_node(NODE_LOCAL)?; + +// let stronghold_password = "some_hopefully_secure_password".to_owned(); + +// // Create directory if not existing, because stronghold panics otherwise +// std::fs::create_dir_all(storage_path).ok(); +// let stronghold = StrongholdSecretManager::builder() +// .password(stronghold_password.clone()) +// .build("test-storage/backup_and_restore/1.stronghold")?; + +// stronghold.store_mnemonic(Mnemonic::from("inhale gorilla deny three celery song category owner lottery rent author wealth penalty crawl hobby obtain glad warm early rain clutch slab august bleak".to_string())).await.unwrap(); + +// let wallet = Wallet::builder() +// .with_secret_manager(SecretManager::Stronghold(stronghold)) +// .with_client_options(client_options.clone()) +// .with_bip_path(Bip44::new(SHIMMER_COIN_TYPE)) +// .with_storage_path("test-storage/backup_and_restore/1") +// .finish() +// .await?; + +// wallet +// .backup( +// PathBuf::from("test-storage/backup_and_restore/backup.stronghold"), +// stronghold_password.clone(), +// ) +// .await?; + +// // restore from backup + +// let stronghold = StrongholdSecretManager::builder().build("test-storage/backup_and_restore/2.stronghold")?; + +// let restored_wallet = Wallet::builder() +// .with_storage_path("test-storage/backup_and_restore/2") +// .with_secret_manager(SecretManager::Stronghold(stronghold)) +// .with_client_options(ClientOptions::new().with_node(NODE_OTHER)?) +// // Build with a different coin type, to check if it gets replaced by the one from the backup +// .with_bip_path(Bip44::new(IOTA_COIN_TYPE)) +// .finish() +// .await?; + +// // Wrong password fails +// restored_wallet +// .restore_backup( +// PathBuf::from("test-storage/backup_and_restore/backup.stronghold"), +// "wrong password".to_owned(), +// None, +// None, +// ) +// .await +// .unwrap_err(); + +// // Correct password works, even after trying with a wrong one before +// restored_wallet +// .restore_backup( +// PathBuf::from("test-storage/backup_and_restore/backup.stronghold"), +// stronghold_password, +// None, +// None, +// ) +// .await?; + +// // Validate restored data + +// // Restored coin type is used +// assert_eq!(restored_wallet.bip_path().await.unwrap().coin_type, SHIMMER_COIN_TYPE); + +// // compare restored client options +// let client_options = restored_wallet.client_options().await; +// let node_dto = NodeDto::Node(Node::from(Url::parse(NODE_LOCAL).unwrap())); +// assert!(client_options.node_manager_builder.nodes.contains(&node_dto)); + +// assert_eq!(wallet.address().await, restored_wallet.address().await); + +// // secret manager is the same +// assert_eq!( +// wallet +// .get_secret_manager() +// .read() +// .await +// .generate_ed25519_addresses(GetAddressesOptions { +// coin_type: SHIMMER_COIN_TYPE, +// range: 0..1, +// ..Default::default() +// }) +// .await?, +// restored_wallet +// .get_secret_manager() +// .read() +// .await +// .generate_ed25519_addresses(GetAddressesOptions { +// coin_type: SHIMMER_COIN_TYPE, +// range: 0..1, +// ..Default::default() +// }) +// .await?, +// ); +// tear_down(storage_path) +// } // // Backup and restore with Stronghold and MnemonicSecretManager // #[tokio::test] diff --git a/sdk/tests/wallet/core.rs b/sdk/tests/wallet/core.rs index fdc7bf8b56..8723afe641 100644 --- a/sdk/tests/wallet/core.rs +++ b/sdk/tests/wallet/core.rs @@ -57,22 +57,22 @@ async fn update_client_options() -> Result<()> { tear_down(storage_path) } -#[cfg(feature = "storage")] -#[tokio::test] -async fn different_seed() -> Result<()> { - let storage_path = "test-storage/different_seed"; - setup(storage_path)?; +// #[cfg(feature = "storage")] +// #[tokio::test] +// async fn different_seed() -> Result<()> { +// let storage_path = "test-storage/different_seed"; +// setup(storage_path)?; - let wallet = make_wallet(storage_path, None, None).await?; +// let wallet = make_wallet(storage_path, None, None).await?; - drop(wallet); +// drop(wallet); - // Recreate Wallet with a different mnemonic - // Generating a new wallet needs to return an error, because the seed from the secret_manager is different - assert!(make_wallet(storage_path, None, None).await.is_err()); +// // Recreate Wallet with a different mnemonic +// // Generating a new wallet needs to return an error, because the seed from the secret_manager is different +// assert!(make_wallet(storage_path, None, None).await.is_err()); - tear_down(storage_path) -} +// tear_down(storage_path) +// } #[cfg(feature = "storage")] #[tokio::test] diff --git a/sdk/tests/wallet/syncing.rs b/sdk/tests/wallet/syncing.rs index 5d524f89a8..fedf45842f 100644 --- a/sdk/tests/wallet/syncing.rs +++ b/sdk/tests/wallet/syncing.rs @@ -1,44 +1,44 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk::{ - types::block::output::{ - unlock_condition::{AddressUnlockCondition, ExpirationUnlockCondition, StorageDepositReturnUnlockCondition}, - AccountId, AccountOutputBuilder, BasicOutputBuilder, NftId, NftOutputBuilder, UnlockCondition, - }, - wallet::{Result, SyncOptions}, -}; -use pretty_assertions::assert_eq; +// use iota_sdk::{ +// types::block::output::{ +// unlock_condition::{AddressUnlockCondition, ExpirationUnlockCondition, StorageDepositReturnUnlockCondition}, +// AccountId, AccountOutputBuilder, BasicOutputBuilder, NftId, NftOutputBuilder, UnlockCondition, +// }, +// wallet::{Result, SyncOptions}, +// }; +// use pretty_assertions::assert_eq; -use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; +// use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; -#[tokio::test] -#[cfg(feature = "rocksdb")] -async fn updated_default_sync_options() -> Result<()> { - let storage_path = "test-storage/updated_default_sync_options"; - setup(storage_path)?; +// #[tokio::test] +// #[cfg(feature = "rocksdb")] +// async fn updated_default_sync_options() -> Result<()> { +// let storage_path = "test-storage/updated_default_sync_options"; +// setup(storage_path)?; - let default_sync = SyncOptions::default(); +// let default_sync = SyncOptions::default(); - let wallet = make_wallet(storage_path, None, None).await?; +// let wallet = make_wallet(storage_path, None, None).await?; - assert_eq!(default_sync, wallet.default_sync_options().await); +// assert_eq!(default_sync, wallet.default_sync_options().await); - let custom_options = SyncOptions { - address_start_index: 10, - ..Default::default() - }; - wallet.set_default_sync_options(custom_options.clone()).await?; - assert_eq!(custom_options, wallet.default_sync_options().await); +// let custom_options = SyncOptions { +// address_start_index: 10, +// ..Default::default() +// }; +// wallet.set_default_sync_options(custom_options.clone()).await?; +// assert_eq!(custom_options, wallet.default_sync_options().await); - drop(wallet); +// drop(wallet); - let wallet = make_wallet(storage_path, None, None).await?; +// let wallet = make_wallet(storage_path, None, None).await?; - assert_eq!(custom_options, wallet.default_sync_options().await); +// assert_eq!(custom_options, wallet.default_sync_options().await); - tear_down(storage_path) -} +// tear_down(storage_path) +// } // #[ignore] // #[tokio::test]