-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Release v0.27.5 #2324
Release v0.27.5 #2324
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
ma "github.com/multiformats/go-multiaddr" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDedupAddrs(t *testing.T) { | ||
tcpAddr := ma.StringCast("/ip4/127.0.0.1/tcp/1234") | ||
quicAddr := ma.StringCast("/ip4/127.0.0.1/udp/1234/quic-v1") | ||
wsAddr := ma.StringCast("/ip4/127.0.0.1/tcp/1234/ws") | ||
|
||
type testcase struct { | ||
in, out []ma.Multiaddr | ||
} | ||
|
||
for i, tc := range []testcase{ | ||
{in: nil, out: nil}, | ||
{in: []ma.Multiaddr{tcpAddr}, out: []ma.Multiaddr{tcpAddr}}, | ||
{in: []ma.Multiaddr{tcpAddr, tcpAddr, tcpAddr}, out: []ma.Multiaddr{tcpAddr}}, | ||
{in: []ma.Multiaddr{tcpAddr, quicAddr, tcpAddr}, out: []ma.Multiaddr{tcpAddr, quicAddr}}, | ||
{in: []ma.Multiaddr{tcpAddr, quicAddr, wsAddr}, out: []ma.Multiaddr{tcpAddr, quicAddr, wsAddr}}, | ||
} { | ||
tc := tc | ||
t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { | ||
deduped := DedupAddrs(tc.in) | ||
for _, a := range tc.out { | ||
require.Contains(t, deduped, a) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to check the length, otherwise |
||
} | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -180,7 +180,12 @@ loop: | |||||
case <-w.triggerDial: | ||||||
for _, addr := range w.nextDial { | ||||||
// spawn the dial | ||||||
ad := w.pending[string(addr.Bytes())] | ||||||
ad, ok := w.pending[string(addr.Bytes())] | ||||||
if !ok { | ||||||
log.Warn("unexpectedly missing pending addrDial for addr") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// Assume nothing to dial here | ||||||
continue | ||||||
} | ||||||
err := w.s.dialNextAddr(ad.ctx, w.peer, addr, w.resch) | ||||||
if err != nil { | ||||||
w.dispatchError(ad, err) | ||||||
|
@@ -195,7 +200,12 @@ loop: | |||||
w.connected = true | ||||||
} | ||||||
|
||||||
ad := w.pending[string(res.Addr.Bytes())] | ||||||
ad, ok := w.pending[string(res.Addr.Bytes())] | ||||||
if !ok { | ||||||
log.Warn("unexpectedly missing pending addrDial res") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here? |
||||||
// Assume nothing to do here | ||||||
continue | ||||||
} | ||||||
|
||||||
if res.Conn != nil { | ||||||
// we got a connection, add it to the swarm | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"version": "v0.27.4" | ||
"version": "v0.27.5" | ||
} |
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.