Skip to content

Commit

Permalink
Remove some stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee committed Apr 12, 2023
1 parent 3767993 commit 944236a
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 175 deletions.
8 changes: 0 additions & 8 deletions aries_vcx/src/utils/async_fn_iterator.rs

This file was deleted.

66 changes: 0 additions & 66 deletions aries_vcx/src/utils/json.rs

This file was deleted.

2 changes: 0 additions & 2 deletions aries_vcx/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ macro_rules! map (
pub mod author_agreement;
#[rustfmt::skip]
pub mod constants;
pub mod async_fn_iterator;
pub mod file;
pub mod json;
pub mod mockdata;
pub mod openssl;
pub mod provision;
Expand Down
28 changes: 0 additions & 28 deletions aries_vcx_core/src/global/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ pub static CONFIG_PROTOCOL_VERSION: &str = "protocol_version";
pub static CONFIG_TXN_AUTHOR_AGREEMENT: &str = "author_agreement";
pub static DEFAULT_PROTOCOL_VERSION: usize = 2;
pub static MAX_SUPPORTED_PROTOCOL_VERSION: usize = 2;
pub static DEFAULT_POOL_NAME: &str = "pool1";
pub static DEFAULT_LINK_SECRET_ALIAS: &str = "main";
pub static DEFAULT_DID: &str = "2hoqvcwupRTUNkXn6ArYzs";
pub static DEFAULT_WALLET_BACKUP_KEY: &str = "backup_wallet_key";

lazy_static! {
static ref SETTINGS: RwLock<HashMap<String, String>> = RwLock::new(HashMap::new());
Expand Down Expand Up @@ -74,32 +72,6 @@ pub fn set_config_value(key: &str, value: &str) -> VcxCoreResult<()> {
Ok(())
}

pub fn reset_config_values() -> VcxCoreResult<()> {
trace!("reset_config_values >>>");
let mut config = SETTINGS.write()?;
config.clear();
Ok(())
}

pub fn set_test_configs() -> String {
trace!("set_testing_defaults >>>");
let mut settings = SETTINGS
.write()
.expect("Unabled to access SETTINGS while setting test configs");
let institution_did = CONFIG_INSTITUTION_DID;
settings.insert(CONFIG_POOL_NAME.to_string(), DEFAULT_POOL_NAME.to_string());
settings.insert(institution_did.to_string(), DEFAULT_DID.to_string());
settings.insert(
CONFIG_PROTOCOL_VERSION.to_string(),
DEFAULT_PROTOCOL_VERSION.to_string(),
);
settings.insert(
CONFIG_WALLET_BACKUP_KEY.to_string(),
DEFAULT_WALLET_BACKUP_KEY.to_string(),
);
institution_did.to_string()
}

pub fn get_protocol_version() -> usize {
let protocol_version = match get_config_value(CONFIG_PROTOCOL_VERSION) {
Ok(ver) => ver.parse::<usize>().unwrap_or_else(|err| {
Expand Down
72 changes: 1 addition & 71 deletions aries_vcx_core/src/utils/mockdata/mock_settings.rs
Original file line number Diff line number Diff line change
@@ -1,91 +1,21 @@
use std::sync::RwLock;
use std::{collections::HashMap, sync::Mutex};

use crate::errors::error::{AriesVcxCoreError, VcxCoreResult};
use crate::errors::error::VcxCoreResult;

static MOCKED_GENERATED_PROOF: &str = "mocked_proof";
static MOCKED_RETRIEVED_CREDS: &str = "mocked_retrieved_creds";
static MOCKED_VALIDATE_INDY_PROOF: &str = "mocked_validate_indy_proof";

lazy_static! {
static ref MOCK_SETTINGS: RwLock<HashMap<String, String>> = RwLock::new(HashMap::new());
static ref MOCK_SETTINGS_RESULT_BOOL: RwLock<HashMap<String, VcxCoreResult<bool>>> = RwLock::new(HashMap::new());
static ref STATUS_CODE_MOCK: Mutex<StatusCodeMock> = Mutex::new(StatusCodeMock::default());
}

pub struct MockBuilder; // empty

impl MockBuilder {
pub fn init() -> MockBuilder {
MockBuilder {}
}

pub fn set_mock_generate_indy_proof(self, generated_proof: &str) -> MockBuilder {
warn!(
"MockBuilder::set_mock_generate_indy_proof >>> generated_proof: {}",
generated_proof
);
let mut settings = MOCK_SETTINGS.write().expect("Unable to access MOCK_SETTINGS");
settings.insert(String::from(MOCKED_GENERATED_PROOF), generated_proof.into());
self
}

pub fn set_mock_creds_retrieved_for_proof_request(self, retrieve_creds: &str) -> MockBuilder {
warn!(
"MockBuilder::set_mock_creds_retrieved_for_proof_request >>> retrieve_creds: {}",
retrieve_creds
);
let mut settings = MOCK_SETTINGS.write().expect("Unable to access MOCK_SETTINGS");
settings.insert(String::from(MOCKED_RETRIEVED_CREDS), retrieve_creds.into());
self
}

pub fn set_mock_result_for_validate_indy_proof(self, result: VcxCoreResult<bool>) -> MockBuilder {
warn!(
"MockBuilder::set_mock_result_for_validate_indy_proof >>> result: {:?}",
result
);
let mut settings = MOCK_SETTINGS_RESULT_BOOL
.write()
.expect("Unable to access MOCK_SETTINGS_RESULT_BOOL");
settings.insert(String::from(MOCKED_VALIDATE_INDY_PROOF), result);
self
}

pub fn reset_mock_settings(&self) {
warn!("MockBuilder::reset_mock_settings >>>");
let mut config = MOCK_SETTINGS.write().expect("Unable to access MOCK_SETTINGS");
config.clear();
}
}

impl Drop for MockBuilder {
fn drop(&mut self) {
warn!("MockBuilder::drop >>>");
self.reset_mock_settings();
}
}

pub fn get_mock_generate_indy_proof() -> Option<String> {
let config = MOCK_SETTINGS.read().expect("Unable to access MOCK_SETTINGS");
config.get(MOCKED_GENERATED_PROOF).map(String::from)
}

pub fn get_mock_creds_retrieved_for_proof_request() -> Option<String> {
let config = MOCK_SETTINGS.read().expect("Unable to access MOCK_SETTINGS");
config.get(MOCKED_RETRIEVED_CREDS).map(String::from)
}

pub fn get_mock_result_for_validate_indy_proof() -> Option<VcxCoreResult<bool>> {
let config = MOCK_SETTINGS_RESULT_BOOL
.read()
.expect("Unable to access MOCK_SETTINGS_RESULT_BOOL");
config.get(MOCKED_VALIDATE_INDY_PROOF).map(|result| match result {
Ok(val) => Ok(*val),
Err(err) => Err(AriesVcxCoreError::from_msg(err.kind(), err.to_string())),
})
}

#[derive(Default)]
pub struct StatusCodeMock {
results: Vec<u32>,
Expand Down

0 comments on commit 944236a

Please sign in to comment.