What changed, and why it matters
This commit only cleans up test files by removing unused variable assignments and adding one missing error check. It does not change any production code that runs on real Lightning nodes, so it cannot directly affect live funds, network behavior, or security.
No security action required. Treat as routine code-quality maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch is a lint-only cleanup across eleven *_test.go files. It replaces assignments whose results are never read with blank identifiers, removes increment statements that have no effect, deletes unused local variables, and adds a single require.NoError assertion for a previously unchecked router creation error in routing/router_test.go. All changes are confined to test code; no runtime/production logic is modified.
Changed components
chainntnfs/txnotifier_test.gochanneldb/meta_test.gograph/builder_test.goinvoices/invoices_test.goitest/lnd_channel_force_close_test.goitest/lnd_psbt_test.gokeychain/interface_test.golnwallet/channel_test.gorouting/pathfind_test.gorouting/router_test.gowatchtower/wtclient/client_test.goInspect captured patch +19 / −24
diff --git a/chainntnfs/txnotifier_test.go b/chainntnfs/txnotifier_test.go
index d06ab8e..451062a 100644
--- a/chainntnfs/txnotifier_test.go
+++ b/chainntnfs/txnotifier_test.go
@@ -1942,14 +1942,18 @@ func TestTxNotifierConfirmHintCache(t *testing.T) {
// the height hints should remain unchanged. This simulates blocks
// confirming while the historical dispatch is processing the
// registration.
- hint, err := hintCache.QueryConfirmHint(ntfn1.HistoricalDispatch.ConfRequest)
+ _, err = hintCache.QueryConfirmHint(
+ ntfn1.HistoricalDispatch.ConfRequest,
+ )
if err != chainntnfs.ErrConfirmHintNotFound {
t.Fatalf("unexpected error when querying for height hint "+
"want: %v, got %v",
chainntnfs.ErrConfirmHintNotFound, err)
}
- hint, err = hintCache.QueryConfirmHint(ntfn2.HistoricalDispatch.ConfRequest)
+ _, err = hintCache.QueryConfirmHint(
+ ntfn2.HistoricalDispatch.ConfRequest,
+ )
if err != chainntnfs.ErrConfirmHintNotFound {
t.Fatalf("unexpected error when querying for height hint "+
"want: %v, got %v",
@@ -1978,7 +1982,9 @@ func TestTxNotifierConfirmHintCache(t *testing.T) {
// Now that both notifications are waiting at tip for confirmations,
// they should have their height hints updated to the latest block
// height.
- hint, err = hintCache.QueryConfirmHint(ntfn1.HistoricalDispatch.ConfRequest)
+ hint, err := hintCache.QueryConfirmHint(
+ ntfn1.HistoricalDispatch.ConfRequest,
+ )
require.NoError(t, err, "unable to query for hint")
if hint != tx1Height {
t.Fatalf("expected hint %d, got %d",
diff --git a/channeldb/meta_test.go b/channeldb/meta_test.go
index 066678c..ea314bc 100644
--- a/channeldb/meta_test.go
+++ b/channeldb/meta_test.go
@@ -547,7 +547,7 @@ func TestApplyOptionalVersions(t *testing.T) {
require.Equal(t, 0, migrateCount, "expected no migration")
// Check the optional meta is not updated.
- om, err := db.fetchOptionalMeta()
+ _, err = db.fetchOptionalMeta()
require.NoError(t, err, "error getting optional meta")
// Enable all optional migrations.
@@ -563,7 +563,7 @@ func TestApplyOptionalVersions(t *testing.T) {
)
// Fetch the updated optional meta.
- om, err = db.fetchOptionalMeta()
+ om, err := db.fetchOptionalMeta()
require.NoError(t, err, "error getting optional meta")
// Verify that the optional meta is updated as expected.
diff --git a/graph/builder_test.go b/graph/builder_test.go
index 3d5cf8e..d9e1c2c 100644
--- a/graph/builder_test.go
+++ b/graph/builder_test.go
@@ -2074,7 +2074,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
}
}
- channelID++ //nolint:ineffassign
+ channelID++ //nolint:ineffassign,wastedassign
}
return &testGraphInstance{
diff --git a/invoices/invoices_test.go b/invoices/invoices_test.go
index 987292b..5cfb76c 100644
--- a/invoices/invoices_test.go
+++ b/invoices/invoices_test.go
@@ -2813,7 +2813,7 @@ func testDeleteCanceledInvoices(t *testing.T,
// Cancel every second invoice.
if i%2 == 0 {
- invoice, err = db.UpdateInvoice(
+ _, err = db.UpdateInvoice(
ctxb, invpkg.InvoiceRefByHash(paymentHash), nil,
updateFunc,
)
diff --git a/itest/lnd_channel_force_close_test.go b/itest/lnd_channel_force_close_test.go
index 60e2a61..817a356 100644
--- a/itest/lnd_channel_force_close_test.go
+++ b/itest/lnd_channel_force_close_test.go
@@ -997,7 +997,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
sweeps = ht.AssertNumPendingSweeps(alice, 2)
commitSweep, anchorSweep := sweeps[0], sweeps[1]
if commitSweep.AmountSat < anchorSweep.AmountSat {
- commitSweep, anchorSweep = anchorSweep, commitSweep
+ commitSweep = anchorSweep
}
// Alice's sweeping transaction should now be broadcast. So we fetch the
diff --git a/itest/lnd_psbt_test.go b/itest/lnd_psbt_test.go
index e0c0740..c70803d 100644
--- a/itest/lnd_psbt_test.go
+++ b/itest/lnd_psbt_test.go
@@ -1920,7 +1920,7 @@ func testPsbtChanFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
// Consume the "channel pending" update. This waits until the funding
// transaction was fully compiled.
updateResp = ht.ReceiveOpenChannelUpdate(chanUpdates)
- upd, ok = updateResp.Update.(*lnrpc.OpenStatusUpdate_ChanPending)
+ _, ok = updateResp.Update.(*lnrpc.OpenStatusUpdate_ChanPending)
require.True(ht, ok)
err = finalTx.Deserialize(bytes.NewReader(finalizeRes.RawFinalTx))
diff --git a/keychain/interface_test.go b/keychain/interface_test.go
index 8d27aa9..c88384b 100644
--- a/keychain/interface_test.go
+++ b/keychain/interface_test.go
@@ -345,7 +345,7 @@ func TestSecretKeyRingDerivation(t *testing.T) {
// If we attempt to query for this key, then we
// should get ErrCannotDerivePrivKey.
- privKey, err = secretKeyRing.DerivePrivKey(
+ _, err = secretKeyRing.DerivePrivKey(
keyDesc,
)
if err != ErrCannotDerivePrivKey {
diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go
index 09822f3..2d04c30 100644
--- a/lnwallet/channel_test.go
+++ b/lnwallet/channel_test.go
@@ -1384,7 +1384,6 @@ func TestForceCloseDustOutput(t *testing.T) {
htlcAmount := lnwire.NewMSatFromSatoshis(500)
- aliceAmount := aliceChannel.channelState.LocalCommitment.LocalBalance
bobAmount := bobChannel.channelState.LocalCommitment.LocalBalance
// Have Bobs' to-self output be below her dust limit and check
@@ -1409,8 +1408,7 @@ func TestForceCloseDustOutput(t *testing.T) {
t.Fatalf("Can't update the channel state: %v", err)
}
- aliceAmount = aliceChannel.channelState.LocalCommitment.LocalBalance
- bobAmount = bobChannel.channelState.LocalCommitment.RemoteBalance
+ aliceAmount := aliceChannel.channelState.LocalCommitment.LocalBalance
closeSummary, err := aliceChannel.ForceClose()
require.NoError(t, err, "unable to force close channel")
@@ -7105,7 +7103,6 @@ func TestChanReserve(t *testing.T) {
// Bob: 5.0
htlcAmt := lnwire.NewMSatFromSatoshis(0.5 * btcutil.SatoshiPerBitcoin)
htlc, _ := createHTLC(aliceIndex, htlcAmt)
- aliceIndex++
addAndReceiveHTLC(t, aliceChannel, bobChannel, htlc, nil)
// Force a state transition, making sure this HTLC is considered valid
@@ -7127,7 +7124,6 @@ func TestChanReserve(t *testing.T) {
// Alice: 4.5
// Bob: 5.0
htlc, _ = createHTLC(bobIndex, htlcAmt)
- bobIndex++
_, err := bobChannel.AddHTLC(htlc, nil)
require.ErrorIs(t, err, ErrBelowChanReserve)
@@ -7140,7 +7136,6 @@ func TestChanReserve(t *testing.T) {
aliceChannel, bobChannel = setupChannels()
aliceIndex = 0
- bobIndex = 0
// Now we'll add HTLC of 3.5 BTC to Alice's commitment, this should put
// Alice's balance at 1.5 BTC.
@@ -7161,7 +7156,6 @@ func TestChanReserve(t *testing.T) {
// balance dip below.
htlcAmt = lnwire.NewMSatFromSatoshis(1 * btcutil.SatoshiPerBitcoin)
htlc, _ = createHTLC(aliceIndex, htlcAmt)
- aliceIndex++
_, err = aliceChannel.AddHTLC(htlc, nil)
require.ErrorIs(t, err, ErrBelowChanReserve)
@@ -7182,7 +7176,6 @@ func TestChanReserve(t *testing.T) {
// Bob: 7.0
htlcAmt = lnwire.NewMSatFromSatoshis(2 * btcutil.SatoshiPerBitcoin)
htlc, preimage := createHTLC(aliceIndex, htlcAmt)
- aliceIndex++
aliceHtlcIndex, err := aliceChannel.AddHTLC(htlc, nil)
require.NoError(t, err, "unable to add htlc")
bobHtlcIndex, err := bobChannel.ReceiveHTLC(htlc)
@@ -7218,7 +7211,6 @@ func TestChanReserve(t *testing.T) {
// the fee this is okay.
htlcAmt = lnwire.NewMSatFromSatoshis(1 * btcutil.SatoshiPerBitcoin)
htlc, _ = createHTLC(bobIndex, htlcAmt)
- bobIndex++
addAndReceiveHTLC(t, bobChannel, aliceChannel, htlc, nil)
// Do a last state transition, which should succeed.
@@ -7622,7 +7614,7 @@ func TestChannelRestoreUpdateLogs(t *testing.T) {
// and remote commit chains are updated in an async fashion. Since the
// remote chain was updated with the latest state (since Bob sent the
// revocation earlier) we can keep advancing the remote commit chain.
- aliceNewCommit, err = aliceChannel.SignNextCommitment(ctxb)
+ _, err = aliceChannel.SignNextCommitment(ctxb)
require.NoError(t, err, "unable to sign commitment")
// After Alice has signed this commitment, her local commitment will
diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go
index 9bf0363..f43a5c8 100644
--- a/routing/pathfind_test.go
+++ b/routing/pathfind_test.go
@@ -797,8 +797,6 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
return nil, err
}
}
-
- channelID++
}
return &testGraphInstance{
diff --git a/routing/router_test.go b/routing/router_test.go
index 535e4db..7dd340c 100644
--- a/routing/router_test.go
+++ b/routing/router_test.go
@@ -165,6 +165,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
&mockTrafficShaper{},
),
})
+ require.NoError(t, err, "unable to create router")
require.NoError(t, router.Start(), "unable to start router")
ctx := &testCtx{
diff --git a/watchtower/wtclient/client_test.go b/watchtower/wtclient/client_test.go
index 1b50600..5b47539 100644
--- a/watchtower/wtclient/client_test.go
+++ b/watchtower/wtclient/client_test.go
@@ -334,7 +334,6 @@ func (c *mockChannel) createRemoteCommitTx(t *testing.T) {
SignMethod: input.TaprootScriptSpendSignMethod,
ControlBlock: ctrlBytes,
}
- outputIndex++
}
txid := commitTxn.TxHash()
@@ -357,7 +356,6 @@ func (c *mockChannel) createRemoteCommitTx(t *testing.T) {
Hash: txid,
Index: uint32(outputIndex),
}
- outputIndex++
}
commitKeyRing := &lnwallet.CommitmentKeyRing{
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.