From f4933c67fd1cc68fc321f188f894411a865caabb Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 10 Jun 2020 12:34:27 +0200 Subject: [PATCH] channeldb: add test case for index offset greater than index In our current invoice pagination logic, we would not return any invoices if our offset index was more than 1 off our last index and we were paginating backwards. This commit adds a test case for this behaviour before fixing it in the next commit. --- channeldb/invoice_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/channeldb/invoice_test.go b/channeldb/invoice_test.go index eea9df03..d19c349b 100644 --- a/channeldb/invoice_test.go +++ b/channeldb/invoice_test.go @@ -1007,6 +1007,18 @@ func TestQueryInvoices(t *testing.T) { // still pending. expected: pendingInvoices[len(pendingInvoices)-15:], }, + // Fetch all invoices paginating backwards, with an index offset + // that is beyond our last offset. We currently do not return + // anything if our index is greater than our last index. + { + query: InvoiceQuery{ + IndexOffset: numInvoices * 2, + PendingOnly: false, + Reversed: true, + NumMaxInvoices: numInvoices, + }, + expected: nil, + }, } for i, testCase := range testCases {