Skip to content

test: Fix IPv6 check on BSD systems - #22103

Merged
maflcko merged 1 commit into
bitcoin:masterfrom
n-thumann:fix_test_bsd_port_0
May 31, 2021
Merged

maflcko merged 1 commit into
bitcoin:masterfrom
n-thumann:fix_test_bsd_port_0

Conversation

@n-thumann

Copy link
Copy Markdown
Contributor

I noticed that test_ipv6_local() always returns False on macOS or FreeBSD, even though IPv6 is working perfectly fine. This causes test/functional/rpc_bind.py --ipv6 and test/functional/feature_proxy.py to skip their run.
Apparently, there's a check if the port number is 0 (see here or here), while Linux has no problem with this.
This is fixed by specifying any other port number than 0, e.g. 1. Still, because of SOCK_DGRAM, no actual connection is made.

@DrahtBot DrahtBot added the Tests label May 30, 2021

@theStack theStack left a comment

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.

Nice find, thanks for improving the test framework for *BSD users!

I can confirm that the fix also works on OpenBSD 6.9. 🚀

master branch:

$ python3
Python 3.8.8 (default, Apr 19 2021, 10:23:47)
[Clang 10.0.1 ] on openbsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> from test.functional.test_framework.netutil import test_ipv6_local
>>> test_ipv6_local()
False
>>>             

PR branch:

$ python3
Python 3.8.8 (default, Apr 19 2021, 10:23:47)
[Clang 10.0.1 ] on openbsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> from test.functional.test_framework.netutil import test_ipv6_local
>>> test_ipv6_local()
True
>>>             

ACK 2be3572

@fanquake

Copy link
Copy Markdown
Member

ACK 2be3572 - nice improvement. I checked that with this change ipv6 related tests in feature_proxy.py are being run.

This causes test/functional/rpc_bind.py --ipv6 and test/functional/feature_proxy.py to skip their run.

Note that rpc_bind.py --ipv6 is still going to be skipped on anything other than Linux due to:

self.log.info("Check for linux")
if not sys.platform.startswith('linux'):
raise SkipTest("This test can only be run on linux.")

@maflcko
maflcko merged commit d7a6bba into bitcoin:master May 31, 2021
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
2be3572 test: Fix IPv6 check on BSD systems (nthumann)

Pull request description:

  I noticed that `test_ipv6_local()` always returns `False` on macOS or FreeBSD, even though IPv6 is working perfectly fine. This causes `test/functional/rpc_bind.py --ipv6` and `test/functional/feature_proxy.py` to skip their run.
  Apparently, there's a check if the port number is `0` (see [here](https://github.com/freebsd/freebsd-src/blob/64881da478071431a2d9e62613997a5772c56cdf/sys/netinet6/udp6_usrreq.c#L248) or [here](https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/bsd/netinet6/udp6_usrreq.c#L282)), while Linux has no problem with this.
  This is fixed by specifying any other port number than `0`, e.g. `1`. Still, because of `SOCK_DGRAM`, no actual connection is made.

ACKs for top commit:
  fanquake:
    ACK 2be3572 - nice improvement. I checked that with this change ipv6 related tests in `feature_proxy.py` are being run.
  theStack:
    ACK 2be3572

Tree-SHA512: 8417c2d3cf71050529f3fa409a03872040fe5d249eae4172f276e62156e505a20d375b963712a186c9ad7967d8a497b5900d327c74a9693f68c33063871d4691
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 15, 2021
2be3572 test: Fix IPv6 check on BSD systems (nthumann)

Pull request description:

  I noticed that `test_ipv6_local()` always returns `False` on macOS or FreeBSD, even though IPv6 is working perfectly fine. This causes `test/functional/rpc_bind.py --ipv6` and `test/functional/feature_proxy.py` to skip their run.
  Apparently, there's a check if the port number is `0` (see [here](https://github.com/freebsd/freebsd-src/blob/64881da478071431a2d9e62613997a5772c56cdf/sys/netinet6/udp6_usrreq.c#L248) or [here](https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/bsd/netinet6/udp6_usrreq.c#L282)), while Linux has no problem with this.
  This is fixed by specifying any other port number than `0`, e.g. `1`. Still, because of `SOCK_DGRAM`, no actual connection is made.

ACKs for top commit:
  fanquake:
    ACK 2be3572 - nice improvement. I checked that with this change ipv6 related tests in `feature_proxy.py` are being run.
  theStack:
    ACK 2be3572

Tree-SHA512: 8417c2d3cf71050529f3fa409a03872040fe5d249eae4172f276e62156e505a20d375b963712a186c9ad7967d8a497b5900d327c74a9693f68c33063871d4691
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants