Page MenuHomePhabricator

Fix port collision detection in functional tests
ClosedPublic

Authored by Fabien on Mar 23 2023, 05:40.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC666a079219ee: Fix port collision detection in functional tests
Summary

If a port is bound but not listening, cannot bind to it anymore but the test will see the port as closed and let us use that, causing a failure. This diff fixes this potential issue by trying to bind instead of connecting.

Test Plan
ninja check-functional

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Mar 23 2023, 05:40
PiRK requested changes to this revision.Mar 23 2023, 07:44
PiRK added a subscriber: PiRK.
PiRK added inline comments.
test/functional/test_framework/util.py
362 ↗(On Diff #38782)

Ideally we should catch more specific exceptions. Catching Exception is OK if you really don't know what the expected exeption should be. BaseException is definitely too wide (it will catch Ctrl-C KeyboardInterrupt and other stuff like this).

380 ↗(On Diff #38782)

maybe use logger.info or logger.debug instead of print

This revision now requires changes to proceed.Mar 23 2023, 07:44

Remove debug leftover, only catch OSError

This revision is now accepted and ready to land.Mar 23 2023, 07:59