Fix crash in server due to overeager parsing
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user