use super::*;
use crate::spawn::SpawnOptions;
use shep_core::protocol::codec;
use std::path::Path;
use std::time::Duration;
use tokio_util::codec::Framed;
#[must_use]
pub fn fast_opts() -> SpawnOptions {
SpawnOptions {
deadline: Duration::from_millis(600),
backoff_start: Duration::from_millis(10),
backoff_cap: Duration::from_millis(50),
handshake_timeout: Duration::from_millis(100),
}
}
pub fn start_fake_daemon_answering_on(path: &Path) {
let mut listener = bind(path);
tokio::spawn(async move {
let stream = listener.accept().await.unwrap();
let mut frames = Framed::new(stream, codec());
let _hello = handshake(&mut frames, sample_ack()).await;
core::future::pending::<()>().await;
});
}
pub fn child_exiting_with(code: i32) -> std::io::Result<std::process::Child> {
std::process::Command::new("sh")
.args(["-c", &format!("exit {code}")])
.spawn()
}