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 74a9cfe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ github.com/containerd/cgroups v1.0.4/go.mod h1:nLNQtsF7Sl2HxNebu77i1R0oDlhiTG+kO
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
Expand Down
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 74a9cfe

Please sign in to comment.