From 1b2e9122d50c1da4c7ae6200a67352a024a28eb5 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Mon, 15 Oct 2018 14:34:11 -0600 Subject: [PATCH] Pubsub listen on random open port when rpc does (quiet some test errors) --- src/fullnode.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fullnode.rs b/src/fullnode.rs index e9b2443598..de604d110a 100644 --- a/src/fullnode.rs +++ b/src/fullnode.rs @@ -274,7 +274,8 @@ impl Fullnode { // Use custom RPC port, if provided (`Some(port)`) // RPC port may be any open port on the node // If rpc_port == `None`, node will listen on the default RPC_PORT from Rpc module - // If rpc_port == `Some(0)`, node will dynamically choose any open port. Useful for tests. + // If rpc_port == `Some(0)`, node will dynamically choose any open port for both + // Rpc and RpcPubsub serivces. Useful for tests. let rpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::from(0)), rpc_port.unwrap_or(RPC_PORT)); // TODO: The RPC service assumes that there is a drone running on the leader // Drone location/id will need to be handled a different way as soon as leader rotation begins @@ -282,7 +283,7 @@ impl Fullnode { let rpc_pubsub_addr = SocketAddr::new( IpAddr::V4(Ipv4Addr::from(0)), - rpc_port.unwrap_or(RPC_PORT) + 1, + rpc_port.map_or(RPC_PORT + 1, |port| if port == 0 { port } else { port + 1 }), ); let rpc_pubsub_service = PubSubService::new(&bank, rpc_pubsub_addr, exit.clone());