Merge pull request #2018 from halseth/peer-remove-failed-chans
Mark channels borked in case of remote error
This commit is contained in:
4 files changed
+57
-2
No files matched your search
+7
-2
@@ -1900,9 +1900,14 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
||||
// Error received from remote, MUST fail channel, but should
|
||||
// only print the contents of the error message if all
|
||||
// characters are printable ASCII.
|
||||
l.fail(LinkFailureError{code: ErrRemoteError},
|
||||
l.fail(
|
||||
LinkFailureError{
|
||||
code: ErrRemoteError,
|
||||
PermanentFailure: true,
|
||||
},
|
||||
"ChannelPoint(%v): received error from peer: %v",
|
||||
l.channel.ChannelPoint(), msg.Error())
|
||||
l.channel.ChannelPoint(), msg.Error(),
|
||||
)
|
||||
default:
|
||||
l.log.Warnf("received unknown message of type %T", msg)
|
||||
}
|
||||
|
||||
@@ -5129,6 +5129,11 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
// force close the channel in response to the actions performed
|
||||
// during the linkTest.
|
||||
shouldForceClose bool
|
||||
|
||||
// permanentFailure indicates whether we expect the link to
|
||||
// consider the failure permanent in response to the actions
|
||||
// performed during the linkTest.
|
||||
permanentFailure bool
|
||||
}{
|
||||
{
|
||||
// Test that we don't force close if syncing states
|
||||
@@ -5144,6 +5149,7 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
// Should fail at startup.
|
||||
},
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
// Test that we don't force closes the channel if
|
||||
@@ -5160,6 +5166,7 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
// Should fail at startup.
|
||||
},
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
// Test that we force close the channel if we receive
|
||||
@@ -5176,6 +5183,7 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
c.HandleChannelUpdate(htlcSettle)
|
||||
},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
// Test that we force close the channel if we receive
|
||||
@@ -5213,6 +5221,7 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
c.HandleChannelUpdate(commitSig)
|
||||
},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
// Test that we force close the channel if we receive
|
||||
@@ -5252,6 +5261,19 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
c.HandleChannelUpdate(commitSig)
|
||||
},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
// Test that we consider the failure permanent if we
|
||||
// receive a link error from the remote.
|
||||
func(c *channelLink) {
|
||||
},
|
||||
func(t *testing.T, c *channelLink, remoteChannel *lnwallet.LightningChannel) {
|
||||
err := &lnwire.Error{}
|
||||
c.HandleChannelUpdate(err)
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5302,6 +5324,12 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
linkErr.ForceClose)
|
||||
}
|
||||
|
||||
if test.permanentFailure != linkErr.PermanentFailure {
|
||||
t.Fatalf("%d) Expected Alice set permanent failure(%v), "+
|
||||
"instead got(%v)", i, test.permanentFailure,
|
||||
linkErr.PermanentFailure)
|
||||
}
|
||||
|
||||
// Clean up before starting next test case.
|
||||
cleanUp()
|
||||
}
|
||||
|
||||
@@ -57,6 +57,10 @@ type LinkFailureError struct {
|
||||
// because of this error.
|
||||
ForceClose bool
|
||||
|
||||
// PermanentFailure indicates whether this failure is permanent, and
|
||||
// the channel should not be attempted loaded again.
|
||||
PermanentFailure bool
|
||||
|
||||
// SendData is a byte slice that will be sent to the peer. If nil a
|
||||
// generic error will be sent.
|
||||
SendData []byte
|
||||
|
||||
Reference in new issue
Block a user