fix: Intermittent failing CI due to addr in use (#9885)

Allow OS to set port at runtime
This commit is contained in:
mattrutherford 2018-11-11 10:20:04 +00:00 committed by Tomasz Drwięga
parent 09c512abaa
commit eea5b86cc4
1 changed files with 2 additions and 2 deletions

View File

@ -28,8 +28,7 @@ use tests::helpers::{GuardedAuthCodes, Server};
/// Setup a mock signer for tests
pub fn serve() -> (Server<ws::Server>, usize, GuardedAuthCodes) {
let port = 35000 + rand::random::<usize>() % 10000;
let address = format!("127.0.0.1:{}", port).parse().unwrap();
let address = "127.0.0.1:0".parse().unwrap();
let io = MetaIoHandler::default();
let authcodes = GuardedAuthCodes::new();
let stats = Arc::new(informant::RpcStats::default());
@ -44,6 +43,7 @@ pub fn serve() -> (Server<ws::Server>, usize, GuardedAuthCodes) {
extractors::WsExtractor::new(Some(&authcodes.path)),
extractors::WsStats::new(stats),
).unwrap());
let port = res.addr().port() as usize;
(res, port, authcodes)
}