network: wait for both Version messages before ACKing
Otherwise the node might crash in `startProtocol` because of missing Version field in the peer. And it also keeps the sequence correct, Version MUST be sent first and ACKs can only follow it.
This commit is contained in:
parent
79d0c7446a
commit
d7f747fa9a
2 changed files with 8 additions and 0 deletions
|
@ -46,7 +46,9 @@ func TestPeerHandshake(t *testing.T) {
|
|||
// Now send and handle versions, but in a different order on client and
|
||||
// server.
|
||||
require.NoError(t, tcpC.SendVersion(&Message{}))
|
||||
require.Error(t, tcpC.HandleVersionAck()) // Didn't receive version yet.
|
||||
require.NoError(t, tcpS.HandleVersion(&payload.Version{}))
|
||||
require.Error(t, tcpS.SendVersionAck(&Message{})) // Didn't send version yet.
|
||||
require.NoError(t, tcpC.HandleVersion(&payload.Version{}))
|
||||
require.NoError(t, tcpS.SendVersion(&Message{}))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue