Skip to content

Commit

Permalink
Remove TestTransport
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 Sep 12, 2023
1 parent 54a4a7c commit 134c147
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
14 changes: 14 additions & 0 deletions aries_vcx/src/protocols/connection/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::{
trait_bounds::{TheirDidDoc, ThreadId},
},
transport::Transport,
utils::encryption_envelope::EncryptionEnvelope,
};

use super::{trait_bounds::BootstrapDidDoc, wrap_and_send_msg};
Expand Down Expand Up @@ -173,6 +174,19 @@ impl GenericConnection {
}
}

pub async fn encrypt_message(
&self,
wallet: &Arc<dyn BaseWallet>,
message: &AriesMessage,
) -> VcxResult<EncryptionEnvelope> {
let sender_verkey = &self.pairwise_info().pw_vk;
let did_doc = self.their_did_doc().ok_or(AriesVcxError::from_msg(
AriesVcxErrorKind::NotReady,
"No DidDoc present",
))?;
EncryptionEnvelope::create(wallet, message, Some(sender_verkey), did_doc).await
}

pub async fn send_message<T>(
&self,
wallet: &Arc<dyn BaseWallet>,
Expand Down
15 changes: 6 additions & 9 deletions aries_vcx/tests/test_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use aries_vcx::common::ledger::transactions::write_endpoint_legacy;
use aries_vcx::protocols::connection::GenericConnection;
use aries_vcx::protocols::mediated_connection::pairwise_info::PairwiseInfo;
use aries_vcx::utils::encryption_envelope::EncryptionEnvelope;
use async_channel::bounded;

use aries_vcx::utils::devsetup::*;
use chrono::Utc;
Expand All @@ -23,7 +22,6 @@ use crate::utils::scenarios::{
create_connections_via_oob_invite, create_connections_via_pairwise_invite, create_connections_via_public_invite,
};
use crate::utils::test_agent::{create_test_agent, create_test_agent_trustee};
use crate::utils::transport_trait::TestTransport;

fn build_basic_message(content: String) -> BasicMessage {
let now = Utc::now();
Expand Down Expand Up @@ -56,17 +54,16 @@ async fn decrypt_message(
async fn send_and_receive_message(
consumer: &TestAgent,
insitution: &TestAgent,
institatuion_to_consumer: &GenericConnection,
institution_to_consumer: &GenericConnection,
consumer_to_institution: &GenericConnection,
message: &AriesMessage,
) -> AriesMessage {
let (sender, receiver) = bounded::<Vec<u8>>(1);
institatuion_to_consumer
.send_message(&insitution.profile.inject_wallet(), message, &TestTransport { sender })
let encrypted_message = institution_to_consumer
.encrypt_message(&insitution.profile.inject_wallet(), message)
.await
.unwrap();
let received = receiver.recv().await.unwrap();
decrypt_message(consumer, received, consumer_to_institution).await
.unwrap()
.0;
decrypt_message(consumer, encrypted_message, consumer_to_institution).await
}

async fn create_service(faber: &TestAgent) {
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ pub mod migration;
pub mod scenarios;
pub mod test_agent;
pub mod test_macros;
pub mod transport_trait;
17 changes: 0 additions & 17 deletions aries_vcx/tests/utils/transport_trait.rs

This file was deleted.

0 comments on commit 134c147

Please sign in to comment.