paymentsdb: use querypayments method to make test db agnostic
What changed, and why it matters
This is a small test-only change in the LND Lightning Network Daemon project. It updates one test helper function to fetch payments using a different database query method so the test can work with multiple database backends. There is no change to production code, no user-facing behavior change, and no security fix.
No security action needed. Treat as routine test refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies payments/db/kv_store_test.go only. The assertPayments test helper previously called paymentDB.FetchPayments() directly. It now calls paymentDB.QueryPayments() with a context and a Query struct requesting all payments (IndexOffset: 0, MaxPayments: math.MaxUint64, IncludeIncomplete: true). This is a refactoring to make the test database-agnostic. No runtime logic, API, or security boundary is changed.
Changed components
payments/db/kv_store_test.goInspect captured patch +15 / −1
diff --git a/payments/db/kv_store_test.go b/payments/db/kv_store_test.go
index 49e80df..04cd726 100644
--- a/payments/db/kv_store_test.go
+++ b/payments/db/kv_store_test.go
@@ -2,11 +2,13 @@ package paymentsdb
import (
"bytes"
+ "context"
"crypto/rand"
"crypto/sha256"
"errors"
"fmt"
"io"
+ "math"
"reflect"
"testing"
"time"
@@ -1372,9 +1374,21 @@ func assertPayments(t *testing.T, paymentDB *KVPaymentsDB,
t.Helper()
- dbPayments, err := paymentDB.FetchPayments()
+ ctx := context.Background()
+
+ // We use the query method to fetch payments from the database which
+ // allows us to use this method db agnostic. We fetch all payments in
+ // one go.
+ queryResp, err := paymentDB.QueryPayments(ctx, Query{
+ IndexOffset: 0,
+ MaxPayments: math.MaxUint64,
+ Reversed: false,
+ IncludeIncomplete: true,
+ })
require.NoError(t, err, "could not fetch payments from db")
+ dbPayments := queryResp.Payments
+
// Make sure that the number of fetched payments is the same
// as expected.
require.Len(
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.