diff --git a/aries_vcx/tests/test_credential_retrieval.rs b/aries_vcx/tests/test_credential_retrieval.rs index 28629b9d07..1aa6633d87 100644 --- a/aries_vcx/tests/test_credential_retrieval.rs +++ b/aries_vcx/tests/test_credential_retrieval.rs @@ -285,7 +285,7 @@ async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() #[ignore] #[allow(unused_mut)] async fn test_agency_pool_it_should_fail_to_select_credentials_for_predicate() { - use aries_vcx::utils::devsetup::SetupPoolDirectory; + use test_utils::devsetup::SetupPoolDirectory; use utils::{ scenarios::prover_select_credentials, test_agent::{create_test_agent, create_test_agent_trustee}, diff --git a/aries_vcx/tests/utils/test_agent.rs b/aries_vcx/tests/utils/test_agent.rs index 8d4c6c9355..e1701bb1c2 100644 --- a/aries_vcx/tests/utils/test_agent.rs +++ b/aries_vcx/tests/utils/test_agent.rs @@ -6,11 +6,11 @@ use aries_vcx_core::{ ledger::base_ledger::{ AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite, }, - wallet::{base_wallet::BaseWallet, indy::IndySdkWallet}, + wallet::base_wallet::BaseWallet, }; use test_utils::{ constants::TRUSTEE_SEED, - devsetup::{dev_build_featured_components, dev_setup_wallet_indy}, + devsetup::{dev_build_featured_components, dev_build_featured_wallet}, random::generate_random_seed, }; @@ -38,8 +38,7 @@ async fn create_test_agent_from_seed( impl BaseAnonCreds, impl BaseWallet, > { - let (institution_did, wallet_handle) = dev_setup_wallet_indy(seed).await; - let wallet = IndySdkWallet::new(wallet_handle); + let (institution_did, wallet) = dev_build_featured_wallet(seed).await; let (ledger_read, ledger_write, anoncreds) = dev_build_featured_components(genesis_file_path.clone()).await; diff --git a/aries_vcx_core/src/wallet/indy/did_mocks.rs b/aries_vcx_core/src/wallet/indy/did_mocks.rs deleted file mode 100644 index 0d2ecaca92..0000000000 --- a/aries_vcx_core/src/wallet/indy/did_mocks.rs +++ /dev/null @@ -1,89 +0,0 @@ -use std::{ - collections::HashSet, - sync::{Mutex, RwLock}, -}; - -lazy_static! { - pub static ref ENABLED_MOCKS: RwLock> = RwLock::new(HashSet::new()); -} - -lazy_static! { - static ref DID_MOCK_RESPONSES: Mutex = Mutex::new(DidMocks::default()); -} - -pub const CONFIG_DID_MOCKS: &str = "did_mocks"; - -#[derive(Default)] -pub struct DidMocks { - responses: Vec, -} - -impl DidMocks { - pub fn set_next_did_response(body: &str) { - if did_mocks_enabled() { - trace!("Mocks enabled, setting next did response"); - DID_MOCK_RESPONSES - .lock() - .expect("Unable to access DID_MOCK_RESPONSES") - .responses - .push(body.into()); - } else { - warn!("Attempting to set mocked did response when mocks are not enabled!"); - } - } - - pub fn get_next_did_response() -> String { - if Self::has_did_mock_responses() { - trace!("Mocks enabled, getting next did response"); - DID_MOCK_RESPONSES - .lock() - .expect("Unable to access DID_MOCK_RESPONSES") - .responses - .pop() - .expect("No data on DID_MOCK_RESPONSES stack to pop") - } else { - debug!( - "Attempting to obtain did response when none were set, but did messages available \ - - returning empty response..." - ); - String::new() - } - } - - pub fn has_did_mock_responses() -> bool { - !DID_MOCK_RESPONSES - .lock() - .expect("Unable to access DID_MOCK_RESPONSES") - .responses - .is_empty() - } - - pub fn clear_mocks() { - DID_MOCK_RESPONSES - .lock() - .expect("Unable to access DID_MOCK_RESPONSES") - .responses - .clear(); - } -} - -pub fn did_mocks_enabled() -> bool { - ENABLED_MOCKS - .read() - .expect("Unable to access ENABLED_MOCKS") - .contains(CONFIG_DID_MOCKS) -} - -pub fn enable_did_mocks() { - ENABLED_MOCKS - .write() - .expect("Unable to access ENABLED_MOCKS") - .insert(CONFIG_DID_MOCKS.to_string()); -} - -pub fn disable_did_mocks() { - ENABLED_MOCKS - .write() - .expect("Unable to access ENABLED_MOCKS") - .remove(CONFIG_DID_MOCKS); -} diff --git a/aries_vcx_core/src/wallet/indy/mod.rs b/aries_vcx_core/src/wallet/indy/mod.rs index 86938afaf1..baac1afee3 100644 --- a/aries_vcx_core/src/wallet/indy/mod.rs +++ b/aries_vcx_core/src/wallet/indy/mod.rs @@ -12,7 +12,6 @@ use crate::{ SearchHandle, WalletHandle, }; -pub mod did_mocks; pub mod indy_wallet; pub mod internal; pub mod signing; diff --git a/aries_vcx_core/src/wallet/indy/wallet.rs b/aries_vcx_core/src/wallet/indy/wallet.rs index 4bf556c602..1a2da86570 100644 --- a/aries_vcx_core/src/wallet/indy/wallet.rs +++ b/aries_vcx_core/src/wallet/indy/wallet.rs @@ -8,10 +8,7 @@ use vdrtools::{ use crate::{ errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}, - wallet::indy::{ - did_mocks::{did_mocks_enabled, DidMocks}, - IssuerConfig, RestoreWalletConfigs, WalletConfig, - }, + wallet::indy::{IssuerConfig, RestoreWalletConfigs, WalletConfig}, }; pub async fn open_wallet(wallet_config: &WalletConfig) -> VcxCoreResult { @@ -317,11 +314,6 @@ pub async fn libindy_replace_keys_start( wallet_handle: WalletHandle, did: &str, ) -> VcxCoreResult { - if DidMocks::has_did_mock_responses() { - warn!("libindy_replace_keys_start >> retrieving did mock response"); - return Ok(DidMocks::get_next_did_response()); - } - let res = Locator::instance() .did_controller .replace_keys_start(wallet_handle, KeyInfo::default(), DidValue(did.into())) @@ -334,11 +326,6 @@ pub async fn libindy_replace_keys_apply( wallet_handle: WalletHandle, did: &str, ) -> VcxCoreResult<()> { - if did_mocks_enabled() { - warn!("libindy_replace_keys_apply >> retrieving did mock response"); - return Ok(()); - } - Locator::instance() .did_controller .replace_keys_apply(wallet_handle, DidValue(did.into())) @@ -351,11 +338,6 @@ pub async fn get_verkey_from_wallet( wallet_handle: WalletHandle, did: &str, ) -> VcxCoreResult { - if DidMocks::has_did_mock_responses() { - warn!("get_verkey_from_wallet >> retrieving did mock response"); - return Ok(DidMocks::get_next_did_response()); - } - let res = Locator::instance() .did_controller .key_for_local_did(wallet_handle, DidValue(did.into())) diff --git a/tools/test_utils/src/devsetup.rs b/tools/test_utils/src/devsetup.rs index 0f7f0a64be..0e8873fb9d 100644 --- a/tools/test_utils/src/devsetup.rs +++ b/tools/test_utils/src/devsetup.rs @@ -36,7 +36,6 @@ use aries_vcx_core::{ledger::request_submitter::vdr_proxy::VdrProxySubmitter, Vd #[cfg(feature = "vdrtools_wallet")] use aries_vcx_core::{ wallet::indy::{ - did_mocks::DidMocks, wallet::{create_and_open_wallet, create_and_store_my_did}, WalletConfig, }, @@ -148,7 +147,6 @@ pub struct SetupPoolDirectory { pub fn reset_global_state() { warn!("reset_global_state >>"); AgencyMockDecrypted::clear_mocks(); - DidMocks::clear_mocks(); } impl SetupMocks { @@ -165,6 +163,7 @@ impl Drop for SetupMocks { } } +#[cfg(feature = "vdrtools_wallet")] pub async fn dev_setup_wallet_indy(key_seed: &str) -> (String, WalletHandle) { info!("dev_setup_wallet_indy >>"); let config_wallet = WalletConfig { @@ -186,7 +185,7 @@ pub async fn dev_setup_wallet_indy(key_seed: &str) -> (String, WalletHandle) { (did, wallet_handle) } -#[cfg(all(feature = "credx", feature = "vdrtools_wallet"))] +#[cfg(feature = "credx")] pub fn dev_build_profile_modular( genesis_file_path: String, ) -> ( @@ -275,24 +274,24 @@ pub async fn dev_build_featured_components( } #[cfg(feature = "vdrtools_wallet")] -pub async fn dev_build_indy_wallet() -> (String, impl BaseWallet) { +pub async fn dev_build_indy_wallet(key_seed: &str) -> (String, impl BaseWallet) { use aries_vcx_core::wallet::indy::IndySdkWallet; - let (public_did, wallet_handle) = dev_setup_wallet_indy(TRUSTEE_SEED).await; + let (public_did, wallet_handle) = dev_setup_wallet_indy(key_seed).await; (public_did, IndySdkWallet::new(wallet_handle)) } #[allow(unreachable_code)] #[allow(unused_variables)] -pub async fn dev_build_featured_wallet() -> (String, impl BaseWallet) { +pub async fn dev_build_featured_wallet(key_seed: &str) -> (String, impl BaseWallet) { #[cfg(feature = "vdrtools_wallet")] return { info!("SetupProfile >> using indy wallet"); - dev_build_indy_wallet().await + dev_build_indy_wallet(key_seed).await }; #[cfg(not(feature = "vdrtools_wallet"))] - return { (String::new(), MockWallet) }; + return (String::new(), MockWallet); } #[macro_export] @@ -315,7 +314,7 @@ pub async fn build_setup_profile() -> SetupProfile< let genesis_file_path = get_temp_file_path(POOL1_TXN).to_str().unwrap().to_string(); create_testpool_genesis_txn_file(&genesis_file_path); - let (institution_did, wallet) = dev_build_featured_wallet().await; + let (institution_did, wallet) = dev_build_featured_wallet(TRUSTEE_SEED).await; let (ledger_read, ledger_write, anoncreds) = dev_build_featured_components(genesis_file_path.clone()).await; anoncreds