basichost: remove usage of MultistreamServerMatcher in test (#1680)

This commit is contained in:
Marten Seemann
2022-08-17 12:08:40 +03:00
committed by GitHub
parent eff72c4afa
commit 6631bfb011
3 changed files with 4 additions and 13 deletions
+4 -11
View File
@@ -15,7 +15,6 @@ import (
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
@@ -272,9 +271,6 @@ func assertWait(t *testing.T, c chan protocol.ID, exp protocol.ID) {
}
func TestHostProtoPreference(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
h1, h2 := getHostPair(t)
defer h1.Close()
defer h2.Close()
@@ -297,7 +293,7 @@ func TestHostProtoPreference(t *testing.T) {
h2.SetStreamHandler(protoOld, handler)
s, err := h1.NewStream(ctx, h2.ID(), protoMinor, protoNew, protoOld)
s, err := h1.NewStream(context.Background(), h2.ID(), protoMinor, protoNew, protoOld)
require.NoError(t, err)
// force the lazy negotiation to complete
@@ -307,12 +303,9 @@ func TestHostProtoPreference(t *testing.T) {
assertWait(t, connectedOn, protoOld)
s.Close()
mfunc, err := helpers.MultistreamSemverMatcher(protoMinor)
require.NoError(t, err)
h2.SetStreamHandlerMatch(protoMinor, mfunc, handler)
h2.SetStreamHandlerMatch(protoMinor, func(string) bool { return true }, handler)
// remembered preference will be chosen first, even when the other side newly supports it
s2, err := h1.NewStream(ctx, h2.ID(), protoMinor, protoNew, protoOld)
s2, err := h1.NewStream(context.Background(), h2.ID(), protoMinor, protoNew, protoOld)
require.NoError(t, err)
// required to force 'lazy' handshake
@@ -322,7 +315,7 @@ func TestHostProtoPreference(t *testing.T) {
assertWait(t, connectedOn, protoOld)
s2.Close()
s3, err := h1.NewStream(ctx, h2.ID(), protoMinor)
s3, err := h1.NewStream(context.Background(), h2.ID(), protoMinor)
require.NoError(t, err)
// Force a lazy handshake as we may have received a protocol update by this point.