Skip to content

Ensure port uniqness in tests#715

Merged
volovyks merged 1 commit intodevelopfrom
serhii/ensure-unique-ports
Mar 19, 2026
Merged

Ensure port uniqness in tests#715
volovyks merged 1 commit intodevelopfrom
serhii/ensure-unique-ports

Conversation

@volovyks
Copy link
Copy Markdown
Contributor

Tests in #697 failed because two of the three nodes got the same port.

ode is starting at http://127.0.0.1:42547  ← node 0-sxtmu
node is starting at http://127.0.0.1:42547  ← node 1-wdkyi
node is starting at http://127.0.0.1:45533  ← node 2-vhtvu

Comment on lines +158 to +159
let listener = tokio::net::TcpListener::bind(addr).await?;
let port = listener.local_addr()?.port();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, by dropping listener: TcpListener, the socket and thus the port is freed on the OS level...

Ah well, I guess it would be nice if solana-test-validator could just pick an unused port itself and report it back.

Your solution seems like the best workaround.

@volovyks volovyks merged commit 16e451e into develop Mar 19, 2026
3 checks passed
@volovyks volovyks deleted the serhii/ensure-unique-ports branch March 19, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants