mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-04-03 14:30:09 +08:00
21 lines
487 B
Go
21 lines
487 B
Go
package pstoremem
|
|
|
|
import (
|
|
"sort"
|
|
"testing"
|
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAddressSorting(t *testing.T) {
|
|
u1 := ma.StringCast("/ip4/152.12.23.53/udp/1234/utp")
|
|
u2l := ma.StringCast("/ip4/127.0.0.1/udp/1234/utp")
|
|
local := ma.StringCast("/ip4/127.0.0.1/tcp/1234")
|
|
norm := ma.StringCast("/ip4/6.5.4.3/tcp/1234")
|
|
|
|
l := addrList{local, u1, u2l, norm}
|
|
sort.Sort(l)
|
|
require.Equal(t, l, addrList{u2l, u1, local, norm})
|
|
}
|