mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-24 09:25:21 +00:00
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{}
|
p = &payload.AddressList{}
|
||||||
case CMDBlock:
|
case CMDBlock:
|
||||||
p = &core.Block{}
|
p = &core.Block{}
|
||||||
|
case CMDConsensus:
|
||||||
|
// Stubbed out for now, see #431.
|
||||||
|
return nil
|
||||||
case CMDGetBlocks:
|
case CMDGetBlocks:
|
||||||
fallthrough
|
fallthrough
|
||||||
case CMDGetHeaders:
|
case CMDGetHeaders:
|
||||||
|
|
|
@ -252,9 +252,6 @@ func (s *Server) handleVersionCmd(p Peer, version *payload.Version) error {
|
||||||
if s.id == version.Nonce {
|
if s.id == version.Nonce {
|
||||||
return errIdenticalID
|
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))
|
return p.SendVersionAck(NewMessage(s.Net, CMDVerack, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,9 @@ func TestServerNotSendsVerack(t *testing.T) {
|
||||||
p.netaddr = *na
|
p.netaddr = *na
|
||||||
s.register <- p
|
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
|
// identical id's
|
||||||
version = payload.NewVersion(1, 3000, "/NEO-GO/", 0, true)
|
version := payload.NewVersion(1, 3000, "/NEO-GO/", 0, true)
|
||||||
err = s.handleVersionCmd(p, version)
|
err := s.handleVersionCmd(p, version)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
assert.Equal(t, errIdenticalID, err)
|
assert.Equal(t, errIdenticalID, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue