multi: stop casting peer warning messages as errors

Split the logic for processing `error` and `warning` messages from our
peers.
This commit is contained in:
positiveblue
2022-08-24 12:26:42 -07:00
parent e65f05360e
commit 4d4d8e480c
8 changed files with 282 additions and 57 deletions

View File

@@ -859,15 +859,23 @@ func (f *Manager) reservationCoordinator() {
switch msg := fmsg.msg.(type) {
case *lnwire.OpenChannel:
f.handleFundingOpen(fmsg.peer, msg)
case *lnwire.AcceptChannel:
f.handleFundingAccept(fmsg.peer, msg)
case *lnwire.FundingCreated:
f.handleFundingCreated(fmsg.peer, msg)
case *lnwire.FundingSigned:
f.handleFundingSigned(fmsg.peer, msg)
case *lnwire.FundingLocked:
f.wg.Add(1)
go f.handleFundingLocked(fmsg.peer, msg)
case *lnwire.Warning:
f.handleWarningMsg(fmsg.peer, msg)
case *lnwire.Error:
f.handleErrorMsg(fmsg.peer, msg)
}
@@ -4193,12 +4201,16 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) {
}
}
// handleWarningMsg processes the warning which was received from remote peer.
func (f *Manager) handleWarningMsg(peer lnpeer.Peer, msg *lnwire.Warning) {
log.Warnf("received warning message from peer %x: %v",
peer.IdentityKey().SerializeCompressed(), msg.Warning())
}
// handleErrorMsg processes the error which was received from remote peer,
// depending on the type of error we should do different clean up steps and
// inform the user about it.
func (f *Manager) handleErrorMsg(peer lnpeer.Peer,
msg *lnwire.Error) {
func (f *Manager) handleErrorMsg(peer lnpeer.Peer, msg *lnwire.Error) {
chanID := msg.ChanID
peerKey := peer.IdentityKey()

View File

@@ -774,6 +774,14 @@ func fundChannel(t *testing.T, alice, bob *testNode, localFundingAmt,
// Forward the response to Alice.
alice.fundingMgr.ProcessFundingMsg(acceptChannelResponse, bob)
// Check that sending warning messages does not abort the funding
// process.
warningMsg := &lnwire.Warning{
Data: []byte("random warning"),
}
alice.fundingMgr.ProcessFundingMsg(warningMsg, bob)
bob.fundingMgr.ProcessFundingMsg(warningMsg, alice)
// Alice responds with a FundingCreated message.
fundingCreated := assertFundingMsgSent(
t, alice.msgChan, "FundingCreated",