Merge pull request #432 from nspcc-dev/networking-fixes

This fixes useless disconnects in testnet/mainnet.
This commit is contained in:
Roman Khimov 2019-10-17 12:05:51 +03:00 committed by GitHub
commit ade4abd91f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View file

@ -184,6 +184,9 @@ func (m *Message) decodePayload(br *io.BinReader) error {
p = &payload.AddressList{}
case CMDBlock:
p = &core.Block{}
case CMDConsensus:
// Stubbed out for now, see #431.
return nil
case CMDGetBlocks:
fallthrough
case CMDGetHeaders:

View file

@ -252,9 +252,6 @@ func (s *Server) handleVersionCmd(p Peer, version *payload.Version) error {
if s.id == version.Nonce {
return errIdenticalID
}
if p.NetAddr().Port != int(version.Port) {
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

@ -67,15 +67,9 @@ func TestServerNotSendsVerack(t *testing.T) {
p.netaddr = *na
s.register <- p
// Port should mismatch
version := payload.NewVersion(1337, 2000, "/NEO-GO/", 0, true)
err := s.handleVersionCmd(p, version)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "port mismatch")
// identical id's
version = payload.NewVersion(1, 3000, "/NEO-GO/", 0, true)
err = s.handleVersionCmd(p, version)
version := payload.NewVersion(1, 3000, "/NEO-GO/", 0, true)
err := s.handleVersionCmd(p, version)
assert.NotNil(t, err)
assert.Equal(t, errIdenticalID, err)
}