Skip to content

Commit 714e528

Browse files
committed
graph/db: fix address fetching error
1 parent 272a2db commit 714e528

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

graph/db/graph_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
190190
// Fetch the node and assert the empty addresses.
191191
dbNode, err = graph.FetchLightningNode(ctx, testPub)
192192
require.NoError(t, err)
193-
194-
// Temporarily have a special case for SQLStore, as currently, it does
195-
// not correctly handle empty addresses. We assert this incorrect
196-
// behaviour here in order to demonstrate the bug. This will be fixed in
197-
// an upcoming commit.
198-
if _, ok := graph.V1Store.(*SQLStore); ok {
199-
require.Empty(t, dbNode.Addresses)
200-
require.NotEqual(t, node.Addresses, dbNode.Addresses)
201-
} else {
202-
compareNodes(t, node, dbNode)
203-
}
193+
compareNodes(t, node, dbNode)
204194

205195
known, addrs, err = graph.AddrsForNode(ctx, pub)
206196
require.NoError(t, err)

graph/db/sql_store.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,6 +3619,12 @@ func getNodeAddresses(ctx context.Context, db SQLQueries, nodePub []byte) (bool,
36193619
}
36203620
}
36213621

3622+
// If we have no addresses, then we'll return nil instead of an
3623+
// empty slice.
3624+
if len(addresses) == 0 {
3625+
addresses = nil
3626+
}
3627+
36223628
return true, addresses, nil
36233629
}
36243630

0 commit comments

Comments
 (0)