Skip to content

Commit

Permalink
refactor(mediator): step1: separate concerns,explicit pathname
Browse files Browse the repository at this point in the history
Signed-off-by: Naian <[email protected]>
  • Loading branch information
nain-F49FF806 committed Oct 18, 2023
1 parent e3a5952 commit 240ea69
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use xum_test_server::storage::MediatorPersistence;
// use super::transports::AriesTransport;
// use diddoc_legacy::aries::service::AriesService;
use super::{transports::AriesTransport, Agent};
use crate::{agent::utils::oob2did, utils::prelude::*};
use crate::{aries_agent::utils::oob2did, utils::prelude::*};
// client role utilities
impl<T: BaseWallet + 'static, P: MediatorPersistence> Agent<T, P> {
/// Starts a new connection object and tries to create request to the specified OOB invite
Expand Down
13 changes: 13 additions & 0 deletions mediator/src/aries_agent/me.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Foo {}
trait Faa {}

struct Obar {}

impl Foo for Obar {}
impl Faa for Obar {}

fn trat() {
let a = Obar {};
tak(a);
}
fn tak(name: &(dyn Foo + Faa)) {}
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ mod test {
use serde_json::Value;

use super::AgentMaker;
use crate::agent::utils::oob2did;
use crate::aries_agent::utils::oob2did;

#[tokio::test]
pub async fn test_pack_unpack() {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion mediator/src/bin/client-tui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use log::info;
/// Aries Agent TUI
use mediator::{agent::AgentMaker, routes::tui};
use mediator::{aries_agent::AgentMaker, http_routes::tui};

#[tokio::main]
async fn main() {
Expand Down
2 changes: 1 addition & 1 deletion mediator/src/bin/client-web.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Client-side focused api accessible Aries Agent
use log::info;
use mediator::{agent::AgentMaker, routes::client::build_client_router};
use mediator::{aries_agent::AgentMaker, http_routes::client::build_client_router};

#[tokio::main]
async fn main() {
Expand Down
4 changes: 2 additions & 2 deletions mediator/src/bin/mediator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use log::info;
use mediator::agent::AgentMaker;
use mediator::aries_agent::AgentMaker;

#[tokio::main]
async fn main() {
Expand All @@ -16,7 +16,7 @@ async fn main() {
)
.await
.unwrap();
let app_router = mediator::routes::build_router(agent).await;
let app_router = mediator::http_routes::build_router(agent).await;
axum::Server::bind(
&endpoint_root
.parse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde_json::json;
use xum_test_server::storage::MediatorPersistence;

use super::*;
use crate::agent::transports::AriesReqwest;
use crate::aries_agent::transports::AriesReqwest;

pub async fn handle_register(
State(agent): State<ArcAgent<impl BaseWallet + 'static, impl MediatorPersistence>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use xum_test_server::{
storage::MediatorPersistence,
};

use crate::{agent::Agent, utils::string_from_std_error};
use crate::{aries_agent::Agent, utils::string_from_std_error};
type ArcAgent<T, P> = Arc<Agent<T, P>>;

pub mod client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use log::info;
use messages::msg_fields::protocols::out_of_band::invitation::Invitation as OOBInvitation;
use xum_test_server::storage::MediatorPersistence;

use crate::{agent::Agent, routes::client::handle_register};
use crate::{aries_agent::Agent, http_routes::client::handle_register};

pub async fn init_tui<T: BaseWallet + 'static, P: MediatorPersistence>(agent: Agent<T, P>) {
let mut cursive = Cursive::new();
Expand Down
4 changes: 2 additions & 2 deletions mediator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod agent;
pub mod routes;
pub mod aries_agent;
pub mod http_routes;
pub mod utils;
4 changes: 2 additions & 2 deletions mediator/tests/mediator-aries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod common;
use std::collections::VecDeque;

use common::{prelude::*, test_setup::OneTimeInit};
use mediator::agent::transports::AriesReqwest;
use mediator::aries_agent::transports::AriesReqwest;
use messages::msg_fields::protocols::out_of_band::invitation::Invitation as OOBInvitation;
use reqwest::header::ACCEPT;

Expand Down Expand Up @@ -39,7 +39,7 @@ async fn didcomm_connection_succeeds() -> Result<()> {
.json()
.await?;
info!("Got invitation from register endpoint {:?}", oobi);
let agent = mediator::agent::AgentMaker::new_demo_agent().await?;
let agent = mediator::aries_agent::AgentMaker::new_demo_agent().await?;
let mut aries_transport = AriesReqwest {
response_queue: VecDeque::new(),
client: reqwest::Client::new(),
Expand Down
12 changes: 6 additions & 6 deletions mediator/tests/mediator-coord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use aries_vcx::protocols::connection::invitee::{states::completed::Completed, In
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use common::{prelude::*, test_setup::OneTimeInit};
use mediator::{
agent::{
aries_agent::{
transports::{AriesReqwest, AriesTransport},
Agent,
},
Expand Down Expand Up @@ -65,7 +65,7 @@ async fn didcomm_connection(
#[ignore]
async fn test_init() {
TestSetupAries.init();
let agent = mediator::agent::AgentMaker::new_demo_agent().await.unwrap();
let agent = mediator::aries_agent::AgentMaker::new_demo_agent().await.unwrap();
let mut aries_transport = AriesReqwest {
response_queue: VecDeque::new(),
client: reqwest::Client::new(),
Expand All @@ -77,7 +77,7 @@ async fn test_init() {
#[tokio::test]
async fn test_mediate_grant() -> Result<()> {
TestSetupAries.init();
let agent = mediator::agent::AgentMaker::new_demo_agent().await?;
let agent = mediator::aries_agent::AgentMaker::new_demo_agent().await?;
let mut aries_transport = AriesReqwest {
response_queue: VecDeque::new(),
client: reqwest::Client::new(),
Expand Down Expand Up @@ -131,7 +131,7 @@ async fn test_mediate_grant() -> Result<()> {
async fn test_mediate_keylist_update_add() -> Result<()> {
TestSetupAries.init();
// ready agent, http client
let agent = mediator::agent::AgentMaker::new_demo_agent().await?;
let agent = mediator::aries_agent::AgentMaker::new_demo_agent().await?;
let mut aries_transport = AriesReqwest {
response_queue: VecDeque::new(),
client: reqwest::Client::new(),
Expand Down Expand Up @@ -187,7 +187,7 @@ async fn test_mediate_keylist_update_add() -> Result<()> {
async fn test_mediate_keylist_query() -> Result<()> {
TestSetupAries.init();
// ready agent, http client
let agent = mediator::agent::AgentMaker::new_demo_agent().await?;
let agent = mediator::aries_agent::AgentMaker::new_demo_agent().await?;
let mut aries_transport = AriesReqwest {
response_queue: VecDeque::new(),
client: reqwest::Client::new(),
Expand Down Expand Up @@ -275,7 +275,7 @@ async fn test_mediate_keylist_query() -> Result<()> {
async fn test_mediate_keylist_update_remove() -> Result<()> {
TestSetupAries.init();
// ready agent, http client
let agent = mediator::agent::AgentMaker::new_demo_agent().await?;
let agent = mediator::aries_agent::AgentMaker::new_demo_agent().await?;
let mut aries_transport = AriesReqwest {
response_queue: VecDeque::new(),
client: reqwest::Client::new(),
Expand Down

0 comments on commit 240ea69

Please sign in to comment.