Skip to content

Commit

Permalink
Builder patter in agency client configuration (#588)
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee authored Sep 30, 2022
1 parent e60c74d commit 6f163ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions agency_client/src/agency_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl AgencyClient {
self.my_vk = vk.to_string();
}

pub fn configure(&mut self, config: &AgencyClientConfig) -> AgencyClientResult<()> {
pub fn configure(mut self, config: &AgencyClientConfig) -> AgencyClientResult<Self> {
info!("AgencyClient::configure >>> config {:?}", config);

validate_mandotory_config_val(
Expand Down Expand Up @@ -128,7 +128,7 @@ impl AgencyClient {
self.set_my_pwdid(&config.sdk_to_remote_did);
self.set_my_vk(&config.sdk_to_remote_verkey);

Ok(())
Ok(self)
}

pub fn set_testing_defaults_agency(&mut self) {
Expand Down
5 changes: 2 additions & 3 deletions aries_vcx/tests/test_agency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub mod utils;
#[cfg(test)]
#[cfg(feature = "agency_v2")]
mod integration_tests {
use std::fmt;
use std::thread;
use std::time::Duration;

Expand Down Expand Up @@ -395,7 +394,7 @@ mod integration_tests {
#[cfg(feature = "agency_v2")]
#[tokio::test]
async fn test_update_agent_webhook() {
let setup = SetupPool::init().await;
let _setup = SetupPool::init().await;
let wallet_config = WalletConfig {
wallet_name: format!("wallet_{}", uuid::Uuid::new_v4().to_string()),
wallet_key: settings::DEFAULT_WALLET_KEY.into(),
Expand All @@ -419,7 +418,7 @@ mod integration_tests {
.await
.unwrap();
let config = client.get_config().unwrap();
client.configure(&config);
let client = client.configure(&config).unwrap();
client.update_agent_webhook("https://example.org").await.unwrap();
close_wallet(wallet_handle).await.unwrap();
}
Expand Down
3 changes: 2 additions & 1 deletion libvcx/src/api_lib/global/agency_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub fn get_main_agency_client() -> VcxResult<AgencyClient> {
}

pub fn create_agency_client_for_main_wallet(config: &AgencyClientConfig) -> VcxResult<()> {
get_main_agency_client_mut()?.configure(config)?;
let client = get_main_agency_client()?.configure(config)?;
set_main_agency_client(client);
get_main_agency_client_mut()?.set_wallet_handle(get_main_wallet_handle());
Ok(())
}
Expand Down

0 comments on commit 6f163ef

Please sign in to comment.