diff --git a/graph/builder_test.go b/graph/builder_test.go index b813c17e2..aed30e097 100644 --- a/graph/builder_test.go +++ b/graph/builder_test.go @@ -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 } diff --git a/graph/notifications_test.go b/graph/notifications_test.go index ff4649cfe..ace578376 100644 --- a/graph/notifications_test.go +++ b/graph/notifications_test.go @@ -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