sqldb+graph/db: implement SQLStore.NodeUpdatesInHorizon

In this commit we add the necessary SQL queries and then implement the
SQLStore's NodeUpdatesInHorizon method. This lets us run the
TestNodeUpdatesInHorizon unit tests against SQL backends.
This commit is contained in:
Elle Mouton committed 2025-05-27 18:36:59 +02:00
1 parent 7a120cb584
commit 86d48390ca
5 files changed
+102 -18

No files matched your search

+6 -18
View File
@@ -2080,7 +2080,7 @@ func TestChanUpdatesInHorizon(t *testing.T) {
func TestNodeUpdatesInHorizon(t *testing.T) {
t.Parallel()
graph := MakeTestGraph(t)
graph := MakeTestGraphNew(t)
startTime := time.Unix(1234, 0)
endTime := startTime
@@ -2091,10 +2091,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
time.Unix(999, 0), time.Unix(9999, 0),
)
require.NoError(t, err, "unable to query for node updates")
if len(nodeUpdates) != 0 {
t.Fatalf("expected 0 node updates, instead got %v",
len(nodeUpdates))
}
require.Len(t, nodeUpdates, 0)
// We'll create 10 node announcements, each with an update timestamp 10
// seconds after the other.
@@ -2113,9 +2110,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
nodeAnns = append(nodeAnns, *nodeAnn)
if err := graph.AddLightningNode(nodeAnn); err != nil {
t.Fatalf("unable to add lightning node: %v", err)
}
require.NoError(t, graph.AddLightningNode(nodeAnn))
}
queryCases := []struct {
@@ -2169,15 +2164,8 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
resp, err := graph.NodeUpdatesInHorizon(
queryCase.start, queryCase.end,
)
if err != nil {
t.Fatalf("unable to query for nodes: %v", err)
}
if len(resp) != len(queryCase.resp) {
t.Fatalf("expected %v nodes, got %v nodes",
len(queryCase.resp), len(resp))
}
require.NoError(t, err)
require.Len(t, resp, len(queryCase.resp))
for i := 0; i < len(resp); i++ {
compareNodes(t, &queryCase.resp[i], &resp[i])
@@ -3382,7 +3370,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
func TestNodePruningUpdateIndexDeletion(t *testing.T) {
t.Parallel()
graph := MakeTestGraph(t)
graph := MakeTestGraphNew(t)
// We'll first populate our graph with a single node that will be
// removed shortly.