fix upx and udp conn counter (#131)

* fix upx in workflow
* fix udp conn counter
This commit is contained in:
Sijie.Sun
2024-06-04 18:50:30 +08:00
committed by GitHub
parent df17a7bb68
commit f9e6264f31
10 changed files with 158 additions and 136 deletions

View File

@@ -419,7 +419,7 @@ pub fn reserve_buf(buf: &mut BytesMut, min_size: usize, max_size: usize) {
pub mod tests {
use std::time::Instant;
use futures::{SinkExt, StreamExt, TryStreamExt};
use futures::{Future, SinkExt, StreamExt, TryStreamExt};
use tokio_util::bytes::{BufMut, Bytes, BytesMut};
use crate::{
@@ -595,4 +595,19 @@ pub mod tests {
.with_env_filter(filter)
.init();
}
pub async fn wait_for_condition<F, FRet>(mut condition: F, timeout: std::time::Duration) -> ()
where
F: FnMut() -> FRet + Send,
FRet: Future<Output = bool>,
{
let now = std::time::Instant::now();
while now.elapsed() < timeout {
if condition().await {
return;
}
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
}
assert!(condition().await, "Timeout")
}
}