htlcswitch/mock: drop messages if link is not online

In this commit, we modify the readHandler w/in
the mock peer to drop messages if it is unable
to find the target link. This has led to observed
race conditions related to removing a link and still
attempting to deliver messages. By removing this,
the readHandler shouldn't fail the test as a result.
This commit is contained in:
Conner Fromknecht 2018-08-20 19:23:15 -07:00
parent f636ff8b4a
commit 53b58a1eb3
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -500,11 +500,12 @@ func (s *mockServer) readHandler(message lnwire.Message) error {
return fmt.Errorf("unknown message type: %T", msg) return fmt.Errorf("unknown message type: %T", msg)
} }
// Dispatch the commitment update message to the proper // Dispatch the commitment update message to the proper channel link
// channel link dedicated to this channel. // dedicated to this channel. If the link is not found, we will discard
// the message.
link, err := s.htlcSwitch.GetLink(targetChan) link, err := s.htlcSwitch.GetLink(targetChan)
if err != nil { if err != nil {
return err return nil
} }
// Create goroutine for this, in order to be able to properly stop // Create goroutine for this, in order to be able to properly stop