diff --git a/src/securejoin.rs b/src/securejoin.rs index af255c083..d969ca09c 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -941,12 +941,21 @@ mod tests { use crate::chatlist::Chatlist; use crate::constants::Chattype; use crate::peerstate::Peerstate; - use crate::test_utils::TestContext; + use crate::test_utils::{LogSink, TestContext}; #[async_std::test] async fn test_setup_contact() -> Result<()> { - let alice = TestContext::new_alice().await; - let bob = TestContext::new_bob().await; + let (log_tx, _log_sink) = LogSink::create(); + let alice = TestContext::builder() + .configure_alice() + .with_log_sink(log_tx.clone()) + .build() + .await; + let bob = TestContext::builder() + .configure_bob() + .with_log_sink(log_tx) + .build() + .await; assert_eq!(Chatlist::try_load(&alice, 0, None, None).await?.len(), 0); assert_eq!(Chatlist::try_load(&bob, 0, None, None).await?.len(), 0); @@ -1133,8 +1142,17 @@ mod tests { #[async_std::test] async fn test_setup_contact_bob_knows_alice() -> Result<()> { - let alice = TestContext::new_alice().await; - let bob = TestContext::new_bob().await; + let (log_tx, _log_sink) = LogSink::create(); + let alice = TestContext::builder() + .configure_alice() + .with_log_sink(log_tx.clone()) + .build() + .await; + let bob = TestContext::builder() + .configure_bob() + .with_log_sink(log_tx) + .build() + .await; // Ensure Bob knows Alice_FP let alice_pubkey = SignedPublicKey::load_self(&alice.ctx).await?; @@ -1257,8 +1275,17 @@ mod tests { #[async_std::test] async fn test_setup_contact_concurrent_calls() -> Result<()> { - let alice = TestContext::new_alice().await; - let bob = TestContext::new_bob().await; + let (log_tx, _log_sink) = LogSink::create(); + let alice = TestContext::builder() + .configure_alice() + .with_log_sink(log_tx.clone()) + .build() + .await; + let bob = TestContext::builder() + .configure_bob() + .with_log_sink(log_tx) + .build() + .await; // do a scan that is not working as claire is never responding let qr_stale = "OPENPGP4FPR:1234567890123456789012345678901234567890#a=claire%40foo.de&n=&i=12345678901&s=23456789012"; @@ -1287,8 +1314,17 @@ mod tests { #[async_std::test] async fn test_secure_join() -> Result<()> { - let alice = TestContext::new_alice().await; - let bob = TestContext::new_bob().await; + let (log_tx, _log_sink) = LogSink::create(); + let alice = TestContext::builder() + .configure_alice() + .with_log_sink(log_tx.clone()) + .build() + .await; + let bob = TestContext::builder() + .configure_bob() + .with_log_sink(log_tx) + .build() + .await; assert_eq!(Chatlist::try_load(&alice, 0, None, None).await?.len(), 0); assert_eq!(Chatlist::try_load(&bob, 0, None, None).await?.len(), 0); diff --git a/src/test_utils.rs b/src/test_utils.rs index dc9a5569d..1ba9d9650 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -570,7 +570,7 @@ pub struct LogSink { impl LogSink { /// Creates a new [`LogSink`] and returns the attached event sink. - fn create() -> (Sender, Self) { + pub fn create() -> (Sender, Self) { let (tx, rx) = channel::unbounded(); (tx, Self { events: rx }) }