network: be more specific on port mismatch error

This commit is contained in:
Roman Khimov 2019-09-13 20:32:16 +03:00
parent 773ccc2b92
commit b2530a4c93
2 changed files with 2 additions and 3 deletions

View file

@ -23,7 +23,6 @@ const (
)
var (
errPortMismatch = errors.New("port mismatch")
errIdenticalID = errors.New("identical node id")
errInvalidHandshake = errors.New("invalid handshake")
errInvalidNetwork = errors.New("invalid network")
@ -248,7 +247,7 @@ func (s *Server) handleVersionCmd(p Peer, version *payload.Version) error {
return errIdenticalID
}
if p.NetAddr().Port != int(version.Port) {
return errPortMismatch
return fmt.Errorf("port mismatch: connected to %d and peer sends %d", p.NetAddr().Port, version.Port)
}
return p.SendVersionAck(NewMessage(s.Net, CMDVerack, nil))
}

View file

@ -71,7 +71,7 @@ func TestServerNotSendsVerack(t *testing.T) {
version := payload.NewVersion(1337, 2000, "/NEO-GO/", 0, true)
err := s.handleVersionCmd(p, version)
assert.NotNil(t, err)
assert.Equal(t, errPortMismatch, err)
assert.Contains(t, err.Error(), "port mismatch")
// identical id's
version = payload.NewVersion(1, 3000, "/NEO-GO/", 0, true)