federation-send-parallel
phiresky 2024-06-29 19:29:35 +02:00
parent 76c6487390
commit 0f5b69cffc
3 changed files with 7 additions and 13 deletions

View File

@ -70,7 +70,8 @@ impl LemmyContext {
let rate_limit_cell = RateLimitCell::with_test_config();
let context = LemmyContext::create(pool, client, secret, rate_limit_cell.clone());
let config = FederationConfig::builder()
FederationConfig::builder()
.domain(context.settings().hostname.clone())
.app_data(context)
.debug(true)
@ -78,8 +79,7 @@ impl LemmyContext {
.http_fetch_limit(0)
.build()
.await
.expect("build federation config");
return config;
.expect("build federation config")
}
pub async fn init_test_context() -> Data<LemmyContext> {
let config = Self::init_test_federation_config().await;

View File

@ -41,4 +41,4 @@ url.workspace = true
actix-web.workspace = true
tracing-test = "0.2.5"
uuid.workspace = true
test-context = "0.3.0"
test-context = "0.3.0"

View File

@ -422,10 +422,8 @@ mod test {
use std::{fs::File, io::BufReader};
use test_context::{test_context, AsyncTestContext};
use tokio::{
select,
spawn,
sync::mpsc::{error::TryRecvError, unbounded_channel, UnboundedReceiver},
task::JoinHandle,
};
use tracing_test::traced_test;
use url::Url;
@ -462,8 +460,7 @@ mod test {
let (inbox_sender, inbox_receiver) = unbounded_channel();
// listen for received activities in background
let cancel_ = cancel.clone();
let wait_stop_server = listen_activities(inbox_sender, cancel_)?;
let wait_stop_server = listen_activities(inbox_sender)?;
let fed_config = FederationWorkerConfig {
concurrent_sends_per_instance: 1,
@ -578,10 +575,7 @@ mod test {
Ok(())
}
fn listen_activities(
inbox_sender: UnboundedSender<String>,
cancel: CancellationToken,
) -> LemmyResult<ServerHandle> {
fn listen_activities(inbox_sender: UnboundedSender<String>) -> LemmyResult<ServerHandle> {
let run = HttpServer::new(move || {
App::new()
.app_data(actix_web::web::Data::new(inbox_sender.clone()))
@ -616,7 +610,7 @@ mod test {
let form = SentActivityForm {
ap_id: Url::parse(&format!(
"http://local.com/activity/{}",
uuid::Uuid::new_v4().to_string()
uuid::Uuid::new_v4()
))?
.into(),
data: serde_json::from_reader(reader)?,