What changed, and why it matters
This commit only changes an integration test file. It adjusts how timestamps are rounded when testing the ListPayments and ListInvoices features, so the tests pass reliably across different database backends. There is no change to production code, no security fix, and no vulnerability being patched.
No security action needed. Treat as a normal test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies itest/lnd_payment_test.go. It replaces a single creation-time-in-seconds value with separate truncated (floor) and ceiling values for start-date and end-date filter test cases, and subtracts 2 seconds instead of 1 in one edge case to account for microsecond precision in the native SQL backend versus second precision in the KV backend. The production ListPayments/ListInvoices logic is untouched.
Changed components
itest/lnd_payment_test.goInspect captured patch +43 / −16
diff --git a/itest/lnd_payment_test.go b/itest/lnd_payment_test.go
index 37aff05..f683cd4 100644
--- a/itest/lnd_payment_test.go
+++ b/itest/lnd_payment_test.go
@@ -504,61 +504,86 @@ func testListPayments(ht *lntest.HarnessTest) {
expected bool
}
- // Create test cases to check the timestamp filters.
- createCases := func(createTimeSeconds uint64) []testCase {
+ // Create test cases with proper rounding for start and end dates.
+ createCases := func(startTimeSeconds,
+ endTimeSeconds uint64) []testCase {
+
return []testCase{
{
// Use a start date same as the creation date
- // should return us the item.
+ // (truncated) should return us the item.
name: "exact start date",
- startDate: createTimeSeconds,
+ startDate: startTimeSeconds,
expected: true,
},
{
// Use an earlier start date should return us
// the item.
name: "earlier start date",
- startDate: createTimeSeconds - 1,
+ startDate: startTimeSeconds - 1,
expected: true,
},
{
// Use a future start date should return us
// nothing.
name: "future start date",
- startDate: createTimeSeconds + 1,
+ startDate: startTimeSeconds + 1,
expected: false,
},
{
// Use an end date same as the creation date
- // should return us the item.
+ // (ceiling) should return us the item.
name: "exact end date",
- endDate: createTimeSeconds,
+ endDate: endTimeSeconds,
expected: true,
},
{
// Use an end date in the future should return
// us the item.
name: "future end date",
- endDate: createTimeSeconds + 1,
+ endDate: endTimeSeconds + 1,
expected: true,
},
{
// Use an earlier end date should return us
// nothing.
- name: "earlier end date",
- endDate: createTimeSeconds - 1,
+ name: "earlier end date",
+ // The native sql backend has a higher
+ // precision than the kv backend, the native sql
+ // backend uses microseconds, the kv backend
+ // when filtering uses seconds so we need to
+ // subtract 2 seconds to ensure the payment is
+ // not included.
+ // We could also truncate before inserting
+ // into the sql db but I rather relax this test
+ // here.
+ endDate: endTimeSeconds - 2,
expected: false,
},
}
}
- // Get the payment creation time in seconds.
- paymentCreateSeconds := uint64(
- p.CreationTimeNs / time.Second.Nanoseconds(),
+ // Get the payment creation time in seconds, using different approaches
+ // for start and end date comparisons to avoid rounding issues.
+ creationTime := time.Unix(0, p.CreationTimeNs)
+
+ // For start date comparisons: use truncation (floor) to include
+ // payments from the beginning of that second.
+ paymentCreateSecondsStart := uint64(
+ creationTime.Truncate(time.Second).Unix(),
+ )
+
+ // For end date comparisons: use ceiling to include payments up to the
+ // end of that second.
+ paymentCreateSecondsEnd := uint64(
+ (p.CreationTimeNs + time.Second.Nanoseconds() - 1) /
+ time.Second.Nanoseconds(),
)
// Create test cases from the payment creation time.
- testCases := createCases(paymentCreateSeconds)
+ testCases := createCases(
+ paymentCreateSecondsStart, paymentCreateSecondsEnd,
+ )
// We now check the timestamp filters in `ListPayments`.
for _, tc := range testCases {
@@ -578,7 +603,9 @@ func testListPayments(ht *lntest.HarnessTest) {
}
// Create test cases from the invoice creation time.
- testCases = createCases(uint64(invoice.CreationDate))
+ testCases = createCases(
+ uint64(invoice.CreationDate), uint64(invoice.CreationDate),
+ )
// We now do the same check for `ListInvoices`.
for _, tc := range testCases {
Why this scored 13/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.