htlcswitch: do not consider unknown failures an error

This commit is contained in:
Joost Jager
2019-06-19 15:09:23 +02:00
parent c6f9517e48
commit 2726f50d7c
7 changed files with 186 additions and 112 deletions

View File

@@ -2344,4 +2344,37 @@ func TestInvalidFailure(t *testing.T) {
case <-time.After(time.Second):
t.Fatal("err wasn't received")
}
// Modify the decryption to simulate that decryption went alright, but
// the failure cannot be decoded.
deobfuscator = SphinxErrorDecrypter{
OnionErrorDecrypter: &mockOnionErrorDecryptor{
sourceIdx: 2,
message: []byte{200},
},
}
resultChan, err = s.GetPaymentResult(
paymentID, rhash, &deobfuscator,
)
if err != nil {
t.Fatal(err)
}
select {
case result := <-resultChan:
fErr, ok := result.Error.(*ForwardingError)
if !ok {
t.Fatal("expected ForwardingError")
}
if fErr.FailureSourceIdx != 2 {
t.Fatal("unexpected error source index")
}
if fErr.FailureMessage != nil {
t.Fatal("expected empty failure message")
}
case <-time.After(time.Second):
t.Fatal("err wasn't received")
}
}