Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Reduce test flakiness
Alexis Sellier committed 2 years ago
commit a3f8305eb437caa29a65a24a3ec5ab0f0cc80d0e
parent 0319bbb9035f0fe73ab8a7bd8f3791b5ca95b9c9
1 file changed +7 -1
modified radicle-node/src/test/environment.rs
@@ -301,7 +301,13 @@ impl<G: cyphernet::Ecdh<Pk = NodeId> + Signer + Clone> Node<G> {
    pub fn spawn(self, config: service::Config) -> NodeHandle<G> {
        let listen = vec![([0, 0, 0, 0], 0).into()];
        let proxy = net::SocketAddr::new(net::Ipv4Addr::LOCALHOST.into(), 9050);
-
        let daemon = ([0, 0, 0, 0], fastrand::u16(1025..)).into();
+
        let daemon: net::SocketAddr = {
+
            // Find free port for git-daemon to bind to.
+
            // This is a somewhat racy solution, though it works much better than assigning a random
+
            // port.
+
            let sock = net::TcpListener::bind("0.0.0.0:0").unwrap();
+
            ([0, 0, 0, 0], sock.local_addr().unwrap().port()).into()
+
        };
        let (_, signals) = chan::bounded(1);
        let rt = Runtime::init(
            self.home.clone(),