Fix crash in server due to overeager parsing
All checks were successful
Build library & run tests / build (unix) (push) Successful in 29s
Build library & run tests / build (tcp) (push) Successful in 29s

This commit is contained in:
2024-06-24 15:58:54 +02:00
parent fc570fa0bd
commit bf183a0598
2 changed files with 29 additions and 16 deletions

View File

@@ -53,29 +53,42 @@ impl TestProtocolServerTrait for TrivialServer {
async fn void(&mut self) {}
}
struct Cleanup {
address: String,
}
impl Drop for Cleanup {
fn drop(&mut self) {
std::fs::remove_file(&self.address).unwrap();
}
}
#[tokio::test]
async fn e2e() {
init_logger();
#[cfg(feature = "unix")]
let address = "/tmp/eagle-test.sock";
let address = format!("/tmp/eagle-test-{}.sock", rand::random::<u64>());
#[cfg(feature = "unix")]
let _cleanup = Cleanup {
address: address.clone(),
};
#[cfg(feature = "tcp")]
let address = format!("127.0.0.1:{}", 10000 + rand::random::<u64>() % 1000);
let server_task = tokio::spawn(TestProtocolServer::bind(TrivialServer, address.clone()));
// Wait for the server to start
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
let client = TestProtocolClient::connect(address).await.unwrap();
let res = client.addition(2, 5).await.unwrap();
// assert_eq!(client.addition(2, 5).await.unwrap(), 7);
// assert_eq!(
// client.some_kind_of_question("Hello, world!".to_string())
// .await
// .unwrap(),
// "Hello, world!".len() as i32
// );
// assert_eq!(
// client.this_responds_with_a_string(42).await.unwrap(),
// "The number is 42"
// );
// client.void().await.unwrap();
// server_task.abort();
assert_eq!(client.addition(2, 5).await.unwrap(), 7);
assert_eq!(
client
.some_kind_of_question("Hello, world!".to_string())
.await
.unwrap(),
"Hello, world!".len() as i32
);
assert_eq!(
client.this_responds_with_a_string(42).await.unwrap(),
"The number is 42"
);
client.void().await.unwrap();
server_task.abort();
}