mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 14:44:22 +01:00
htlcswitch: add linkError field to htlcpacket
This commit adds a linkError field to track the value of failures which occur at our node. This field is set when local payments or multi hop htlcs fail in the switch or on our outgoing link. This addition is required for the addition of a htlc notifier which will notify these failures in handleDownstreamPacket. The passing of link error to failAddPacket removes the need for an additional error field, because the link error's failure detail will contain any additional metadata. In the places where the failure detail does not cover all the metadata that was previously supplied by addr err, the error is logged before calling failAddPacket so that this change does not reduce the amount of information we log.
This commit is contained in:
@@ -211,10 +211,13 @@ func TestSwitchSendPending(t *testing.T) {
|
||||
// Send the ADD packet, this should not be forwarded out to the link
|
||||
// since there are no eligible links.
|
||||
err = s.forward(packet)
|
||||
expErr := fmt.Sprintf("unable to find link with destination %v",
|
||||
aliceChanID)
|
||||
if err != nil && err.Error() != expErr {
|
||||
t.Fatalf("expected forward failure: %v", err)
|
||||
linkErr, ok := err.(*LinkError)
|
||||
if !ok {
|
||||
t.Fatalf("expected link error, got: %T", err)
|
||||
}
|
||||
if linkErr.WireMessage().Code() != lnwire.CodeUnknownNextPeer {
|
||||
t.Fatalf("expected fail unknown next peer, got: %T",
|
||||
linkErr.WireMessage().Code())
|
||||
}
|
||||
|
||||
// No message should be sent, since the packet was failed.
|
||||
@@ -1070,9 +1073,13 @@ func TestSwitchForwardFailAfterHalfAdd(t *testing.T) {
|
||||
// Resend the failed htlc, it should be returned to alice since the
|
||||
// switch will detect that it has been half added previously.
|
||||
err = s2.forward(ogPacket)
|
||||
if err != ErrIncompleteForward {
|
||||
t.Fatal("unexpected error when reforwarding a "+
|
||||
"failed packet", err)
|
||||
linkErr, ok := err.(*LinkError)
|
||||
if !ok {
|
||||
t.Fatalf("expected link error, got: %T", err)
|
||||
}
|
||||
if linkErr.FailureDetail != OutgoingFailureIncompleteForward {
|
||||
t.Fatalf("expected incomplete forward, got: %v",
|
||||
linkErr.FailureDetail)
|
||||
}
|
||||
|
||||
// After detecting an incomplete forward, the fail packet should have
|
||||
|
||||
Reference in New Issue
Block a user