From 719e32830dcc8f6161d6fda50d1401ecbd46f7c6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 10 Jan 2020 15:27:50 +0100 Subject: [PATCH] lntest: fix most linter warnings, silence rest We fix all linter issues except for the 'lostcontext' and 'unparam' ones as those are too numerous and would increase the diff even more. Therefore we silence them in the itest directory for now. Because the linter is still not build tag aware, we also have to silence the unused and deadcode sub linters to not get false positives. --- .golangci.yml | 8 +++ lntest/harness.go | 1 - lntest/itest/lnd_channel_backup_test.go | 3 +- lntest/itest/lnd_forward_interceptor_test.go | 4 +- lntest/itest/lnd_macaroons_test.go | 4 +- lntest/itest/lnd_mpp_test.go | 2 +- lntest/itest/lnd_multi-hop-payments_test.go | 2 +- .../lnd_multi-hop_htlc_local_timeout_test.go | 17 +---- ...ulti-hop_htlc_receiver_chain_claim_test.go | 4 +- ..._force_close_on_chain_htlc_timeout_test.go | 11 +--- ..._force_close_on_chain_htlc_timeout_test.go | 11 +--- lntest/itest/lnd_multi-hop_test.go | 1 + lntest/itest/lnd_network_test.go | 4 +- lntest/itest/lnd_psbt_test.go | 2 +- lntest/itest/lnd_rest_api_test.go | 8 ++- lntest/itest/lnd_single_hop_invoice_test.go | 1 - lntest/itest/lnd_test.go | 64 +++++++------------ lntest/itest/lnd_test_list_on_test.go | 2 +- lntest/itest/test_harness.go | 2 - 19 files changed, 58 insertions(+), 93 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c0057fce..1ffef44b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -65,3 +65,11 @@ issues: - path: _test\.go linters: - gosec + + # Fix false positives because of build flags in itest directory. + - path: lntest/itest/.* + linters: + - unused + - deadcode + - unparam + - govet diff --git a/lntest/harness.go b/lntest/harness.go index f8c0b7fc..aa56af72 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -463,7 +463,6 @@ func (n *NetworkHarness) EnsureConnected(ctx context.Context, a, b *HarnessNode) err := n.connect(ctx, req, a) switch { - // Request was successful, wait for both to display the // connection. case err == nil: diff --git a/lntest/itest/lnd_channel_backup_test.go b/lntest/itest/lnd_channel_backup_test.go index 4a394c2d..5a8bf87d 100644 --- a/lntest/itest/lnd_channel_backup_test.go +++ b/lntest/itest/lnd_channel_backup_test.go @@ -364,6 +364,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // ann is updated? for _, testCase := range testCases { + testCase := testCase success := t.t.Run(testCase.name, func(t *testing.T) { h := newHarnessTest(t, net) @@ -543,7 +544,7 @@ func testChannelBackupUpdates(net *lntest.NetworkHarness, t *harnessTest) { chanPoint := chanPoints[i] - ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout) + ctxt, _ := context.WithTimeout(ctxb, channelCloseTimeout) closeChannelAndAssert( ctxt, t, net, net.Alice, chanPoint, forceClose, ) diff --git a/lntest/itest/lnd_forward_interceptor_test.go b/lntest/itest/lnd_forward_interceptor_test.go index ed36f879..6c54756f 100644 --- a/lntest/itest/lnd_forward_interceptor_test.go +++ b/lntest/itest/lnd_forward_interceptor_test.go @@ -120,7 +120,7 @@ func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) { t.t.Errorf("expected payment to fail, instead got %v", attempt.Status) } - // For settle and resume we make sure the payment is successfull. + // For settle and resume we make sure the payment is successful. case routerrpc.ResolveHoldForwardAction_SETTLE: fallthrough @@ -164,7 +164,7 @@ func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) { } // For all other packets we resolve according to the test case. - interceptor.Send(&routerrpc.ForwardHtlcInterceptResponse{ + _ = interceptor.Send(&routerrpc.ForwardHtlcInterceptResponse{ IncomingCircuitKey: request.IncomingCircuitKey, Action: testCase.interceptorAction, Preimage: testCase.invoice.RPreimage, diff --git a/lntest/itest/lnd_macaroons_test.go b/lntest/itest/lnd_macaroons_test.go index 8dee9572..93ef10b0 100644 --- a/lntest/itest/lnd_macaroons_test.go +++ b/lntest/itest/lnd_macaroons_test.go @@ -108,14 +108,14 @@ func testMacaroonAuthentication(net *lntest.NetworkHarness, t *harnessTest) { testNode.ReadMacPath(), defaultTimeout, ) require.NoError(t, err) - invalidIpAddrMac, err := macaroons.AddConstraints( + invalidIPAddrMac, err := macaroons.AddConstraints( readonlyMac, macaroons.IPLockConstraint( "1.1.1.1", ), ) require.NoError(t, err) cleanup, client := macaroonClient( - t, testNode, invalidIpAddrMac, + t, testNode, invalidIPAddrMac, ) defer cleanup() _, err = client.GetInfo(ctxt, infoReq) diff --git a/lntest/itest/lnd_mpp_test.go b/lntest/itest/lnd_mpp_test.go index c240a2b0..e213d981 100644 --- a/lntest/itest/lnd_mpp_test.go +++ b/lntest/itest/lnd_mpp_test.go @@ -23,7 +23,7 @@ func testSendToRouteMultiPath(net *lntest.NetworkHarness, t *harnessTest) { ctx := newMppTestContext(t, net) defer ctx.shutdownNodes() - // To ensure the payment goes through seperate paths, we'll set a + // To ensure the payment goes through separate paths, we'll set a // channel size that can only carry one shard at a time. We'll divide // the payment into 3 shards. const ( diff --git a/lntest/itest/lnd_multi-hop-payments_test.go b/lntest/itest/lnd_multi-hop-payments_test.go index 5c546a7c..ed8f25d8 100644 --- a/lntest/itest/lnd_multi-hop-payments_test.go +++ b/lntest/itest/lnd_multi-hop-payments_test.go @@ -168,7 +168,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { // Set the fee policies of the Alice -> Bob and the Dave -> Alice // channel edges to relatively large non default values. This makes it // possible to pick up more subtle fee calculation errors. - maxHtlc := uint64(calculateMaxHtlc(chanAmt)) + maxHtlc := calculateMaxHtlc(chanAmt) const aliceBaseFeeSat = 1 const aliceFeeRatePPM = 100000 updateChannelPolicy( diff --git a/lntest/itest/lnd_multi-hop_htlc_local_timeout_test.go b/lntest/itest/lnd_multi-hop_htlc_local_timeout_test.go index 6e61b458..8e55a744 100644 --- a/lntest/itest/lnd_multi-hop_htlc_local_timeout_test.go +++ b/lntest/itest/lnd_multi-hop_htlc_local_timeout_test.go @@ -93,11 +93,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest, nodes := []*lntest.HarnessNode{alice, bob, carol} err = wait.Predicate(func() bool { predErr = assertActiveHtlcs(nodes, dustPayHash, payHash) - if predErr != nil { - return false - } - - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -152,11 +148,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest, nodes = []*lntest.HarnessNode{alice} err = wait.Predicate(func() bool { predErr = assertActiveHtlcs(nodes, payHash) - if predErr != nil { - return false - } - - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -240,10 +232,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest, nodes = []*lntest.HarnessNode{alice} err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(nodes, 0) - if predErr != nil { - return false - } - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("alice's channel still has active htlc's: %v", predErr) diff --git a/lntest/itest/lnd_multi-hop_htlc_receiver_chain_claim_test.go b/lntest/itest/lnd_multi-hop_htlc_receiver_chain_claim_test.go index fb118940..1e022844 100644 --- a/lntest/itest/lnd_multi-hop_htlc_receiver_chain_claim_test.go +++ b/lntest/itest/lnd_multi-hop_htlc_receiver_chain_claim_test.go @@ -136,7 +136,7 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest, if c == commitTypeAnchors { expectedTxes = 2 } - txes, err := getNTxsFromMempool( + _, err = getNTxsFromMempool( net.Miner.Node, expectedTxes, minerMempoolTimeout, ) if err != nil { @@ -178,7 +178,7 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest, if c == commitTypeAnchors { expectedTxes = 3 } - txes, err = getNTxsFromMempool(net.Miner.Node, + txes, err := getNTxsFromMempool(net.Miner.Node, expectedTxes, minerMempoolTimeout) if err != nil { t.Fatalf("transactions not found in mempool: %v", err) diff --git a/lntest/itest/lnd_multi-hop_local_force_close_on_chain_htlc_timeout_test.go b/lntest/itest/lnd_multi-hop_local_force_close_on_chain_htlc_timeout_test.go index 449c4573..8eb5b97f 100644 --- a/lntest/itest/lnd_multi-hop_local_force_close_on_chain_htlc_timeout_test.go +++ b/lntest/itest/lnd_multi-hop_local_force_close_on_chain_htlc_timeout_test.go @@ -67,11 +67,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, nodes := []*lntest.HarnessNode{alice, bob, carol} err = wait.Predicate(func() bool { predErr = assertActiveHtlcs(nodes, payHash) - if predErr != nil { - return false - } - - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", err) @@ -201,10 +197,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, nodes = []*lntest.HarnessNode{alice} err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(nodes, 0) - if predErr != nil { - return false - } - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("alice's channel still has active htlc's: %v", predErr) diff --git a/lntest/itest/lnd_multi-hop_remote_force_close_on_chain_htlc_timeout_test.go b/lntest/itest/lnd_multi-hop_remote_force_close_on_chain_htlc_timeout_test.go index 53e56227..19d92165 100644 --- a/lntest/itest/lnd_multi-hop_remote_force_close_on_chain_htlc_timeout_test.go +++ b/lntest/itest/lnd_multi-hop_remote_force_close_on_chain_htlc_timeout_test.go @@ -68,11 +68,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, nodes := []*lntest.HarnessNode{alice, bob, carol} err = wait.Predicate(func() bool { predErr = assertActiveHtlcs(nodes, payHash) - if predErr != nil { - return false - } - - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -210,10 +206,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, nodes = []*lntest.HarnessNode{alice} err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(nodes, 0) - if predErr != nil { - return false - } - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("alice's channel still has active htlc's: %v", predErr) diff --git a/lntest/itest/lnd_multi-hop_test.go b/lntest/itest/lnd_multi-hop_test.go index 29817461..3707ae11 100644 --- a/lntest/itest/lnd_multi-hop_test.go +++ b/lntest/itest/lnd_multi-hop_test.go @@ -71,6 +71,7 @@ func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) { for _, commitType := range commitTypes { testName := fmt.Sprintf("committype=%v", commitType.String()) + commitType := commitType success := t.t.Run(testName, func(t *testing.T) { ht := newHarnessTest(t, net) diff --git a/lntest/itest/lnd_network_test.go b/lntest/itest/lnd_network_test.go index 8ce168b0..a1d69f53 100644 --- a/lntest/itest/lnd_network_test.go +++ b/lntest/itest/lnd_network_test.go @@ -79,7 +79,7 @@ func assertTimeoutError(ctxt context.Context, t *harnessTest, ctxt, cancel := context.WithTimeout(ctxt, defaultTimeout) defer cancel() - err := connect(node, ctxt, req) + err := connect(ctxt, node, req) // a DeadlineExceeded error will appear in the context if the above // ctxtTimeout value is reached. @@ -92,7 +92,7 @@ func assertTimeoutError(ctxt context.Context, t *harnessTest, ) } -func connect(node *lntest.HarnessNode, ctxt context.Context, +func connect(ctxt context.Context, node *lntest.HarnessNode, req *lnrpc.ConnectPeerRequest) error { syncTimeout := time.After(15 * time.Second) diff --git a/lntest/itest/lnd_psbt_test.go b/lntest/itest/lnd_psbt_test.go index b2affc03..69af9589 100644 --- a/lntest/itest/lnd_psbt_test.go +++ b/lntest/itest/lnd_psbt_test.go @@ -400,7 +400,7 @@ func receiveChanUpdate(ctx context.Context, errChan := make(chan error) go func() { // Consume one message. This will block until the message is - // recieved. + // received. resp, err := stream.Recv() if err != nil { errChan <- err diff --git a/lntest/itest/lnd_rest_api_test.go b/lntest/itest/lnd_rest_api_test.go index f0b402d8..573d0b43 100644 --- a/lntest/itest/lnd_rest_api_test.go +++ b/lntest/itest/lnd_rest_api_test.go @@ -49,9 +49,9 @@ var ( resultPattern = regexp.MustCompile("{\"result\":(.*)}") ) -// testRestApi tests that the most important features of the REST API work +// testRestAPI tests that the most important features of the REST API work // correctly. -func testRestApi(net *lntest.NetworkHarness, ht *harnessTest) { +func testRestAPI(net *lntest.NetworkHarness, ht *harnessTest) { testCases := []struct { name string run func(*testing.T, *lntest.HarnessNode, *lntest.HarnessNode) @@ -396,6 +396,7 @@ func testRestApi(net *lntest.NetworkHarness, ht *harnessTest) { } for _, tc := range testCases { + tc := tc ht.t.Run(tc.name, func(t *testing.T) { tc.run(t, net.Alice, net.Bob) }) @@ -486,10 +487,11 @@ func openWebSocket(node *lntest.HarnessNode, url, method string, fullURL := fmt.Sprintf( "wss://%s%s?method=%s", node.Cfg.RESTAddr(), url, method, ) - conn, _, err := webSocketDialer.Dial(fullURL, header) + conn, resp, err := webSocketDialer.Dial(fullURL, header) if err != nil { return nil, err } + defer func() { _ = resp.Body.Close() }() // Send the given request message as the first message on the socket. reqMsg, err := jsonMarshaler.MarshalToString(req) diff --git a/lntest/itest/lnd_single_hop_invoice_test.go b/lntest/itest/lnd_single_hop_invoice_test.go index 58c26d0b..83d914a1 100644 --- a/lntest/itest/lnd_single_hop_invoice_test.go +++ b/lntest/itest/lnd_single_hop_invoice_test.go @@ -40,7 +40,6 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) { RPreimage: preimage, Value: paymentAmt, } - ctxt, _ = context.WithTimeout(ctxt, defaultTimeout) invoiceResp, err := net.Bob.AddInvoice(ctxb, invoice) if err != nil { t.Fatalf("unable to add invoice: %v", err) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 49254d30..6b3ba1f5 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -1187,7 +1187,7 @@ func basicChannelFundingTest(t *harnessTest, net *lntest.NetworkHarness, // Finally, immediately close the channel. This function will // also block until the channel is closed and will additionally // assert the relevant channel closing post conditions. - ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout) + ctxt, _ := context.WithTimeout(ctxb, channelCloseTimeout) closeChannelAndAssert(ctxt, t, net, alice, chanPoint, false) } @@ -1253,6 +1253,8 @@ test: carolCommitType, daveCommitType) ht := t + carolCommitType := carolCommitType + daveCommitType := daveCommitType success := t.t.Run(testName, func(t *testing.T) { carolChannel, daveChannel, closeChan, err := basicChannelFundingTest( ht, net, carol, dave, nil, @@ -1454,7 +1456,7 @@ func testPaymentFollowingChannelOpen(net *lntest.NetworkHarness, t *harnessTest) ctxb := context.Background() const paymentAmt = btcutil.Amount(100) - channelCapacity := btcutil.Amount(paymentAmt * 1000) + channelCapacity := paymentAmt * 1000 // We first establish a channel between Alice and Bob. ctxt, cancel := context.WithTimeout(ctxb, channelOpenTimeout) @@ -2148,7 +2150,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { baseFee = int64(800) feeRate = int64(123) timeLockDelta = uint32(22) - maxHtlc = maxHtlc * 2 + maxHtlc *= 2 expectedPolicy.FeeBaseMsat = baseFee expectedPolicy.FeeRateMilliMsat = testFeeBase * feeRate @@ -2762,7 +2764,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) { // Assert that our wallet has our opening transaction with a label // that does not have a channel ID set yet, because we have not // reached our required confirmations. - tx := findTxAtHeight(ctxt, t, height, fundingTxStr, net, net.Alice) + tx := findTxAtHeight(ctxt, t, height, fundingTxStr, net.Alice) // At this stage, we expect the transaction to be labelled, but not with // our channel ID because our transaction has not yet confirmed. @@ -2793,7 +2795,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) { } // Re-lookup our transaction in the block that it confirmed in. - tx = findTxAtHeight(ctxt, t, height, fundingTxStr, net, net.Alice) + tx = findTxAtHeight(ctxt, t, height, fundingTxStr, net.Alice) // Create an additional check for our channel assertion that will // check that our label is as expected. @@ -2837,8 +2839,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) { // of at the target height, and finds and returns the tx with the target txid, // failing if it is not found. func findTxAtHeight(ctx context.Context, t *harnessTest, height int32, - target string, net *lntest.NetworkHarness, - node *lntest.HarnessNode) *lnrpc.Transaction { + target string, node *lntest.HarnessNode) *lnrpc.Transaction { txns, err := node.LightningClient.GetTransactions( ctx, &lnrpc.GetTransactionsRequest{ @@ -3208,6 +3209,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) { for _, channelType := range commitTypes { testName := fmt.Sprintf("committype=%v", channelType) + channelType := channelType success := t.t.Run(testName, func(t *testing.T) { ht := newHarnessTest(t, net) @@ -4123,7 +4125,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest, TxidStr: output.Hash.String(), OutputIndex: output.Index, }, - AmountSat: uint64(htlcLessFees), + AmountSat: htlcLessFees, } } @@ -4702,13 +4704,12 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, bob) // Connect Alice to Bob. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) if err := net.ConnectNodes(ctxb, alice, bob); err != nil { t.Fatalf("unable to connect alice to bob: %v", err) } // Give Alice some coins so she can fund a channel. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, alice) if err != nil { t.Fatalf("unable to send coins to alice: %v", err) @@ -5417,7 +5418,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest, i, p.PaymentRequest) } - // Assert the payment ammount is correct. + // Assert the payment amount is correct. if p.ValueSat != paymentAmtSat { t.Fatalf("incorrect payment amt for payment %d, "+ "want: %d, got: %d", @@ -9284,7 +9285,7 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest, } // Generate a single block, which should confirm the closing tx. - block := mineBlocks(t, net, 1, expectedTxes)[0] + _ = mineBlocks(t, net, 1, expectedTxes)[0] // Dave should sweep his funds immediately, as they are not timelocked. // We also expect Dave to sweep his anchor, if present. @@ -9305,7 +9306,7 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest, assertNumPendingChannels(t, carol, 0, 1) // Mine the sweep tx. - block = mineBlocks(t, net, 1, expectedTxes)[0] + _ = mineBlocks(t, net, 1, expectedTxes)[0] // Now Dave should consider the channel fully closed. assertNumPendingChannels(t, dave, 0, 0) @@ -9334,7 +9335,7 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest, if err != nil { t.Fatalf("unable to find Carol's sweep tx in mempool: %v", err) } - block = mineBlocks(t, net, 1, 1)[0] + block := mineBlocks(t, net, 1, 1)[0] assertTxInBlock(t, block, carolSweep) // Now the channel should be fully closed also from Carol's POV. @@ -11050,11 +11051,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { // Ensure all nodes in the network still have 5 outstanding htlcs. err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(nodes, numPayments) - if predErr != nil { - return false - } - return true - + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -11365,10 +11362,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { // for the duration of the interval. err = wait.Invariant(func() bool { predErr = assertNumActiveHtlcs(nodes, numPayments) - if predErr != nil { - return false - } - return true + return predErr == nil }, time.Second*2) if err != nil { t.Fatalf("htlc change: %v", predErr) @@ -11392,10 +11386,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { carolNode := []*lntest.HarnessNode{carol} err = wait.Predicate(func() bool { predErr = assertNumActiveHtlcs(carolNode, 0) - if predErr != nil { - return false - } - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -11683,7 +11674,6 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness // Disconnect the two intermediaries, Alice and Dave, by shutting down // Alice. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) if err := net.StopNode(net.Alice); err != nil { t.Fatalf("unable to shutdown alice: %v", err) } @@ -11713,10 +11703,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness } predErr = assertNumActiveHtlcsChanPoint(dave, carolFundPoint, 0) - if predErr != nil { - return false - } - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -12021,7 +12008,6 @@ func testSwitchOfflineDeliveryOutgoingOffline( // Disconnect the two intermediaries, Alice and Dave, so that when carol // restarts, the response will be held by Dave. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) if err := net.StopNode(net.Alice); err != nil { t.Fatalf("unable to shutdown alice: %v", err) } @@ -12042,11 +12028,7 @@ func testSwitchOfflineDeliveryOutgoingOffline( } predErr = assertNumActiveHtlcsChanPoint(dave, carolFundPoint, 0) - if predErr != nil { - return false - } - - return true + return predErr == nil }, time.Second*15) if err != nil { t.Fatalf("htlc mismatch: %v", predErr) @@ -12930,10 +12912,10 @@ func testAbandonChannel(net *lntest.NetworkHarness, t *harnessTest) { if err != nil { t.Fatalf("unable to list pending channels: %v", err) } - if len(alicePendingList.PendingClosingChannels) != 0 { + if len(alicePendingList.PendingClosingChannels) != 0 { //nolint:staticcheck t.Fatalf("alice should only have no pending closing channels, "+ "instead she has %v", - len(alicePendingList.PendingClosingChannels)) + len(alicePendingList.PendingClosingChannels)) //nolint:staticcheck } if len(alicePendingList.PendingForceClosingChannels) != 0 { t.Fatalf("alice should only have no pending force closing "+ @@ -13558,7 +13540,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) { // Assert terminal payment state. if i%2 == 0 { if payment.Status != lnrpc.Payment_SUCCEEDED { - t.Fatalf("state not suceeded : %v", + t.Fatalf("state not succeeded : %v", payment.Status) } } else { diff --git a/lntest/itest/lnd_test_list_on_test.go b/lntest/itest/lnd_test_list_on_test.go index e4cb916e..98910d22 100644 --- a/lntest/itest/lnd_test_list_on_test.go +++ b/lntest/itest/lnd_test_list_on_test.go @@ -264,7 +264,7 @@ var testsCases = []*testCase{ }, { name: "REST API", - test: testRestApi, + test: testRestAPI, }, { name: "intercept forwarded htlc packets", diff --git a/lntest/itest/test_harness.go b/lntest/itest/test_harness.go index daf089c0..a3c47528 100644 --- a/lntest/itest/test_harness.go +++ b/lntest/itest/test_harness.go @@ -101,8 +101,6 @@ func (h *harnessTest) RunTestCase(testCase *testCase) { }() testCase.test(h.lndHarness, h) - - return } func (h *harnessTest) Logf(format string, args ...interface{}) {