mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-02 17:52:28 +02:00
lntest: add itest for timestamp filters
This commit is contained in:
@@ -1273,7 +1273,8 @@ func (h *HarnessTest) findPayment(hn *node.HarnessNode,
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
require.Fail(h, "payment: %v not found", paymentHash)
|
require.Failf(h, "payment not found", "payment %v cannot be found",
|
||||||
|
paymentHash)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -72,11 +72,71 @@ func testListPayments(ht *lntemp.HarnessTest) {
|
|||||||
require.Zero(ht, p.FeeSat, "fee should be 0")
|
require.Zero(ht, p.FeeSat, "fee should be 0")
|
||||||
require.Zero(ht, p.FeeMsat, "fee should be 0")
|
require.Zero(ht, p.FeeMsat, "fee should be 0")
|
||||||
|
|
||||||
// Finally, verify that the payment request returned by the rpc matches
|
// Now verify that the payment request returned by the rpc matches the
|
||||||
// the invoice that we paid.
|
// invoice that we paid.
|
||||||
require.Equal(ht, invoiceResp.PaymentRequest, p.PaymentRequest,
|
require.Equal(ht, invoiceResp.PaymentRequest, p.PaymentRequest,
|
||||||
"incorrect payreq")
|
"incorrect payreq")
|
||||||
|
|
||||||
|
// We now check the timestamp filters in `ListPayments`.
|
||||||
|
//
|
||||||
|
// Use a start date long time ago should return us the payment.
|
||||||
|
req := &lnrpc.ListPaymentsRequest{
|
||||||
|
CreationDateStart: 1227035905,
|
||||||
|
}
|
||||||
|
resp := alice.RPC.ListPayments(req)
|
||||||
|
require.Len(ht, resp.Payments, 1)
|
||||||
|
|
||||||
|
// Use an end date long time ago should return us nothing.
|
||||||
|
req = &lnrpc.ListPaymentsRequest{
|
||||||
|
CreationDateEnd: 1227035905,
|
||||||
|
}
|
||||||
|
resp = alice.RPC.ListPayments(req)
|
||||||
|
require.Empty(ht, resp.Payments)
|
||||||
|
|
||||||
|
// Use a start date far in the future should return us nothing.
|
||||||
|
req = &lnrpc.ListPaymentsRequest{
|
||||||
|
CreationDateStart: 5392552705,
|
||||||
|
}
|
||||||
|
resp = alice.RPC.ListPayments(req)
|
||||||
|
require.Empty(ht, resp.Payments)
|
||||||
|
|
||||||
|
// Use an end date far in the future should return us the payment.
|
||||||
|
req = &lnrpc.ListPaymentsRequest{
|
||||||
|
CreationDateEnd: 5392552705,
|
||||||
|
}
|
||||||
|
resp = alice.RPC.ListPayments(req)
|
||||||
|
require.Len(ht, resp.Payments, 1)
|
||||||
|
|
||||||
|
// We now do the same check for `ListInvoices`
|
||||||
|
//
|
||||||
|
// Use a start date long time ago should return us the invoice.
|
||||||
|
invReq := &lnrpc.ListInvoiceRequest{
|
||||||
|
CreationDateStart: 1227035905,
|
||||||
|
}
|
||||||
|
invResp := bob.RPC.ListInvoices(invReq)
|
||||||
|
require.Len(ht, invResp.Invoices, 1)
|
||||||
|
|
||||||
|
// Use an end date long time ago should return us nothing.
|
||||||
|
invReq = &lnrpc.ListInvoiceRequest{
|
||||||
|
CreationDateEnd: 1227035905,
|
||||||
|
}
|
||||||
|
invResp = bob.RPC.ListInvoices(invReq)
|
||||||
|
require.Empty(ht, invResp.Invoices)
|
||||||
|
|
||||||
|
// Use a start date far in the future should return us nothing.
|
||||||
|
invReq = &lnrpc.ListInvoiceRequest{
|
||||||
|
CreationDateStart: 5392552705,
|
||||||
|
}
|
||||||
|
invResp = bob.RPC.ListInvoices(invReq)
|
||||||
|
require.Empty(ht, invResp.Invoices)
|
||||||
|
|
||||||
|
// Use an end date far in the future should return us the invoice.
|
||||||
|
invReq = &lnrpc.ListInvoiceRequest{
|
||||||
|
CreationDateEnd: 5392552705,
|
||||||
|
}
|
||||||
|
invResp = bob.RPC.ListInvoices(invReq)
|
||||||
|
require.Len(ht, invResp.Invoices, 1)
|
||||||
|
|
||||||
// Delete all payments from Alice. DB should have no payments.
|
// Delete all payments from Alice. DB should have no payments.
|
||||||
alice.RPC.DeleteAllPayments()
|
alice.RPC.DeleteAllPayments()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user