[NOD-1208] Use ID netAdapter generates in netAdapterMock handshake

This commit is contained in:
Mike Zak
2020-08-05 15:50:46 +03:00
parent 9d60bb1ee7
commit ec03a094e5

View File

@@ -47,7 +47,7 @@ func New(cfg *config.Config) (*NetAdapterMock, error) {
}, nil
}
// Connect opens a connection to the given address, handles handshake, and returns the routes this connection
// Connect opens a connection to the given address, handles handshake, and returns the routes for this connection
// To simplify usage the return type contains only two routes:
// OutgoingRoute - for all outgoing messages
// IncomingRoute - for all incoming messages (excluding handshake messages)
@@ -61,7 +61,7 @@ func (nam *NetAdapterMock) Connect(address string) (*Routes, error) {
}
routes := <-nam.routesChan
err = handleHandshake(routes)
err = handleHandshake(routes, nam.netAdapter.ID())
if err != nil {
return nil, errors.Wrap(err, "Error in handshake")
}
@@ -95,7 +95,7 @@ func handlePingPong(routes *Routes) error {
}
}
func handleHandshake(routes *Routes) error {
func handleHandshake(routes *Routes, ourID *id.ID) error {
msg, err := routes.handshakeRoute.DequeueWithTimeout(common.DefaultTimeout)
if err != nil {
return err
@@ -106,10 +106,6 @@ func handleHandshake(routes *Routes) error {
return errors.Errorf("Expected first message to be of type %s, but got %s", wire.CmdVersion, msg.Command())
}
ourID, err := id.GenerateID()
if err != nil {
return err
}
err = routes.OutgoingRoute.Enqueue(&wire.MsgVersion{
ProtocolVersion: versionMessage.ProtocolVersion,
Services: versionMessage.Services,