Skip to content

Commit

Permalink
Fix/cleanup features
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Jun 22, 2023
1 parent 61753b8 commit e384f78
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 27 deletions.
12 changes: 6 additions & 6 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,17 @@ required-features = [ "wallet", "stronghold" ]
[[example]]
name = "check_unlock_conditions"
path = "examples/wallet/17_check_unlock_conditions.rs"
required-features = [ "wallet" ]
required-features = [ "wallet", "storage" ]

[[example]]
name = "accounts"
path = "examples/wallet/accounts.rs"
required-features = [ "wallet" ]
required-features = [ "wallet", "storage" ]

[[example]]
name = "background_syncing"
path = "examples/wallet/background_syncing.rs"
required-features = [ "wallet" ]
required-features = [ "wallet", "storage" ]

[[example]]
name = "events"
Expand Down Expand Up @@ -661,7 +661,7 @@ required-features = [ "wallet", "stronghold" ]
[[example]]
name = "recover_accounts"
path = "examples/wallet/recover_accounts.rs"
required-features = [ "wallet" ]
required-features = [ "wallet", "storage" ]

[[example]]
name = "spammer"
Expand All @@ -671,7 +671,7 @@ required-features = [ "wallet" ]
[[example]]
name = "split_funds"
path = "examples/wallet/split_funds.rs"
required-features = [ "wallet" ]
required-features = [ "wallet", "storage" ]

[[example]]
name = "storage"
Expand All @@ -686,7 +686,7 @@ required-features = [ "wallet", "stronghold" ]
[[example]]
name = "wallet"
path = "examples/wallet/wallet.rs"
required-features = [ "wallet" ]
required-features = [ "wallet", "storage" ]

[[example]]
name = "migrate_stronghold_snapshot_v2_to_v3"
Expand Down
1 change: 0 additions & 1 deletion sdk/examples/wallet/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async fn main() -> Result<()> {
MnemonicSecretManager::try_from_mnemonic(var("NON_SECURE_USE_OF_DEVELOPMENT_MNEMONIC_1").unwrap())?;
let wallet = Wallet::builder()
.with_secret_manager(SecretManager::Mnemonic(secret_manager))
.with_storage_path(&var("WALLET_DB_PATH").unwrap())
.with_client_options(client_options)
.with_coin_type(SHIMMER_COIN_TYPE)
.finish()
Expand Down
1 change: 1 addition & 0 deletions sdk/src/wallet/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ impl AccountDetails {
/// index: 0, coin_type: 4218, alias: "Alice", public_addresses: contains a single public account address
/// (rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy), all other fields are set to their Rust
/// defaults.
#[cfg(feature = "storage")]
pub(crate) fn mock() -> Self {
Self {
index: 0,
Expand Down
11 changes: 1 addition & 10 deletions sdk/tests/wallet/backup_restore.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

#[cfg(all(feature = "stronghold", feature = "storage"))]
use std::path::PathBuf;

#[cfg(all(feature = "stronghold", feature = "storage"))]
use iota_sdk::wallet::{ClientOptions, Result, Wallet};
#[cfg(all(feature = "stronghold", feature = "storage"))]
use iota_sdk::{
client::{
constants::{IOTA_COIN_TYPE, SHIMMER_COIN_TYPE},
node_manager::node::{Node, NodeDto},
secret::{mnemonic::MnemonicSecretManager, stronghold::StrongholdSecretManager, SecretManager},
},
wallet::{ClientOptions, Result, Wallet},
Url,
};

use crate::wallet::common::{setup, tear_down, NODE_LOCAL, NODE_OTHER};

#[tokio::test]
#[cfg(all(feature = "stronghold", feature = "storage"))]
// Backup and restore with Stronghold
async fn backup_and_restore() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -114,7 +110,6 @@ async fn backup_and_restore() -> Result<()> {
}

#[tokio::test]
#[cfg(all(feature = "stronghold", feature = "storage"))]
// Backup and restore with Stronghold and MnemonicSecretManager
async fn backup_and_restore_mnemonic_secret_manager() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -197,7 +192,6 @@ async fn backup_and_restore_mnemonic_secret_manager() -> Result<()> {
}

#[tokio::test]
#[cfg(all(feature = "stronghold", feature = "storage"))]
// Backup and restore with Stronghold
async fn backup_and_restore_different_coin_type() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -282,7 +276,6 @@ async fn backup_and_restore_different_coin_type() -> Result<()> {
}

#[tokio::test]
#[cfg(all(feature = "stronghold", feature = "storage"))]
// Backup and restore with Stronghold
async fn backup_and_restore_same_coin_type() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -365,7 +358,6 @@ async fn backup_and_restore_same_coin_type() -> Result<()> {
}

#[tokio::test]
#[cfg(all(feature = "stronghold", feature = "storage"))]
// Backup and restore with Stronghold
async fn backup_and_restore_different_coin_type_dont_ignore() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -454,7 +446,6 @@ async fn backup_and_restore_different_coin_type_dont_ignore() -> Result<()> {
}

#[tokio::test]
#[cfg(all(feature = "stronghold", feature = "storage"))]
async fn backup_and_restore_bech32_hrp_mismatch() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();

Expand Down
3 changes: 0 additions & 3 deletions sdk/tests/wallet/migrate_stronghold_snapshot_v2_to_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::wallet::common::{setup, tear_down, NODE_LOCAL};
const PBKDF_SALT: &str = "wallet.rs";
const PBKDF_ITER: u32 = 100;

#[cfg(feature = "stronghold")]
#[tokio::test]
async fn stronghold_snapshot_v2_v3_migration() {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -117,7 +116,6 @@ async fn stronghold_snapshot_v2_v3_migration() {
tear_down(storage_path).unwrap();
}

#[cfg(feature = "stronghold")]
#[tokio::test]
async fn stronghold_snapshot_v2_v3_migration_same_path() {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -155,7 +153,6 @@ async fn stronghold_snapshot_v2_v3_migration_same_path() {
std::fs::remove_file("./tests/wallet/fixtures/v2-copy.stronghold").unwrap();
}

#[cfg(feature = "stronghold")]
#[tokio::test]
async fn stronghold_snapshot_v2_v3_migration_with_backup() {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down
3 changes: 3 additions & 0 deletions sdk/tests/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod account_recovery;
mod accounts;
#[cfg(all(feature = "stronghold", feature = "storage"))]
mod backup_restore;
mod balance;
mod bech32_hrp_validation;
Expand All @@ -15,6 +16,7 @@ mod error;
mod events;
#[cfg(feature = "message_interface")]
mod message_interface;
#[cfg(feature = "stronghold")]
mod migrate_stronghold_snapshot_v2_to_v3;
mod native_tokens;
mod output_preparation;
Expand All @@ -23,4 +25,5 @@ mod transactions;
#[allow(clippy::module_inception)]
mod wallet;
#[cfg(not(target_os = "windows"))]
#[cfg(feature = "rocksdb")]
mod wallet_storage;
10 changes: 7 additions & 3 deletions sdk/tests/wallet/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
use iota_sdk::client::secret::stronghold::StrongholdSecretManager;
#[cfg(feature = "storage")]
use iota_sdk::{
client::constants::SHIMMER_COIN_TYPE,
client::node_manager::node::{Node, NodeDto},
wallet::Error,
Url,
};
use iota_sdk::{
client::{
constants::{IOTA_COIN_TYPE, SHIMMER_COIN_TYPE},
constants::IOTA_COIN_TYPE,
secret::{mnemonic::MnemonicSecretManager, SecretManager},
},
types::block::address::{Bech32Address, ToBech32Ext},
wallet::{ClientOptions, Error, Result, Wallet},
wallet::{ClientOptions, Result, Wallet},
};

use crate::wallet::common::{make_wallet, setup, tear_down, DEFAULT_MNEMONIC, NODE_LOCAL, NODE_OTHER};
#[cfg(feature = "storage")]
use crate::wallet::common::NODE_OTHER;
use crate::wallet::common::{make_wallet, setup, tear_down, DEFAULT_MNEMONIC, NODE_LOCAL};

#[cfg(feature = "storage")]
#[tokio::test]
Expand Down
10 changes: 6 additions & 4 deletions sdk/tests/wallet/wallet_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

use std::{fs, io, path::Path};

use iota_sdk::{client::stronghold::StrongholdAdapter, wallet::Result, Wallet};
#[cfg(feature = "stronghold")]
use iota_sdk::client::stronghold::StrongholdAdapter;
use iota_sdk::{wallet::Result, Wallet};

use crate::wallet::common::{setup, tear_down};

// Db created with wallet.rs commit 8dd389ddeed0d95bb493c38f376b41a6a9127148
#[cfg(all(feature = "stronghold", feature = "rocksdb"))]
#[cfg(feature = "stronghold")]
#[tokio::test]
async fn check_existing_db() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down Expand Up @@ -86,7 +88,7 @@ async fn check_existing_db() -> Result<()> {
}

// Db created with wallet.rs commit 2dd9974c1bc05c2b0b7d6f0ee100deb2da60d071
#[cfg(all(feature = "ledger_nano", feature = "rocksdb"))]
#[cfg(feature = "ledger_nano")]
#[tokio::test]
async fn check_existing_db_1() -> Result<()> {
let storage_path = "check_existing_1_db_test";
Expand Down Expand Up @@ -135,7 +137,7 @@ async fn check_existing_db_1() -> Result<()> {
}

// Db created with wallet.rs commit b5132eb545cd0a2043640677bca335efee4029b8
#[cfg(all(feature = "stronghold", feature = "rocksdb"))]
#[cfg(feature = "stronghold")]
#[tokio::test]
async fn check_existing_db_2() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Expand Down

0 comments on commit e384f78

Please sign in to comment.