From 0609431a0c30d01899a2aaf1c1857081e9bd1a52 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 7 Mar 2024 15:43:30 -0800 Subject: [PATCH] channeldb: fix payment control unit tests w/ errors.Is --- channeldb/payment_control_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/channeldb/payment_control_test.go b/channeldb/payment_control_test.go index 9db6fe862..5b394edae 100644 --- a/channeldb/payment_control_test.go +++ b/channeldb/payment_control_test.go @@ -181,7 +181,7 @@ func TestPaymentControlSwitchFail(t *testing.T) { // Attempt a final payment, which should now fail since the prior // payment succeed. err = pControl.InitPayment(info.PaymentIdentifier, info) - if err != ErrAlreadyPaid { + if !errors.Is(err, ErrAlreadyPaid) { t.Fatalf("unable to send htlc message: %v", err) } } @@ -216,9 +216,7 @@ func TestPaymentControlSwitchDoubleSend(t *testing.T) { // payment hash, should result in error indicating that payment has // already been sent. err = pControl.InitPayment(info.PaymentIdentifier, info) - require.Equal(t, ErrPaymentExists, err, "payment control wrong "+ - "behaviour: init payment again must trigger ErrPaymentExists "+ - "error") + require.ErrorIs(t, err, ErrPaymentExists) // Record an attempt. _, err = pControl.RegisterAttempt(info.PaymentIdentifier, attempt) @@ -234,7 +232,7 @@ func TestPaymentControlSwitchDoubleSend(t *testing.T) { // Sends base htlc message which initiate StatusInFlight. err = pControl.InitPayment(info.PaymentIdentifier, info) - if err != ErrPaymentInFlight { + if !errors.Is(err, ErrPaymentInFlight) { t.Fatalf("payment control wrong behaviour: " + "double sending must trigger ErrPaymentInFlight error") } @@ -253,7 +251,7 @@ func TestPaymentControlSwitchDoubleSend(t *testing.T) { assertPaymentInfo(t, pControl, info.PaymentIdentifier, info, nil, htlc) err = pControl.InitPayment(info.PaymentIdentifier, info) - if err != ErrAlreadyPaid { + if !errors.Is(err, ErrAlreadyPaid) { t.Fatalf("unable to send htlc message: %v", err) } }