Skip to content

Commit 3c618ee

Browse files
authored
Rename connection -> mediated_connection in api_lib (#658)
* Rename connection -> mediated_connection in api_lib * Rename in wrapper Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
1 parent 34dba47 commit 3c618ee

26 files changed

+107
-107
lines changed

libvcx/src/api_lib/api_c/credential.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use futures::future::BoxFuture;
44
use libc::c_char;
55

66
use aries_vcx::error::{VcxError, VcxErrorKind};
7-
use aries_vcx::vdrtools_sys::CommandHandle;
87
use aries_vcx::utils::error;
8+
use aries_vcx::vdrtools_sys::CommandHandle;
99

1010
use crate::api_lib::api_handle::credential;
1111
use crate::api_lib::utils::cstring::CStringUtils;
@@ -1223,8 +1223,8 @@ mod tests {
12231223
ARIES_CREDENTIAL_OFFER, ARIES_CREDENTIAL_RESPONSE, CREDENTIAL_SM_FINISHED,
12241224
};
12251225

1226-
use crate::api_lib::api_handle::connection;
12271226
use crate::api_lib::api_handle::credential::tests::BAD_CREDENTIAL_OFFER;
1227+
use crate::api_lib::api_handle::mediated_connection;
12281228
use crate::api_lib::utils::return_types_u32;
12291229
use crate::api_lib::utils::timeout::TimeoutUtils;
12301230

@@ -1300,7 +1300,7 @@ mod tests {
13001300
async fn test_vcx_credential_get_new_offers() {
13011301
let _setup = SetupMocks::init();
13021302

1303-
let handle_conn = connection::tests::build_test_connection_invitee_completed();
1303+
let handle_conn = mediated_connection::tests::build_test_connection_invitee_completed();
13041304

13051305
let cb = return_types_u32::Return_U32_STR::new().unwrap();
13061306
assert_eq!(
@@ -1315,7 +1315,7 @@ mod tests {
13151315
async fn test_vcx_credential_create() {
13161316
let _setup = SetupMocks::init();
13171317

1318-
let handle_conn = connection::tests::build_test_connection_invitee_completed();
1318+
let handle_conn = mediated_connection::tests::build_test_connection_invitee_completed();
13191319

13201320
let cb = return_types_u32::Return_U32_U32_STR::new().unwrap();
13211321
assert_eq!(
@@ -1354,7 +1354,7 @@ mod tests {
13541354
async fn test_vcx_credential_update_state() {
13551355
let _setup = SetupMocks::init();
13561356

1357-
let handle_conn = connection::tests::build_test_connection_inviter_requested().await;
1357+
let handle_conn = mediated_connection::tests::build_test_connection_inviter_requested().await;
13581358

13591359
let handle_cred = _vcx_credential_create_with_offer_c_closure(ARIES_CREDENTIAL_OFFER).unwrap();
13601360
assert_eq!(

libvcx/src/api_lib/api_c/disclosed_proof.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ mod tests {
11481148
use aries_vcx::utils::mockdata::mockdata_credex::ARIES_CREDENTIAL_REQUEST;
11491149
use aries_vcx::utils::mockdata::mockdata_proof::ARIES_PROOF_REQUEST_PRESENTATION;
11501150

1151-
use crate::api_lib::api_handle::connection;
1151+
use crate::api_lib::api_handle::mediated_connection;
11521152
use crate::api_lib::utils::return_types_u32;
11531153
use crate::api_lib::utils::timeout::TimeoutUtils;
11541154
use crate::aries_vcx::protocols::proof_presentation::prover::state_machine::ProverState;
@@ -1194,7 +1194,7 @@ mod tests {
11941194
async fn test_create_with_msgid() {
11951195
let _setup = SetupMocks::init();
11961196

1197-
let cxn = connection::tests::build_test_connection_inviter_requested().await;
1197+
let cxn = mediated_connection::tests::build_test_connection_inviter_requested().await;
11981198

11991199
let cb = return_types_u32::Return_U32_U32_STR::new().unwrap();
12001200
assert_eq!(
@@ -1298,7 +1298,7 @@ mod tests {
12981298
ProverState::PresentationRequestReceived as u32
12991299
);
13001300

1301-
let handle_conn = connection::tests::build_test_connection_inviter_requested().await;
1301+
let handle_conn = mediated_connection::tests::build_test_connection_inviter_requested().await;
13021302

13031303
let cb = return_types_u32::Return_U32::new().unwrap();
13041304
assert_eq!(
@@ -1319,7 +1319,7 @@ mod tests {
13191319
ProverState::PresentationRequestReceived as u32
13201320
);
13211321

1322-
let connection_handle = connection::tests::build_test_connection_inviter_requested().await;
1322+
let connection_handle = mediated_connection::tests::build_test_connection_inviter_requested().await;
13231323

13241324
let cb = return_types_u32::Return_U32::new().unwrap();
13251325
assert_eq!(
@@ -1342,7 +1342,7 @@ mod tests {
13421342
ProverState::PresentationRequestReceived as u32
13431343
);
13441344

1345-
let _connection_handle = connection::tests::build_test_connection_inviter_requested().await;
1345+
let _connection_handle = mediated_connection::tests::build_test_connection_inviter_requested().await;
13461346

13471347
let cb = return_types_u32::Return_U32_STR::new().unwrap();
13481348
assert_eq!(
@@ -1357,7 +1357,7 @@ mod tests {
13571357
async fn test_vcx_proof_get_requests() {
13581358
let _setup = SetupMocks::init();
13591359

1360-
let cxn = connection::tests::build_test_connection_inviter_requested().await;
1360+
let cxn = mediated_connection::tests::build_test_connection_inviter_requested().await;
13611361

13621362
AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE);
13631363
AgencyMockDecrypted::set_next_decrypted_message(ARIES_CREDENTIAL_REQUEST);

libvcx/src/api_lib/api_c/filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mod tests {
8181
use aries_vcx::utils::{constants::GET_MESSAGES_DECRYPTED_RESPONSE, devsetup::*, error, mockdata::mockdata_proof};
8282

8383
use crate::api_lib::api_c::filters::vcx_filter_proof_requests_by_name;
84-
use crate::api_lib::api_handle::connection;
84+
use crate::api_lib::api_handle::mediated_connection;
8585
use crate::api_lib::api_handle::disclosed_proof::get_proof_request_messages;
8686
use crate::api_lib::utils::return_types_u32;
8787
use crate::api_lib::utils::timeout::TimeoutUtils;
@@ -91,7 +91,7 @@ mod tests {
9191
async fn test_vcx_filter_proof_requests_by_name() {
9292
let _setup = SetupMocks::init();
9393

94-
let connection_h = connection::tests::build_test_connection_inviter_requested().await;
94+
let connection_h = mediated_connection::tests::build_test_connection_inviter_requested().await;
9595

9696
AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE);
9797
AgencyMockDecrypted::set_next_decrypted_message(mockdata_proof::PRESENTATION_REQUEST_MESSAGE_1);

libvcx/src/api_lib/api_c/issuer_credential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use futures::future::BoxFuture;
44
use libc::c_char;
55

66
use aries_vcx::error::{VcxError, VcxErrorKind};
7-
use aries_vcx::vdrtools_sys::CommandHandle;
87
use aries_vcx::utils::error;
8+
use aries_vcx::vdrtools_sys::CommandHandle;
99

1010
use crate::api_lib::api_handle::issuer_credential;
1111
use crate::api_lib::utils::cstring::CStringUtils;

libvcx/src/api_lib/api_c/connection.rs renamed to libvcx/src/api_lib/api_c/mediated_connection.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use aries_vcx::vdrtools_sys::CommandHandle;
99
use aries_vcx::indy;
1010
use aries_vcx::utils::error;
1111

12-
use crate::api_lib::api_handle::connection;
13-
use crate::api_lib::api_handle::connection::*;
12+
use crate::api_lib::api_handle::mediated_connection;
13+
use crate::api_lib::api_handle::mediated_connection::*;
1414
use crate::api_lib::global::wallet::get_main_wallet_handle;
1515
use crate::api_lib::utils;
1616
use crate::api_lib::utils::cstring::CStringUtils;
@@ -124,7 +124,7 @@ pub extern "C" fn vcx_generate_public_invite(
124124
);
125125

126126
execute(move || {
127-
match connection::generate_public_invitation(&public_did, &label) {
127+
match mediated_connection::generate_public_invitation(&public_did, &label) {
128128
Ok(public_invite) => {
129129
trace!(
130130
"vcx_generate_public_invite_cb(command_handle: {}, rc: {}, public_invite: {})",
@@ -1129,7 +1129,7 @@ pub extern "C" fn vcx_connection_sign_data(
11291129
);
11301130

11311131
execute_async::<BoxFuture<'static, Result<(), ()>>>(Box::pin(async move {
1132-
let vk = match connection::get_pw_verkey(connection_handle) {
1132+
let vk = match mediated_connection::get_pw_verkey(connection_handle) {
11331133
Ok(err) => err,
11341134
Err(err) => {
11351135
error!(
@@ -1226,7 +1226,7 @@ pub extern "C" fn vcx_connection_verify_signature(
12261226
trace!("vcx_connection_verify_signature: entities >>> connection_handle: {}, data_raw: {:?}, data_len: {}, signature_raw: {:?}, signature_len: {}", connection_handle, data_raw, data_len, signature_raw, signature_len);
12271227

12281228
execute_async::<BoxFuture<'static, Result<(), ()>>>(Box::pin(async move {
1229-
let vk = match connection::get_their_pw_verkey(connection_handle) {
1229+
let vk = match mediated_connection::get_their_pw_verkey(connection_handle) {
12301230
Ok(err) => err,
12311231
Err(err) => {
12321232
error!(
@@ -1595,7 +1595,7 @@ pub extern "C" fn vcx_connection_messages_download(
15951595
);
15961596

15971597
execute_async::<BoxFuture<'static, Result<(), ()>>>(Box::pin(async move {
1598-
match connection::download_messages(connection_handles, message_statuses, uids).await {
1598+
match mediated_connection::download_messages(connection_handles, message_statuses, uids).await {
15991599
Ok(err) => {
16001600
match serde_json::to_string(&err) {
16011601
Ok(err) => {
@@ -1656,7 +1656,7 @@ mod tests {
16561656
ARIES_CONNECTION_ACK, ARIES_CONNECTION_REQUEST, DEFAULT_SERIALIZED_CONNECTION,
16571657
};
16581658

1659-
use crate::api_lib::api_handle::connection::tests::{
1659+
use crate::api_lib::api_handle::mediated_connection::tests::{
16601660
build_test_connection_inviter_invited, build_test_connection_inviter_null,
16611661
build_test_connection_inviter_requested,
16621662
};
@@ -1915,7 +1915,7 @@ mod tests {
19151915
cb.receive(TimeoutUtils::some_medium()).unwrap();
19161916

19171917
assert_eq!(
1918-
connection::get_source_id(connection_handle).unwrap_err().kind(),
1918+
mediated_connection::get_source_id(connection_handle).unwrap_err().kind(),
19191919
VcxErrorKind::InvalidHandle
19201920
);
19211921
}
@@ -1951,7 +1951,7 @@ mod tests {
19511951
async fn test_sign() {
19521952
let _setup = SetupMocks::init();
19531953

1954-
let connection_handle = connection::tests::build_test_connection_inviter_invited().await;
1954+
let connection_handle = mediated_connection::tests::build_test_connection_inviter_invited().await;
19551955

19561956
let msg = format!("My message");
19571957
let msg_len = msg.len();
@@ -1976,7 +1976,7 @@ mod tests {
19761976
async fn test_verify_signature() {
19771977
let _setup = SetupMocks::init();
19781978

1979-
let connection_handle = connection::tests::build_test_connection_inviter_requested().await;
1979+
let connection_handle = mediated_connection::tests::build_test_connection_inviter_requested().await;
19801980

19811981
let msg = format!("My message");
19821982
let msg_len = msg.len();

libvcx/src/api_lib/api_c/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod agent;
2-
pub mod connection;
2+
pub mod mediated_connection;
33
pub mod credential;
44
pub mod credential_def;
55
pub mod disclosed_proof;

libvcx/src/api_lib/api_c/proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ mod tests {
801801
use aries_vcx::utils::mockdata::mock_settings::MockBuilder;
802802
use aries_vcx::utils::mockdata::mockdata_proof;
803803

804-
use crate::api_lib::api_handle::connection::tests::build_test_connection_inviter_requested;
804+
use crate::api_lib::api_handle::mediated_connection::tests::build_test_connection_inviter_requested;
805805
use crate::api_lib::api_handle::proof;
806806
use crate::api_lib::utils::return_types_u32;
807807
use crate::api_lib::utils::timeout::TimeoutUtils;

libvcx/src/api_lib/api_c/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use aries_vcx::global::settings;
2020
use aries_vcx::indy::ledger::transactions::{get_ledger_txn, add_service, get_service};
2121
use crate::api_lib::global::pool::get_main_pool_handle;
2222

23-
use crate::api_lib::api_handle::connection;
24-
use crate::api_lib::api_handle::connection::{parse_connection_handles, parse_status_codes};
23+
use crate::api_lib::api_handle::mediated_connection;
24+
use crate::api_lib::api_handle::mediated_connection::{parse_connection_handles, parse_status_codes};
2525
use crate::api_lib::api_handle::utils::agency_update_messages;
2626
use crate::api_lib::global::agency_client::get_main_agency_client;
2727
use crate::api_lib::global::wallet::get_main_wallet_handle;
@@ -231,7 +231,7 @@ pub extern "C" fn vcx_v2_messages_download(
231231

232232
execute_async::<BoxFuture<'static, Result<(), ()>>>(
233233
async move {
234-
match connection::download_messages(conn_handles, message_statuses, uids).await {
234+
match mediated_connection::download_messages(conn_handles, message_statuses, uids).await {
235235
Ok(err) => {
236236
match serde_json::to_string(&err) {
237237
Ok(err) => {

libvcx/src/api_lib/api_c/vcx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ pub extern "C" fn vcx_shutdown(delete: bool) -> u32 {
311311
};
312312

313313
crate::api_lib::api_handle::schema::release_all();
314-
crate::api_lib::api_handle::connection::release_all();
314+
crate::api_lib::api_handle::mediated_connection::release_all();
315315
crate::api_lib::api_handle::issuer_credential::release_all();
316316
crate::api_lib::api_handle::credential_def::release_all();
317317
crate::api_lib::api_handle::proof::release_all();
@@ -799,7 +799,7 @@ mod tests {
799799

800800
use crate::api_lib;
801801
use crate::api_lib::api_c;
802-
use crate::api_lib::api_c::connection::vcx_connection_create;
802+
use crate::api_lib::api_c::mediated_connection::vcx_connection_create;
803803
use crate::api_lib::api_c::vcx::test_utils::{
804804
_test_add_and_get_wallet_record,
805805
_vcx_create_and_open_wallet, _vcx_create_wallet, _vcx_init_threadpool,
@@ -808,7 +808,7 @@ mod tests {
808808
_vcx_open_wallet,
809809
};
810810
use crate::api_lib::api_handle::{
811-
connection, credential, credential_def, disclosed_proof, issuer_credential, proof, schema,
811+
mediated_connection, credential, credential_def, disclosed_proof, issuer_credential, proof, schema,
812812
};
813813
#[cfg(feature = "pool_tests")]
814814
use crate::api_lib::global::wallet::get_main_wallet_handle;
@@ -1011,7 +1011,7 @@ mod tests {
10111011
let _setup = SetupMocks::init();
10121012

10131013
let data = r#"["name","male"]"#;
1014-
let connection = connection::tests::build_test_connection_inviter_invited().await;
1014+
let connection = mediated_connection::tests::build_test_connection_inviter_invited().await;
10151015
let credentialdef = credential_def::create(
10161016
"SID".to_string(),
10171017
"4fUDR9R7fjwELRvH9JT6HH".to_string(),
@@ -1049,7 +1049,7 @@ mod tests {
10491049

10501050
vcx_shutdown(true);
10511051
assert_eq!(
1052-
connection::release(connection).unwrap_err().kind(),
1052+
mediated_connection::release(connection).unwrap_err().kind(),
10531053
VcxErrorKind::InvalidConnectionHandle
10541054
);
10551055
assert_eq!(

libvcx/src/api_lib/api_handle/credential.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use aries_vcx::{
1212
messages::issuance::credential_offer::CredentialOffer,
1313
};
1414

15-
use crate::api_lib::api_handle::connection;
15+
use crate::api_lib::api_handle::mediated_connection;
1616
use crate::api_lib::api_handle::object_cache::ObjectCache;
1717
use crate::api_lib::global::wallet::get_main_wallet_handle;
1818

@@ -130,7 +130,7 @@ pub async fn update_state(credential_handle: u32, message: Option<&str>, connect
130130
if credential.is_terminal_state() {
131131
return Ok(credential.get_state().into());
132132
}
133-
let send_message = connection::send_message_closure(connection_handle).await?;
133+
let send_message = mediated_connection::send_message_closure(connection_handle).await?;
134134

135135
if let Some(message) = message {
136136
let message: A2AMessage = serde_json::from_str(&message).map_err(|err| {
@@ -143,10 +143,10 @@ pub async fn update_state(credential_handle: u32, message: Option<&str>, connect
143143
.step(wallet_handle, pool_handle, message.into(), Some(send_message))
144144
.await?;
145145
} else {
146-
let messages = connection::get_messages(connection_handle).await?;
146+
let messages = mediated_connection::get_messages(connection_handle).await?;
147147
if let Some((uid, msg)) = credential.find_message_to_handle(messages) {
148148
credential.step(wallet_handle, pool_handle, msg.into(), Some(send_message)).await?;
149-
connection::update_message_status(connection_handle, &uid).await?;
149+
mediated_connection::update_message_status(connection_handle, &uid).await?;
150150
}
151151
}
152152
let state = credential.get_state().into();
@@ -229,8 +229,8 @@ pub async fn send_credential_request(handle: u32, connection_handle: u32) -> Vcx
229229
connection_handle
230230
);
231231
let mut credential = HANDLE_MAP.get_cloned(handle)?;
232-
let my_pw_did = connection::get_pw_did(connection_handle)?;
233-
let send_message = connection::send_message_closure(connection_handle).await?;
232+
let my_pw_did = mediated_connection::get_pw_did(connection_handle)?;
233+
let send_message = mediated_connection::send_message_closure(connection_handle).await?;
234234
credential
235235
.send_request(get_main_wallet_handle(), get_main_pool_handle()?, my_pw_did, send_message)
236236
.await?;
@@ -249,7 +249,7 @@ async fn get_credential_offer_msg(connection_handle: u32, msg_id: &str) -> VcxRe
249249
AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE);
250250
AgencyMockDecrypted::set_next_decrypted_message(ARIES_CREDENTIAL_OFFER);
251251
}
252-
let credential_offer = match connection::get_message_by_id(connection_handle, msg_id).await {
252+
let credential_offer = match mediated_connection::get_message_by_id(connection_handle, msg_id).await {
253253
Ok(message) => match message {
254254
A2AMessage::CredentialOffer(_) => Ok(message),
255255
msg => {
@@ -279,7 +279,7 @@ pub async fn get_credential_offer_messages_with_conn_handle(connection_handle: u
279279
AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE);
280280
AgencyMockDecrypted::set_next_decrypted_message(ARIES_CREDENTIAL_OFFER);
281281

282-
let credential_offers: Vec<A2AMessage> = connection::get_messages(connection_handle)
282+
let credential_offers: Vec<A2AMessage> = mediated_connection::get_messages(connection_handle)
283283
.await?
284284
.into_iter()
285285
.filter_map(|(_, a2a_message)| match a2a_message {
@@ -351,7 +351,7 @@ pub fn get_thread_id(handle: u32) -> VcxResult<String> {
351351

352352
pub async fn decline_offer(handle: u32, connection_handle: u32, comment: Option<&str>) -> VcxResult<u32> {
353353
let mut credential = HANDLE_MAP.get_cloned(handle)?;
354-
let send_message = connection::send_message_closure(connection_handle).await?;
354+
let send_message = mediated_connection::send_message_closure(connection_handle).await?;
355355
credential.decline_offer(comment, send_message).await?;
356356
HANDLE_MAP.insert(handle, credential)?;
357357
Ok(error::SUCCESS.code_num)
@@ -367,7 +367,7 @@ pub mod tests {
367367
ARIES_CREDENTIAL_RESPONSE, CREDENTIAL_SM_FINISHED,
368368
};
369369

370-
use crate::api_lib::api_handle::connection;
370+
use crate::api_lib::api_handle::mediated_connection;
371371
use crate::api_lib::api_handle::credential::{
372372
credential_create_with_offer, get_attributes, get_credential, send_credential_request,
373373
};
@@ -439,7 +439,7 @@ pub mod tests {
439439
let _setup = SetupMocks::init();
440440

441441
info!("full_credential_test:: going to build_test_connection");
442-
let handle_conn = connection::tests::build_test_connection_inviter_requested().await;
442+
let handle_conn = mediated_connection::tests::build_test_connection_inviter_requested().await;
443443

444444
info!("full_credential_test:: going to _get_offer");
445445
let offer = _get_offer(handle_conn).await;
@@ -507,7 +507,7 @@ pub mod tests {
507507
async fn test_get_credential_offer() {
508508
let _setup = SetupMocks::init();
509509

510-
let connection_h = connection::tests::build_test_connection_invitee_completed();
510+
let connection_h = mediated_connection::tests::build_test_connection_invitee_completed();
511511

512512
let offer = get_credential_offer_messages_with_conn_handle(connection_h)
513513
.await

0 commit comments

Comments
 (0)