Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder pattern in agency client configuration #588

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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