mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-30 17:50:58 +02:00
graph: test cleanup
Remove the kvdb.Backend return type of the `makeTestGraph` helper. This is in preparation for the helper being used to create a test graph backed by a DB other than bbolt.
This commit is contained in:
parent
424f63b310
commit
4ab0699e10
@ -1352,10 +1352,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
testAddrs = append(testAddrs, testAddr)
|
||||
|
||||
// Next, create a temporary graph database for usage within the test.
|
||||
graph, graphBackend, err := makeTestGraph(t, useCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
graph := makeTestGraph(t, useCache)
|
||||
|
||||
aliasMap := make(map[string]route.Vertex)
|
||||
privKeyMap := make(map[string]*btcec.PrivateKey)
|
||||
@ -1562,12 +1559,11 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
}
|
||||
|
||||
return &testGraphInstance{
|
||||
graph: graph,
|
||||
graphBackend: graphBackend,
|
||||
aliasMap: aliasMap,
|
||||
privKeyMap: privKeyMap,
|
||||
channelIDs: channelIDs,
|
||||
links: links,
|
||||
graph: graph,
|
||||
aliasMap: aliasMap,
|
||||
privKeyMap: privKeyMap,
|
||||
channelIDs: channelIDs,
|
||||
links: links,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -1730,10 +1726,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
testAddrs = append(testAddrs, testAddr)
|
||||
|
||||
// Next, create a temporary graph database for usage within the test.
|
||||
graph, graphBackend, err := makeTestGraph(t, useCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
graph := makeTestGraph(t, useCache)
|
||||
|
||||
aliasMap := make(map[string]route.Vertex)
|
||||
privKeyMap := make(map[string]*btcec.PrivateKey)
|
||||
@ -1947,11 +1940,10 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
}
|
||||
|
||||
return &testGraphInstance{
|
||||
graph: graph,
|
||||
graphBackend: graphBackend,
|
||||
aliasMap: aliasMap,
|
||||
privKeyMap: privKeyMap,
|
||||
links: links,
|
||||
graph: graph,
|
||||
aliasMap: aliasMap,
|
||||
privKeyMap: privKeyMap,
|
||||
links: links,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -1034,8 +1034,7 @@ type testCtx struct {
|
||||
func createTestCtxSingleNode(t *testing.T,
|
||||
startingHeight uint32) *testCtx {
|
||||
|
||||
graph, graphBackend, err := makeTestGraph(t, true)
|
||||
require.NoError(t, err, "failed to make test graph")
|
||||
graph := makeTestGraph(t, true)
|
||||
|
||||
sourceNode := createTestNode(t)
|
||||
|
||||
@ -1044,8 +1043,7 @@ func createTestCtxSingleNode(t *testing.T,
|
||||
)
|
||||
|
||||
graphInstance := &testGraphInstance{
|
||||
graph: graph,
|
||||
graphBackend: graphBackend,
|
||||
graph: graph,
|
||||
}
|
||||
|
||||
return createTestCtxFromGraphInstance(
|
||||
@ -1086,14 +1084,12 @@ func (c *testCtx) RestartBuilder(t *testing.T) {
|
||||
|
||||
// makeTestGraph creates a new instance of a channeldb.ChannelGraph for testing
|
||||
// purposes.
|
||||
func makeTestGraph(t *testing.T, useCache bool) (*graphdb.ChannelGraph,
|
||||
kvdb.Backend, error) {
|
||||
func makeTestGraph(t *testing.T, useCache bool) *graphdb.ChannelGraph {
|
||||
t.Helper()
|
||||
|
||||
// Create channelgraph for the first time.
|
||||
backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(backendCleanup)
|
||||
|
||||
@ -1101,20 +1097,17 @@ func makeTestGraph(t *testing.T, useCache bool) (*graphdb.ChannelGraph,
|
||||
&graphdb.Config{KVDB: backend},
|
||||
graphdb.WithUseGraphCache(useCache),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, graph.Start())
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, graph.Stop())
|
||||
})
|
||||
|
||||
return graph, backend, nil
|
||||
return graph
|
||||
}
|
||||
|
||||
type testGraphInstance struct {
|
||||
graph *graphdb.ChannelGraph
|
||||
graphBackend kvdb.Backend
|
||||
graph *graphdb.ChannelGraph
|
||||
|
||||
// aliasMap is a map from a node's alias to its public key. This type is
|
||||
// provided in order to allow easily look up from the human memorable
|
||||
|
Loading…
x
Reference in New Issue
Block a user