node: Reduce test flakiness

Most of the test flakiness was caused by the git-daemon not being able
to bind to a port. It seems like using an RNG was not a good enough
solution.

After this change, tests seem to be passing without issue.
This commit is contained in:
Alexis Sellier 2023-06-08 15:44:30 +02:00
parent 0319bbb903
commit a3f8305eb4
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -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(),