Don't use TestPlan's rng in fake LSP handlers

These should use the test context's rng, so that they behave the same whether
a pre-recorded plan was used, or the plan is being generated.
This commit is contained in:
Max Brunsfeld 2023-04-05 17:50:04 -07:00
parent 2d63ed3ca4
commit 1064b14779
2 changed files with 30 additions and 20 deletions

View file

@ -829,6 +829,16 @@ impl Background {
}
}
#[cfg(any(test, feature = "test-support"))]
pub fn rng<'a>(&'a self) -> impl 'a + std::ops::DerefMut<Target = rand::prelude::StdRng> {
match self {
Self::Deterministic { executor, .. } => {
parking_lot::lock_api::MutexGuard::map(executor.state.lock(), |s| &mut s.rng)
}
_ => panic!("this method can only be called on a deterministic executor"),
}
}
#[cfg(any(test, feature = "test-support"))]
pub async fn simulate_random_delay(&self) {
match self {