Skip to content

Commit

Permalink
Merge pull request #19 from libp2p/chore/update-deps
Browse files Browse the repository at this point in the history
chore(dep): update
  • Loading branch information
Stebalien authored Dec 7, 2019
2 parents c86093d + 3dade04 commit da4a5cb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions p2p/net/conn-security-multistream/ssms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,31 @@ import (
"testing"

"github.com/libp2p/go-libp2p-core/sec/insecure"
tnet "github.com/libp2p/go-libp2p-testing/net"
sst "github.com/libp2p/go-libp2p-testing/suites/sec"
)

func TestCommonProto(t *testing.T) {
idA := tnet.RandIdentityOrFatal(t)
idB := tnet.RandIdentityOrFatal(t)

var at, bt SSMuxer
atInsecure := insecure.New("peerA")
btInsecure := insecure.New("peerB")

atInsecure := insecure.NewWithIdentity(idA.ID(), idA.PrivateKey())
btInsecure := insecure.NewWithIdentity(idB.ID(), idB.PrivateKey())
at.AddTransport("/plaintext/1.0.0", atInsecure)
bt.AddTransport("/plaintext/1.1.0", btInsecure)
bt.AddTransport("/plaintext/1.0.0", btInsecure)
sst.SubtestRW(t, &at, &bt, "peerA", "peerB")
sst.SubtestRW(t, &at, &bt, idA.ID(), idB.ID())
}

func TestNoCommonProto(t *testing.T) {
idA := tnet.RandIdentityOrFatal(t)
idB := tnet.RandIdentityOrFatal(t)

var at, bt SSMuxer
atInsecure := insecure.New("peerA")
btInsecure := insecure.New("peerB")
atInsecure := insecure.NewWithIdentity(idA.ID(), idA.PrivateKey())
btInsecure := insecure.NewWithIdentity(idB.ID(), idB.PrivateKey())

at.AddTransport("/plaintext/1.0.0", atInsecure)
bt.AddTransport("/plaintext/1.1.0", btInsecure)
Expand All @@ -46,7 +54,7 @@ func TestNoCommonProto(t *testing.T) {
go func() {
defer wg.Done()
defer b.Close()
_, err := bt.SecureOutbound(ctx, b, "peerA")
_, err := bt.SecureOutbound(ctx, b, idA.ID())
if err == nil {
t.Fatal("connection should have failed")
}
Expand Down

0 comments on commit da4a5cb

Please sign in to comment.