Merge pull request #432 from nspcc-dev/networking-fixes
This fixes useless disconnects in testnet/mainnet.
This commit is contained in:
commit
ade4abd91f
3 changed files with 5 additions and 11 deletions
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue