Skip to content

Commit

Permalink
tls: add error assertions for ErrPeerIDMismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 25, 2023
1 parent 99f09aa commit e50ad64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion p2p/security/tls/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ func TestPeerIDMismatch(t *testing.T) {
require.Error(t, err)
var mismatchErr sec.ErrPeerIDMismatch
require.ErrorAs(t, err, &mismatchErr)
require.Equal(t, thirdPartyID, mismatchErr.Expected)
require.Equal(t, serverID, mismatchErr.Actual)

var serverErr error
select {
Expand All @@ -393,8 +395,8 @@ func TestPeerIDMismatch(t *testing.T) {
clientInsecureConn, serverInsecureConn := connect(t)

errChan := make(chan error)
thirdPartyID, _ := createPeer(t)
go func() {
thirdPartyID, _ := createPeer(t)
// expect the wrong peer ID
_, err := serverTransport.SecureInbound(context.Background(), serverInsecureConn, thirdPartyID)
errChan <- err
Expand All @@ -415,6 +417,8 @@ func TestPeerIDMismatch(t *testing.T) {
require.Error(t, serverErr)
var mismatchErr sec.ErrPeerIDMismatch
require.ErrorAs(t, serverErr, &mismatchErr)
require.Equal(t, thirdPartyID, mismatchErr.Expected)
require.Equal(t, clientTransport.localPeer, mismatchErr.Actual)
})
}

Expand Down

0 comments on commit e50ad64

Please sign in to comment.