mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Use the LogSink explicitly in securejoin tests
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -570,7 +570,7 @@ pub struct LogSink {
|
||||
|
||||
impl LogSink {
|
||||
/// Creates a new [`LogSink`] and returns the attached event sink.
|
||||
fn create() -> (Sender<Event>, Self) {
|
||||
pub fn create() -> (Sender<Event>, Self) {
|
||||
let (tx, rx) = channel::unbounded();
|
||||
(tx, Self { events: rx })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user