lnwire+htlcswitch: only use references for failure messages

Methods on failure message types used to be defined on value receivers.
This allowed assignment of a failure message to ForwardingError both as
a value and as a pointer. This is error-prone, especially when using a
type switch.

In this commit the failure message methods are changed so that they
target pointer receivers.

Two instances where a value was assigned instead of a reference are
fixed.
This commit is contained in:
Joost Jager committed 2019-07-11 19:49:47 +02:00
1 parent 418fe364de
commit c6f9517e48
4 files changed
+36 -36

No files matched your search

+2 -2
View File
@@ -177,7 +177,7 @@ func TestFailUnknownPaymentHashOptionalAmount(t *testing.T) {
// Creation an error that is a non-pointer will allow us to skip the
// type assertion for the Serializable interface. As a result, the
// amount body won't be written.
onionError := FailUnknownPaymentHash{}
onionError := &FailUnknownPaymentHash{}
var b bytes.Buffer
if err := EncodeFailure(&b, onionError, 0); err != nil {
@@ -189,7 +189,7 @@ func TestFailUnknownPaymentHashOptionalAmount(t *testing.T) {
t.Fatalf("unable to decode error: %v", err)
}
if !reflect.DeepEqual(onionError, onionError) {
if !reflect.DeepEqual(onionError, onionError2) {
t.Fatalf("expected %v, got %v", spew.Sdump(onionError),
spew.Sdump(onionError2))
}