Skip to content

Commit

Permalink
basichost: remove usage of MultistreamServerMatcher in test
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 17, 2022
1 parent eff72c4 commit 42c6761
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions p2p/host/basic/basic_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 42c6761

Please sign in to comment.