Simplify management of entity ids for different app contexts in randomized test

This commit is contained in:
Max Brunsfeld 2023-01-12 14:30:10 -08:00
parent a3c7416218
commit 00e8625037

View file

@ -105,7 +105,6 @@ async fn test_random_collaboration(
let mut clients = Vec::new(); let mut clients = Vec::new();
let mut client_tasks = Vec::new(); let mut client_tasks = Vec::new();
let mut operation_channels = Vec::new(); let mut operation_channels = Vec::new();
let mut next_entity_id = 100000;
loop { loop {
let Some((next_operation, skipped)) = plan.lock().next_server_operation(&clients) else { break }; let Some((next_operation, skipped)) = plan.lock().next_server_operation(&clients) else { break };
@ -115,7 +114,6 @@ async fn test_random_collaboration(
&mut clients, &mut clients,
&mut client_tasks, &mut client_tasks,
&mut operation_channels, &mut operation_channels,
&mut next_entity_id,
plan.clone(), plan.clone(),
next_operation, next_operation,
cx, cx,
@ -323,7 +321,6 @@ async fn apply_server_operation(
clients: &mut Vec<(Rc<TestClient>, TestAppContext)>, clients: &mut Vec<(Rc<TestClient>, TestAppContext)>,
client_tasks: &mut Vec<Task<()>>, client_tasks: &mut Vec<Task<()>>,
operation_channels: &mut Vec<futures::channel::mpsc::UnboundedSender<usize>>, operation_channels: &mut Vec<futures::channel::mpsc::UnboundedSender<usize>>,
next_entity_id: &mut usize,
plan: Arc<Mutex<TestPlan>>, plan: Arc<Mutex<TestPlan>>,
operation: Operation, operation: Operation,
cx: &mut TestAppContext, cx: &mut TestAppContext,
@ -341,15 +338,15 @@ async fn apply_server_operation(
username = user.username.clone(); username = user.username.clone();
}; };
log::info!("Adding new connection for {}", username); log::info!("Adding new connection for {}", username);
*next_entity_id += 100000; let next_entity_id = (user_id.0 * 10_000) as usize;
let mut client_cx = TestAppContext::new( let mut client_cx = TestAppContext::new(
cx.foreground_platform(), cx.foreground_platform(),
cx.platform(), cx.platform(),
deterministic.build_foreground(*next_entity_id), deterministic.build_foreground(user_id.0 as usize),
deterministic.build_background(), deterministic.build_background(),
cx.font_cache(), cx.font_cache(),
cx.leak_detector(), cx.leak_detector(),
*next_entity_id, next_entity_id,
cx.function_name.clone(), cx.function_name.clone(),
); );