-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test(transport): add ipv6 coverage to integration tests #3461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rishishanbhag
wants to merge
16
commits into
libp2p:master
Choose a base branch
from
rishishanbhag:add-ipv6-transport-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+143
−16
Open
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bf2d217
test(transport): add ipv6 coverage to integration tests
rishishanbhag c955178
test(transport): add WebRTC IPv6 test and skip on Windows
rishishanbhag 72d4ae0
Merge branch 'master' of https://github.com/libp2p/go-libp2p into add…
rishishanbhag 91db88e
Revert "Update to Go 1.25 (#3462)"
rishishanbhag 5d7c37c
Merge branch 'master' of https://github.com/libp2p/go-libp2p into add…
rishishanbhag ce3363f
Revert "webrtc: upgrade pion deps (#3469)"
rishishanbhag c98c1d8
(fix):Fixed webrtc ipv6 loopback on windows
rishishanbhag 729e18f
Reapply "webrtc: upgrade pion deps (#3469)"
rishishanbhag 073172f
Merge upstream/master into add-ipv6-transport-tests
rishishanbhag 263034f
test(transport): skip WebRTC IPv6 on Windows; revert prod workaround
rishishanbhag 2625b00
test(transport): address reviewer nits
rishishanbhag eb2e241
refactor(transport): rename skipWebRTCIPv6OnWindows to skipWindows
rishishanbhag 7e887b6
refactor(transport): simplify skipWindows function usage
rishishanbhag 0e3934c
fix(tests): remove unnecessary blank lines in transport tests
rishishanbhag c8ecf00
refactor(tests): update WebRTC condition checks in transport tests
rishishanbhag 14d5d51
go fmt
MarcoPolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,22 @@ func selfSignedTLSConfig(t *testing.T) *tls.Config { | |
| return tlsConfig | ||
| } | ||
|
|
||
| func skipIfNoIPv6(t *testing.T) { | ||
| t.Helper() | ||
| ln, err := net.Listen("tcp6", "[::1]:0") | ||
| if err != nil { | ||
| t.Skip("IPv6 loopback not available") | ||
| } | ||
| ln.Close() | ||
| } | ||
|
|
||
| func skipWindows(t *testing.T, transportName string) { | ||
| t.Helper() | ||
| if transportName == "WebRTC - IP6" && runtime.GOOS == "windows" { | ||
| t.Skip("WebRTC IPv6 over loopback is not supported on Windows. See WebRTC - IP6 HostGenerator for details.") | ||
| } | ||
| } | ||
|
|
||
| var transportsToTest = []TransportTestCase{ | ||
| { | ||
| Name: "TCP / Noise / Yamux", | ||
|
|
@@ -353,11 +369,113 @@ var transportsToTest = []TransportTestCase{ | |
| return h | ||
| }, | ||
| }, | ||
| { | ||
| Name: "TCP / Noise / Yamux - IP6", | ||
| HostGenerator: func(t *testing.T, opts TransportTestCaseOpts) host.Host { | ||
| skipIfNoIPv6(t) | ||
| libp2pOpts := transformOpts(opts) | ||
| libp2pOpts = append(libp2pOpts, libp2p.Security(noise.ID, noise.New)) | ||
| libp2pOpts = append(libp2pOpts, libp2p.Muxer(yamux.ID, yamux.DefaultTransport)) | ||
| if opts.NoListen { | ||
| libp2pOpts = append(libp2pOpts, libp2p.NoListenAddrs) | ||
| } else { | ||
| libp2pOpts = append(libp2pOpts, libp2p.ListenAddrStrings("/ip6/::1/tcp/0")) | ||
| } | ||
| h, err := libp2p.New(libp2pOpts...) | ||
| require.NoError(t, err) | ||
| return h | ||
| }, | ||
| }, | ||
| { | ||
| Name: "TCP / TLS / Yamux - IP6", | ||
| HostGenerator: func(t *testing.T, opts TransportTestCaseOpts) host.Host { | ||
| skipIfNoIPv6(t) | ||
| libp2pOpts := transformOpts(opts) | ||
| libp2pOpts = append(libp2pOpts, libp2p.Security(libp2ptls.ID, libp2ptls.New)) | ||
| libp2pOpts = append(libp2pOpts, libp2p.Muxer(yamux.ID, yamux.DefaultTransport)) | ||
| if opts.NoListen { | ||
| libp2pOpts = append(libp2pOpts, libp2p.NoListenAddrs) | ||
| } else { | ||
| libp2pOpts = append(libp2pOpts, libp2p.ListenAddrStrings("/ip6/::1/tcp/0")) | ||
| } | ||
| h, err := libp2p.New(libp2pOpts...) | ||
| require.NoError(t, err) | ||
| return h | ||
| }, | ||
| }, | ||
| { | ||
| Name: "WebSocket - IP6", | ||
| HostGenerator: func(t *testing.T, opts TransportTestCaseOpts) host.Host { | ||
| skipIfNoIPv6(t) | ||
| libp2pOpts := transformOpts(opts) | ||
| if opts.NoListen { | ||
| libp2pOpts = append(libp2pOpts, libp2p.NoListenAddrs) | ||
| } else { | ||
| libp2pOpts = append(libp2pOpts, libp2p.ListenAddrStrings("/ip6/::1/tcp/0/ws")) | ||
| } | ||
| h, err := libp2p.New(libp2pOpts...) | ||
| require.NoError(t, err) | ||
| return h | ||
| }, | ||
| }, | ||
| { | ||
| Name: "QUIC - IP6", | ||
| HostGenerator: func(t *testing.T, opts TransportTestCaseOpts) host.Host { | ||
| skipIfNoIPv6(t) | ||
| libp2pOpts := transformOpts(opts) | ||
| if opts.NoListen { | ||
| libp2pOpts = append(libp2pOpts, libp2p.NoListenAddrs) | ||
| } else { | ||
| libp2pOpts = append(libp2pOpts, libp2p.ListenAddrStrings("/ip6/::1/udp/0/quic-v1")) | ||
| } | ||
| h, err := libp2p.New(libp2pOpts...) | ||
| require.NoError(t, err) | ||
| return h | ||
| }, | ||
| }, | ||
| { | ||
| Name: "WebTransport - IP6", | ||
| HostGenerator: func(t *testing.T, opts TransportTestCaseOpts) host.Host { | ||
| skipIfNoIPv6(t) | ||
| libp2pOpts := transformOpts(opts) | ||
| if opts.NoListen { | ||
| libp2pOpts = append(libp2pOpts, libp2p.NoListenAddrs) | ||
| } else { | ||
| libp2pOpts = append(libp2pOpts, libp2p.ListenAddrStrings("/ip6/::1/udp/0/quic-v1/webtransport")) | ||
| } | ||
| h, err := libp2p.New(libp2pOpts...) | ||
| require.NoError(t, err) | ||
| return h | ||
| }, | ||
| }, | ||
| { | ||
| Name: "WebRTC - IP6", | ||
| HostGenerator: func(t *testing.T, opts TransportTestCaseOpts) host.Host { | ||
| skipIfNoIPv6(t) | ||
| // The WebRTC IPv6 loopback listener is /ip6/::1/udp/.../webrtc-direct. | ||
| // Pion ICE gathers candidates on link-local/global IPv6 interfaces, and on | ||
| // Windows wsasendto rejects sends from those locals to ::1 with | ||
| // "The requested address is not valid in its context" (scope mismatch). | ||
| // Those packets never leave the stack, so captures show no IPv6 UDP loopback traffic. | ||
| skipWindows(t, "WebRTC - IP6") | ||
| libp2pOpts := transformOpts(opts) | ||
| libp2pOpts = append(libp2pOpts, libp2p.Transport(libp2pwebrtc.New)) | ||
| if opts.NoListen { | ||
| libp2pOpts = append(libp2pOpts, libp2p.NoListenAddrs) | ||
| } else { | ||
| libp2pOpts = append(libp2pOpts, libp2p.ListenAddrStrings("/ip6/::1/udp/0/webrtc-direct")) | ||
| } | ||
| h, err := libp2p.New(libp2pOpts...) | ||
| require.NoError(t, err) | ||
| return h | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| func TestPing(t *testing.T) { | ||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
|
||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer h1.Close() | ||
|
|
@@ -387,6 +505,7 @@ func TestBigPing(t *testing.T) { | |
|
|
||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer h1.Close() | ||
|
|
@@ -515,6 +634,7 @@ func TestManyStreams(t *testing.T) { | |
| const streamCount = 128 | ||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{NoRcmgr: true}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true, NoRcmgr: true}) | ||
| defer h1.Close() | ||
|
|
@@ -739,6 +859,7 @@ func TestMoreStreamsThanOurLimits(t *testing.T) { | |
| func TestListenerStreamResets(t *testing.T) { | ||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer h1.Close() | ||
|
|
@@ -768,6 +889,7 @@ func TestListenerStreamResets(t *testing.T) { | |
| func TestDialerStreamResets(t *testing.T) { | ||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer h1.Close() | ||
|
|
@@ -799,6 +921,7 @@ func TestDialerStreamResets(t *testing.T) { | |
| func TestStreamReadDeadline(t *testing.T) { | ||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer h1.Close() | ||
|
|
@@ -853,6 +976,7 @@ func TestDiscoverPeerIDFromSecurityNegotiation(t *testing.T) { | |
|
|
||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| h1 := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| h2 := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer h1.Close() | ||
|
|
@@ -897,6 +1021,7 @@ func TestCloseConnWhenBlocked(t *testing.T) { | |
| continue | ||
| } | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| ctrl := gomock.NewController(t) | ||
| defer ctrl.Finish() | ||
| mockRcmgr := mocknetwork.NewMockResourceManager(ctrl) | ||
|
|
@@ -977,6 +1102,7 @@ func TestConnDroppedWhenBlocked(t *testing.T) { | |
| func TestConnClosedWhenRemoteCloses(t *testing.T) { | ||
| for _, tc := range transportsToTest { | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| server := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| client := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer server.Close() | ||
|
|
@@ -1017,6 +1143,7 @@ func TestErrorCodes(t *testing.T) { | |
| continue | ||
| } | ||
| t.Run(tc.Name, func(t *testing.T) { | ||
| skipWindows(t, tc.Name) | ||
| server := tc.HostGenerator(t, TransportTestCaseOpts{}) | ||
| client := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true}) | ||
| defer server.Close() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need the transportName param. It's just skip windows helper