graph/db: let MakeTestGraph take ChanGraphOptions

Currently none of the calls to MakeTestGraph make use of the
KVStoreOptionModifier options but later on we will want to make use of
the `WithUseGraphCache` ChannelGraphOption and so we take this
opportunity to switch out the functional parameters that the helper
function takes.
This commit is contained in:
Elle Mouton committed 2025-05-22 14:14:42 +02:00
1 parent 7288f280f6
commit 7a348e324d
1 file changed
+4 -11
+4 -11
View File
@@ -4707,16 +4707,9 @@ func (c *chanGraphNodeTx) ForEachChannel(f func(*models.ChannelEdgeInfo,
) )
} }
// MakeTestGraph creates a new instance of the KVStore for testing // MakeTestGraph creates a new instance of the ChannelGraph for testing
// purposes. // purposes.
func MakeTestGraph(t testing.TB, func MakeTestGraph(t testing.TB, opts ...ChanGraphOption) *ChannelGraph {
modifiers ...KVStoreOptionModifier) *ChannelGraph {
opts := DefaultOptions()
for _, modifier := range modifiers {
modifier(opts)
}
// Next, create KVStore for the first time. // Next, create KVStore for the first time.
backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr") backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr")
t.Cleanup(backendCleanup) t.Cleanup(backendCleanup)
@@ -4725,10 +4718,10 @@ func MakeTestGraph(t testing.TB,
require.NoError(t, backend.Close()) require.NoError(t, backend.Close())
}) })
graphStore, err := NewKVStore(backend, modifiers...) graphStore, err := NewKVStore(backend)
require.NoError(t, err) require.NoError(t, err)
graph, err := NewChannelGraph(graphStore) graph, err := NewChannelGraph(graphStore, opts...)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, graph.Start()) require.NoError(t, graph.Start())
t.Cleanup(func() { t.Cleanup(func() {