htlcswitch+peer: CreateAndAddLink in switch, add messageSwitch to peer

This commit allows the peer to be tested without relying on a raw
htlcswitch.Switch pointer. This is accomplished by using a messageSwitch
interface and adding the CreateAndAddLink method to the
htlcswitch.Switch.
This commit is contained in:
eugene
2021-08-03 15:18:37 -04:00
parent e72468646c
commit 23a4fad4ac
4 changed files with 74 additions and 30 deletions

View File

@ -1956,6 +1956,15 @@ func (s *Switch) Stop() error {
return nil
}
// CreateAndAddLink will create a link and then add it to the internal maps
// when given a ChannelLinkConfig and LightningChannel.
func (s *Switch) CreateAndAddLink(linkCfg ChannelLinkConfig,
lnChan *lnwallet.LightningChannel) error {
link := NewChannelLink(linkCfg, lnChan)
return s.AddLink(link)
}
// AddLink is used to initiate the handling of the add link command. The
// request will be propagated and handled in the main goroutine.
func (s *Switch) AddLink(link ChannelLink) error {