graph/db: fix address fetching error

This commit is contained in:
Elle Mouton
2025-06-30 18:06:41 +02:00
parent 272a2db16c
commit 714e528a3a
2 changed files with 7 additions and 11 deletions

View File

@@ -190,17 +190,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
// Fetch the node and assert the empty addresses.
dbNode, err = graph.FetchLightningNode(ctx, testPub)
require.NoError(t, err)
// Temporarily have a special case for SQLStore, as currently, it does
// not correctly handle empty addresses. We assert this incorrect
// behaviour here in order to demonstrate the bug. This will be fixed in
// an upcoming commit.
if _, ok := graph.V1Store.(*SQLStore); ok {
require.Empty(t, dbNode.Addresses)
require.NotEqual(t, node.Addresses, dbNode.Addresses)
} else {
compareNodes(t, node, dbNode)
}
compareNodes(t, node, dbNode)
known, addrs, err = graph.AddrsForNode(ctx, pub)
require.NoError(t, err)

View File

@@ -3619,6 +3619,12 @@ func getNodeAddresses(ctx context.Context, db SQLQueries, nodePub []byte) (bool,
}
}
// If we have no addresses, then we'll return nil instead of an
// empty slice.
if len(addresses) == 0 {
addresses = nil
}
return true, addresses, nil
}