Move over EvTracker to a normal event sender

I considered removing it from the context by default, but the
migration test really wants to have the tracker initialised from the
very first event and not after the context is initialised.  It is
easier for now to leave it hardcoded instead of adding an API to
explicitly require enabling it via the builder.
This commit is contained in:
Floris Bruynooghe
2021-12-15 22:14:08 +01:00
parent 147f5c1e0d
commit 9a02a58273
4 changed files with 68 additions and 63 deletions

View File

@@ -4684,14 +4684,18 @@ Second thread."#;
let chat = chat::Chat::load_from_db(&t, msg.chat_id).await?;
assert!(chat.is_contact_request());
let duration = std::time::Duration::from_secs(1);
loop {
let event = async_std::future::timeout(duration, t.evtracker.recv()).await??;
if let EventType::IncomingMsg { chat_id, msg_id } = &event {
assert_eq!(msg.chat_id, *chat_id);
assert_eq!(msg.id, *msg_id);
return Ok(());
let event = t
.evtracker
.get_matching(|evt| matches!(evt, EventType::IncomingMsg { .. }))
.await;
match event {
EventType::IncomingMsg { chat_id, msg_id } => {
assert_eq!(msg.chat_id, chat_id);
assert_eq!(msg.id, msg_id);
return Ok(());
}
_ => unreachable!(),
}
}
}