mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 05:46:29 +03:00
test: reproduce #8094
This commit is contained in:
@@ -4,6 +4,7 @@ use pretty_assertions::assert_eq;
|
|||||||
|
|
||||||
use crate::EventType;
|
use crate::EventType;
|
||||||
use crate::chat;
|
use crate::chat;
|
||||||
|
use crate::chat::send_msg;
|
||||||
use crate::contact;
|
use crate::contact;
|
||||||
use crate::download::{DownloadState, PRE_MSG_ATTACHMENT_SIZE_THRESHOLD, PostMsgMetadata};
|
use crate::download::{DownloadState, PRE_MSG_ATTACHMENT_SIZE_THRESHOLD, PostMsgMetadata};
|
||||||
use crate::message::{Message, MessageState, Viewtype, delete_msgs, markseen_msgs};
|
use crate::message::{Message, MessageState, Viewtype, delete_msgs, markseen_msgs};
|
||||||
@@ -13,7 +14,7 @@ use crate::reaction::{get_msg_reactions, send_reaction};
|
|||||||
use crate::summary::assert_summary_texts;
|
use crate::summary::assert_summary_texts;
|
||||||
use crate::test_utils::TestContextManager;
|
use crate::test_utils::TestContextManager;
|
||||||
use crate::tests::pre_messages::util::{
|
use crate::tests::pre_messages::util::{
|
||||||
send_large_file_message, send_large_image_message, send_large_webxdc_message,
|
big_webxdc_app, send_large_file_message, send_large_image_message, send_large_webxdc_message,
|
||||||
};
|
};
|
||||||
use crate::webxdc::StatusUpdateSerial;
|
use crate::webxdc::StatusUpdateSerial;
|
||||||
|
|
||||||
@@ -513,6 +514,40 @@ async fn test_webxdc_update_for_not_downloaded_instance() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tests receiving of a large webxdc with updates attached to the the .xdc message.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_large_webxdc_with_info_update() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let alice = &tcm.alice().await;
|
||||||
|
let bob = &tcm.bob().await;
|
||||||
|
|
||||||
|
let alice_chat_id = alice.create_chat_id(bob).await;
|
||||||
|
|
||||||
|
let big_webxdc_app = big_webxdc_app().await?;
|
||||||
|
|
||||||
|
let mut alice_instance = Message::new(Viewtype::Webxdc);
|
||||||
|
alice_instance.set_file_from_bytes(alice, "test.xdc", &big_webxdc_app, None)?;
|
||||||
|
alice_instance.set_text("Test".to_string());
|
||||||
|
alice_chat_id
|
||||||
|
.set_draft(alice, Some(&mut alice_instance))
|
||||||
|
.await?;
|
||||||
|
alice
|
||||||
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload":42, "info":"i"}"#)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let _alice_instance_id = send_msg(alice, alice_chat_id, &mut alice_instance).await?;
|
||||||
|
let post_message = alice.pop_sent_msg().await;
|
||||||
|
let pre_message = alice.pop_sent_msg().await;
|
||||||
|
|
||||||
|
let bob_instance = bob.recv_msg(&pre_message).await;
|
||||||
|
assert_eq!(bob_instance.download_state, DownloadState::Available);
|
||||||
|
bob.recv_msg_trash(&post_message).await;
|
||||||
|
let bob_instance = Message::load_from_db(bob, bob_instance.id).await?;
|
||||||
|
assert_eq!(bob_instance.download_state, DownloadState::Done);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Test mark seen pre-message
|
/// Test mark seen pre-message
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_markseen_pre_msg() -> Result<()> {
|
async fn test_markseen_pre_msg() -> Result<()> {
|
||||||
|
|||||||
@@ -37,10 +37,7 @@ pub async fn send_large_file_message<'a>(
|
|||||||
Ok((pre_message.to_owned(), post_message.to_owned(), msg_id))
|
Ok((pre_message.to_owned(), post_message.to_owned(), msg_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_large_webxdc_message<'a>(
|
pub async fn big_webxdc_app() -> Result<Vec<u8>> {
|
||||||
sender: &'a TestContext,
|
|
||||||
target_chat: ChatId,
|
|
||||||
) -> Result<(SentMessage<'a>, SentMessage<'a>, MsgId)> {
|
|
||||||
let futures_cursor = FuturesCursor::new(Vec::new());
|
let futures_cursor = FuturesCursor::new(Vec::new());
|
||||||
let mut buffer = futures_cursor.compat_write();
|
let mut buffer = futures_cursor.compat_write();
|
||||||
let mut writer = ZipFileWriter::with_tokio(&mut buffer);
|
let mut writer = ZipFileWriter::with_tokio(&mut buffer);
|
||||||
@@ -51,7 +48,14 @@ pub async fn send_large_webxdc_message<'a>(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
writer.close().await?;
|
writer.close().await?;
|
||||||
let big_webxdc_app = buffer.into_inner().into_inner();
|
Ok(buffer.into_inner().into_inner())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_large_webxdc_message<'a>(
|
||||||
|
sender: &'a TestContext,
|
||||||
|
target_chat: ChatId,
|
||||||
|
) -> Result<(SentMessage<'a>, SentMessage<'a>, MsgId)> {
|
||||||
|
let big_webxdc_app = big_webxdc_app().await?;
|
||||||
send_large_file_message(sender, target_chat, Viewtype::Webxdc, &big_webxdc_app).await
|
send_large_file_message(sender, target_chat, Viewtype::Webxdc, &big_webxdc_app).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user