htlcswitch+routing: type check on ClearTextError

Update the type check used for checking local payment
failures to check on the ClearTextError interface rather
than on the ForwardingError type. This change prepares
for splitting payment errors up into Link and Forwarding
errors.
This commit is contained in:
carla committed 2020-01-14 15:07:42 +02:00
1 parent 6a83b06ab7
commit b5a2d75465
5 files changed
+94 -62

No files matched your search

+11 -7
View File
@@ -2178,11 +2178,11 @@ func TestUpdateFailMalformedHTLCErrorConversion(t *testing.T) {
t.Fatalf("unable to send payment: %v", err)
}
fwdingErr := err.(*ForwardingError)
failureMsg := fwdingErr.WireMessage()
routingErr := err.(ClearTextError)
failureMsg := routingErr.WireMessage()
if _, ok := failureMsg.(*lnwire.FailInvalidOnionKey); !ok {
t.Fatalf("expected onion failure instead got: %v",
fwdingErr.WireMessage())
routingErr.WireMessage())
}
}
@@ -2441,14 +2441,18 @@ func TestInvalidFailure(t *testing.T) {
select {
case result := <-resultChan:
fErr, ok := result.Error.(*ForwardingError)
rtErr, ok := result.Error.(ClearTextError)
if !ok {
t.Fatal("expected ForwardingError")
t.Fatal("expected ClearTextError")
}
if fErr.FailureSourceIdx != 2 {
source, ok := rtErr.(*ForwardingError)
if !ok {
t.Fatalf("expected forwarding error, got: %T", rtErr)
}
if source.FailureSourceIdx != 2 {
t.Fatal("unexpected error source index")
}
if fErr.WireMessage() != nil {
if rtErr.WireMessage() != nil {
t.Fatal("expected empty failure message")
}