Skip to content

Commit d1bceb2

Browse files
committed
Merge new go-multistream changes
1 parent c3085da commit d1bceb2

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

p2p/host/autorelay/relay_finder.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/libp2p/go-libp2p/core/event"
1414
"github.com/libp2p/go-libp2p/core/network"
1515
"github.com/libp2p/go-libp2p/core/peer"
16-
"github.com/libp2p/go-libp2p/core/protocol"
1716
basic "github.com/libp2p/go-libp2p/p2p/host/basic"
1817
relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay"
1918
circuitv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client"
@@ -24,8 +23,8 @@ import (
2423
)
2524

2625
const (
27-
protoIDv1 = protocol.ID(relayv1.ProtoID)
28-
protoIDv2 = protocol.ID(circuitv2_proto.ProtoIDv2Hop)
26+
protoIDv1 = relayv1.ProtoID
27+
protoIDv2 = circuitv2_proto.ProtoIDv2Hop
2928
)
3029

3130
// Terminology:

p2p/host/basic/basic_host_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func TestProtocolHandlerEvents(t *testing.T) {
158158

159159
h.SetStreamHandler(protocol.TestingID, func(s network.Stream) {})
160160
assert([]protocol.ID{protocol.TestingID}, nil)
161-
h.SetStreamHandler(protocol.ID("foo"), func(s network.Stream) {})
162-
assert([]protocol.ID{protocol.ID("foo")}, nil)
161+
h.SetStreamHandler("foo", func(s network.Stream) {})
162+
assert([]protocol.ID{"foo"}, nil)
163163
h.RemoveStreamHandler(protocol.TestingID)
164164
assert(nil, []protocol.ID{protocol.TestingID})
165165
}
@@ -273,9 +273,9 @@ func TestHostProtoPreference(t *testing.T) {
273273
defer h2.Close()
274274

275275
const (
276-
protoOld = protocol.ID("/testing")
277-
protoNew = protocol.ID("/testing/1.1.0")
278-
protoMinor = protocol.ID("/testing/1.2.0")
276+
protoOld = "/testing"
277+
protoNew = "/testing/1.1.0"
278+
protoMinor = "/testing/1.2.0"
279279
)
280280

281281
connectedOn := make(chan protocol.ID)

p2p/host/peerstore/test/peerstore_suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func testPeerstoreProtoStore(ps pstore.Peerstore) func(t *testing.T) {
221221
require.NoError(t, err)
222222
require.Len(t, out, len(protos), "got wrong number of protocols back")
223223

224-
sort.Slice(out, func(i, j int) bool { return out[i] < out[j] })
224+
sortProtos(out)
225225
for i, p := range protos {
226226
if out[i] != p {
227227
t.Fatal("got wrong protocol")

p2p/host/resource-manager/extapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (r *resourceManager) ListProtocols() []protocol.ID {
8787
}
8888

8989
sort.Slice(result, func(i, j int) bool {
90-
return strings.Compare(string(result[i]), string(result[j])) < 0
90+
return result[i] < result[j]
9191
})
9292

9393
return result

p2p/protocol/identify/id_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func TestIdentifyPushWhileIdentifyingConn(t *testing.T) {
383383
handler := func(s network.Stream) {
384384
<-block
385385
w := pbio.NewDelimitedWriter(s)
386-
w.WriteMsg(&pb.Identify{Protocols:protocol.ConvertToStrings(h1.Mux().Protocols())})
386+
w.WriteMsg(&pb.Identify{Protocols: protocol.ConvertToStrings(h1.Mux().Protocols())})
387387
s.Close()
388388
}
389389
h1.RemoveStreamHandler(identify.ID)
@@ -613,9 +613,9 @@ func TestLargeIdentifyMessage(t *testing.T) {
613613
// add protocol strings to make the message larger
614614
// about 2K of protocol strings
615615
for i := 0; i < 500; i++ {
616-
r := fmt.Sprintf("rand%d", i)
617-
h1.SetStreamHandler(protocol.ID(r), func(network.Stream) {})
618-
h2.SetStreamHandler(protocol.ID(r), func(network.Stream) {})
616+
r := protocol.ID(fmt.Sprintf("rand%d", i))
617+
h1.SetStreamHandler(r, func(network.Stream) {})
618+
h2.SetStreamHandler(r, func(network.Stream) {})
619619
}
620620

621621
h1p := h1.ID()
@@ -719,9 +719,9 @@ func TestLargePushMessage(t *testing.T) {
719719
// add protocol strings to make the message larger
720720
// about 2K of protocol strings
721721
for i := 0; i < 500; i++ {
722-
r := fmt.Sprintf("rand%d", i)
723-
h1.SetStreamHandler(protocol.ID(r), func(network.Stream) {})
724-
h2.SetStreamHandler(protocol.ID(r), func(network.Stream) {})
722+
r := protocol.ID(fmt.Sprintf("rand%d", i))
723+
h1.SetStreamHandler(r, func(network.Stream) {})
724+
h2.SetStreamHandler(r, func(network.Stream) {})
725725
}
726726

727727
h1p := h1.ID()

p2p/security/tls/transport_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,37 +188,37 @@ func TestHandshakeWithNextProtoSucceeds(t *testing.T) {
188188
{
189189
clientProtos: []protocol.ID{"muxer1", "muxer2"},
190190
serverProtos: []protocol.ID{"muxer2", "muxer1"},
191-
expectedResult: protocol.ID("muxer1"),
191+
expectedResult: "muxer1",
192192
},
193193
{
194194
clientProtos: []protocol.ID{"muxer1", "muxer2", "libp2p"},
195195
serverProtos: []protocol.ID{"muxer2", "muxer1", "libp2p"},
196-
expectedResult: protocol.ID("muxer1"),
196+
expectedResult: "muxer1",
197197
},
198198
{
199199
clientProtos: []protocol.ID{"muxer1", "libp2p"},
200200
serverProtos: []protocol.ID{"libp2p"},
201-
expectedResult: protocol.ID(""),
201+
expectedResult: "",
202202
},
203203
{
204204
clientProtos: []protocol.ID{"libp2p"},
205205
serverProtos: []protocol.ID{"libp2p"},
206-
expectedResult: protocol.ID(""),
206+
expectedResult: "",
207207
},
208208
{
209209
clientProtos: []protocol.ID{"muxer1"},
210210
serverProtos: []protocol.ID{},
211-
expectedResult: protocol.ID(""),
211+
expectedResult: "",
212212
},
213213
{
214214
clientProtos: []protocol.ID{},
215215
serverProtos: []protocol.ID{"muxer1"},
216-
expectedResult: protocol.ID(""),
216+
expectedResult: "",
217217
},
218218
{
219219
clientProtos: []protocol.ID{"muxer2"},
220220
serverProtos: []protocol.ID{"muxer1"},
221-
expectedResult: protocol.ID(""),
221+
expectedResult: "",
222222
},
223223
}
224224

p2p/test/negotiation/security_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/libp2p/go-libp2p"
99
"github.com/libp2p/go-libp2p/core/crypto"
1010
"github.com/libp2p/go-libp2p/core/peer"
11-
"github.com/libp2p/go-libp2p/core/protocol"
1211
"github.com/libp2p/go-libp2p/p2p/security/noise"
1312
tls "github.com/libp2p/go-libp2p/p2p/security/tls"
1413
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
@@ -84,7 +83,7 @@ func TestSecurityNegotiation(t *testing.T) {
8483
require.NoError(t, err)
8584
conns := client.Network().ConnsToPeer(server.ID())
8685
require.Len(t, conns, 1, "expected exactly one connection")
87-
require.Equal(t, tc.Expected, protocol.ID(conns[0].ConnState().Security))
86+
require.Equal(t, tc.Expected, conns[0].ConnState().Security)
8887
})
8988
}
9089
}

0 commit comments

Comments
 (0)