Skip to content

Commit d839777

Browse files
committed
test: Message sent from future shall not stick to the bottom (#8027)
Currently this fails, so if the user fixes their clock incorrectly set to the future, they need to delete previously sent messages or wait until this future comes again.
1 parent ec5117a commit d839777

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/chat/chat_tests.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,6 +5034,33 @@ async fn test_do_not_overwrite_draft() -> Result<()> {
50345034
Ok(())
50355035
}
50365036

5037+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5038+
async fn test_outgoing_msg_after_another_from_future() -> Result<()> {
5039+
let mut tcm = TestContextManager::new();
5040+
let t = &tcm.alice().await;
5041+
let chat_id = t.get_self_chat().await.id;
5042+
// Simulate sending a message with clock set to the future.
5043+
let msg_id = send_text_msg(t, chat_id, "test".to_string()).await?;
5044+
t.sql
5045+
.execute(
5046+
"UPDATE msgs SET timestamp=timestamp+3600 WHERE id=?",
5047+
(msg_id,),
5048+
)
5049+
.await?;
5050+
let timestamp_sent: i64 = t
5051+
.sql
5052+
.query_get_value("SELECT timestamp_sent FROM msgs WHERE id=?", (msg_id,))
5053+
.await?
5054+
.unwrap();
5055+
// Let's have a check here that locally sent messages have zero `timestamp_sent`, it can be a
5056+
// useful invariant.
5057+
assert_eq!(timestamp_sent, 0);
5058+
5059+
let msg_id = send_text_msg(t, chat_id, "Fixed my clock".to_string()).await?;
5060+
assert_eq!(t.get_last_msg_in(chat_id).await.id, msg_id);
5061+
Ok(())
5062+
}
5063+
50375064
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
50385065
async fn test_info_contact_id() -> Result<()> {
50395066
let mut tcm = TestContextManager::new();

0 commit comments

Comments
 (0)