From 53b58a1eb3f0a06e04edf1b46aceaa46f6e7303c Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 20 Aug 2018 19:23:15 -0700 Subject: [PATCH] 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. --- htlcswitch/mock.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 64f843fc..9df91993 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -500,11 +500,12 @@ func (s *mockServer) readHandler(message lnwire.Message) error { return fmt.Errorf("unknown message type: %T", msg) } - // Dispatch the commitment update message to the proper - // channel link dedicated to this channel. + // Dispatch the commitment update message to the proper channel link + // dedicated to this channel. If the link is not found, we will discard + // the message. link, err := s.htlcSwitch.GetLink(targetChan) if err != nil { - return err + return nil } // Create goroutine for this, in order to be able to properly stop