From d28e67ddb059ee19b7386189888bd1db12fda399 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 29 Jun 2021 05:10:16 +0800 Subject: [PATCH] itest: fix make lint --- lntest/itest/assertions.go | 6 +++--- lntest/itest/lnd_channel_force_close.go | 15 ++++----------- lntest/itest/lnd_channel_policy_test.go | 10 +++++----- lntest/itest/lnd_misc_test.go | 2 +- lntest/itest/lnd_payment_test.go | 10 +++++----- lntest/itest/lnd_switch_test.go | 5 +---- 6 files changed, 19 insertions(+), 29 deletions(-) diff --git a/lntest/itest/assertions.go b/lntest/itest/assertions.go index 2102245b..def13577 100644 --- a/lntest/itest/assertions.go +++ b/lntest/itest/assertions.go @@ -361,7 +361,7 @@ func assertChannelClosed(ctx context.Context, t *harnessTest, // findForceClosedChannel searches a pending channel response for a particular // channel, returning the force closed channel upon success. func findForceClosedChannel(pendingChanResp *lnrpc.PendingChannelsResponse, - op *wire.OutPoint) (*lnrpc.PendingChannelsResponse_ForceClosedChannel, + op fmt.Stringer) (*lnrpc.PendingChannelsResponse_ForceClosedChannel, error) { for _, forceClose := range pendingChanResp.PendingForceClosingChannels { @@ -376,7 +376,7 @@ func findForceClosedChannel(pendingChanResp *lnrpc.PendingChannelsResponse, // findWaitingCloseChannel searches a pending channel response for a particular // channel, returning the waiting close channel upon success. func findWaitingCloseChannel(pendingChanResp *lnrpc.PendingChannelsResponse, - op *wire.OutPoint) (*lnrpc.PendingChannelsResponse_WaitingCloseChannel, + op fmt.Stringer) (*lnrpc.PendingChannelsResponse_WaitingCloseChannel, error) { for _, waitingClose := range pendingChanResp.WaitingCloseChannels { @@ -1237,7 +1237,7 @@ func assertNumPendingChannels(t *harnessTest, node *lntest.HarnessNode, } n := len(pendingChanResp.WaitingCloseChannels) if n != expWaitingClose { - predErr = fmt.Errorf("Expected to find %d channels "+ + predErr = fmt.Errorf("expected to find %d channels "+ "waiting close, found %d", expWaitingClose, n) return false } diff --git a/lntest/itest/lnd_channel_force_close.go b/lntest/itest/lnd_channel_force_close.go index 06781feb..9077a7c4 100644 --- a/lntest/itest/lnd_channel_force_close.go +++ b/lntest/itest/lnd_channel_force_close.go @@ -379,10 +379,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest, var predErr error err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(nodes, numInvoices) - if predErr != nil { - return false - } - return true + return predErr == nil }, defaultTimeout) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -1136,11 +1133,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest, } predErr = checkPendingChannelNumHtlcs(forceClose, numInvoices) - if predErr != nil { - return false - } - - return true + return predErr == nil }, defaultTimeout) if err != nil { t.Fatalf(predErr.Error()) @@ -1473,7 +1466,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) { } n := len(pendingChanResp.WaitingCloseChannels) if n != 1 { - predErr = fmt.Errorf("Expected to find %d channels "+ + predErr = fmt.Errorf("expected to find %d channels "+ "waiting close, found %d", 1, n) return false } @@ -1503,7 +1496,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) { } n := len(pendingChanResp.WaitingCloseChannels) if n != 0 { - predErr = fmt.Errorf("Expected to find %d channels "+ + predErr = fmt.Errorf("expected to find %d channels "+ "waiting close, found %d", 0, n) return false } diff --git a/lntest/itest/lnd_channel_policy_test.go b/lntest/itest/lnd_channel_policy_test.go index 0cac0f38..93300fac 100644 --- a/lntest/itest/lnd_channel_policy_test.go +++ b/lntest/itest/lnd_channel_policy_test.go @@ -235,14 +235,14 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { payAmt = btcutil.Amount(4) amtSat := int64(payAmt) amtMSat := int64(lnwire.NewMSatFromSatoshis(payAmt)) - routes.Routes[0].Hops[0].AmtToForward = amtSat + routes.Routes[0].Hops[0].AmtToForward = amtSat // nolint:staticcheck routes.Routes[0].Hops[0].AmtToForwardMsat = amtMSat - routes.Routes[0].Hops[1].AmtToForward = amtSat + routes.Routes[0].Hops[1].AmtToForward = amtSat // nolint:staticcheck routes.Routes[0].Hops[1].AmtToForwardMsat = amtMSat // Send the payment with the modified value. ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - alicePayStream, err := net.Alice.SendToRoute(ctxt) + alicePayStream, err := net.Alice.SendToRoute(ctxt) // nolint:staticcheck if err != nil { t.Fatalf("unable to create payment stream for alice: %v", err) } @@ -279,9 +279,9 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { payAmt = btcutil.Amount(5) amtSat = int64(payAmt) amtMSat = int64(lnwire.NewMSatFromSatoshis(payAmt)) - routes.Routes[0].Hops[0].AmtToForward = amtSat + routes.Routes[0].Hops[0].AmtToForward = amtSat // nolint:staticcheck routes.Routes[0].Hops[0].AmtToForwardMsat = amtMSat - routes.Routes[0].Hops[1].AmtToForward = amtSat + routes.Routes[0].Hops[1].AmtToForward = amtSat // nolint:staticcheck routes.Routes[0].Hops[1].AmtToForwardMsat = amtMSat // Manually set the MPP payload a new for each payment since diff --git a/lntest/itest/lnd_misc_test.go b/lntest/itest/lnd_misc_test.go index 23386d99..aa7bf25d 100644 --- a/lntest/itest/lnd_misc_test.go +++ b/lntest/itest/lnd_misc_test.go @@ -304,7 +304,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) { if err != nil { t.Fatalf("unable to lookup invoice: %v", err) } - if dbInvoice.Settled { + if dbInvoice.Settled { // nolint:staticcheck t.Fatalf("dave's invoice should not be marked as settled: %v", spew.Sdump(dbInvoice)) } diff --git a/lntest/itest/lnd_payment_test.go b/lntest/itest/lnd_payment_test.go index 83771663..dfaa10fb 100644 --- a/lntest/itest/lnd_payment_test.go +++ b/lntest/itest/lnd_payment_test.go @@ -102,7 +102,7 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("incorrect number of payments, got %v, want %v", len(paymentsResp.Payments), 1) } - p := paymentsResp.Payments[0] + p := paymentsResp.Payments[0] // nolint:staticcheck path := p.Htlcs[len(p.Htlcs)-1].Route.Hops // Ensure that the stored path shows a direct payment to Bob with no @@ -112,9 +112,9 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) { } // The payment amount should also match our previous payment directly. - if p.Value != paymentAmt { + if p.Value != paymentAmt { // nolint:staticcheck t.Fatalf("incorrect amount, got %v, want %v", - p.Value, paymentAmt) + p.Value, paymentAmt) // nolint:staticcheck } // The payment hash (or r-hash) should have been stored correctly. @@ -126,8 +126,8 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) { // As we made a single-hop direct payment, there should have been no fee // applied. - if p.Fee != 0 { - t.Fatalf("incorrect Fee, got %v, want %v", p.Fee, 0) + if p.Fee != 0 { // nolint:staticcheck + t.Fatalf("incorrect Fee, got %v, want %v", p.Fee, 0) // nolint:staticcheck } // Finally, verify that the payment request returned by the rpc matches diff --git a/lntest/itest/lnd_switch_test.go b/lntest/itest/lnd_switch_test.go index 81541110..97e8cf8b 100644 --- a/lntest/itest/lnd_switch_test.go +++ b/lntest/itest/lnd_switch_test.go @@ -176,10 +176,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { var predErr error err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(nodes, numPayments) - if predErr != nil { - return false - } - return true + return predErr == nil }, defaultTimeout) if err != nil { t.Fatalf("htlc mismatch: %v", predErr)