refactor: use SampleString

This commit is contained in:
link2xt
2025-10-27 17:41:39 +00:00
committed by l
parent 4abc695790
commit 21caf87119

View File

@@ -1,4 +1,3 @@
use rand::Rng;
use std::time::Duration;
use tokio::fs;
@@ -20,6 +19,8 @@ use crate::test_utils::{
};
use crate::tools::{SystemTime, time};
use rand::distr::SampleString;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_outgoing() -> Result<()> {
let context = TestContext::new_alice().await;
@@ -4339,11 +4340,8 @@ async fn test_download_later() -> Result<()> {
let bob_chat = bob.create_chat(&alice).await;
// Generate a random string so OpenPGP does not compress it.
let text: String = rand::rng()
.sample_iter(&rand::distr::Alphanumeric)
.take(MIN_DOWNLOAD_LIMIT as usize)
.map(char::from)
.collect();
let text =
rand::distr::Alphanumeric.sample_string(&mut rand::rng(), MIN_DOWNLOAD_LIMIT as usize);
let sent_msg = bob.send_text(bob_chat.id, &text).await;
let msg = alice.recv_msg(&sent_msg).await;