mirror of https://github.com/rapiz1/rathole.git
ci: don't publish unless release is successful
fix: fix test_udp_connect for `cross`
This commit is contained in:
parent
9ad61b5fdc
commit
25a737b10e
|
@ -102,6 +102,7 @@ jobs:
|
|||
docker:
|
||||
name: Publish to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
@ -119,6 +120,7 @@ jobs:
|
|||
publish-crate:
|
||||
name: Publish to crates.io
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
|
|
|
@ -82,8 +82,6 @@ pub fn floor_to_pow_of_2(x: usize) -> usize {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
use crate::helper::{floor_to_pow_of_2, log2_floor};
|
||||
|
||||
use super::udp_connect;
|
||||
|
@ -127,29 +125,4 @@ mod test {
|
|||
assert_eq!(floor_to_pow_of_2(t.0), t.1);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_udp_connect() {
|
||||
let hello = "HELLO";
|
||||
|
||||
let t = [("0.0.0.0:2333", "127.0.0.1:2333"), (":::2333", "::1:2333")];
|
||||
for t in t {
|
||||
let listener = UdpSocket::bind(t.0).await.unwrap();
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
let s = udp_connect(t.1).await.unwrap();
|
||||
s.send(hello.as_bytes()).await.unwrap();
|
||||
let mut buf = [0u8; 16];
|
||||
let n = s.recv(&mut buf).await.unwrap();
|
||||
assert_eq!(&buf[..n], hello.as_bytes());
|
||||
});
|
||||
|
||||
let mut buf = [0u8; 16];
|
||||
let (n, addr) = listener.recv_from(&mut buf).await.unwrap();
|
||||
assert_eq!(&buf[..n], hello.as_bytes());
|
||||
listener.send_to(&buf[..n], addr).await.unwrap();
|
||||
|
||||
handle.await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue