-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* swarm: Dedup addresses to dial (#2322) * Dedup addresses to dial Co-authored-by: Aayush Rajasekaran <[email protected]> * Move DedupAddrs test * Typo --------- Co-authored-by: Aayush Rajasekaran <[email protected]> * Release version v0.27.5 --------- Co-authored-by: Aayush Rajasekaran <[email protected]>
- Loading branch information
Showing
8 changed files
with
119 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -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) | ||
} | ||
}) | ||
} | ||
} |
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"version": "v0.27.4" | ||
"version": "v0.27.5" | ||
} |