diff --git a/autopilot/prefattach_test.go b/autopilot/prefattach_test.go index b6793fa5f..4e1bbf7b1 100644 --- a/autopilot/prefattach_test.go +++ b/autopilot/prefattach_test.go @@ -36,7 +36,7 @@ type testDBGraph struct { } func newDiskChanGraph(t *testing.T) (testGraph, error) { - graphDB := graphdb.MakeTestGraphNew(t) + graphDB := graphdb.MakeTestGraph(t) require.NoError(t, graphDB.Start()) t.Cleanup(func() { require.NoError(t, graphDB.Stop()) diff --git a/graph/builder_test.go b/graph/builder_test.go index 048e1e22b..a27605269 100644 --- a/graph/builder_test.go +++ b/graph/builder_test.go @@ -1375,7 +1375,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 := graphdb.MakeTestGraphNew( + graph := graphdb.MakeTestGraph( t, graphdb.WithUseGraphCache(useCache), ) @@ -1753,7 +1753,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, testAddrs = append(testAddrs, testAddr) // Next, create a temporary graph database for usage within the test. - graph := graphdb.MakeTestGraphNew( + graph := graphdb.MakeTestGraph( t, graphdb.WithUseGraphCache(useCache), ) diff --git a/graph/db/graph.go b/graph/db/graph.go index 692406096..922adef53 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -594,7 +594,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(ctx context.Context, return nil } -// MakeTestGraphNew creates a new instance of the ChannelGraph for testing +// MakeTestGraph creates a new instance of the ChannelGraph for testing // purposes. The backing V1Store implementation depends on the version of // NewTestDB included in the current build. // @@ -603,7 +603,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(ctx context.Context, // implemented, unit tests will be switched to use this function instead of // the existing MakeTestGraph helper. Once only this function is used, the // existing MakeTestGraph function will be removed and this one will be renamed. -func MakeTestGraphNew(t testing.TB, +func MakeTestGraph(t testing.TB, opts ...ChanGraphOption) *ChannelGraph { t.Helper() diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 7d995355d..d86a2f65c 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -101,7 +101,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test basic insertion/deletion for vertexes from the // graph, so we'll create a test vertex to start with. @@ -264,7 +264,7 @@ func TestPartialNode(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // To insert a partial node, we need to add a channel edge that has // node keys for nodes we are not yet aware @@ -332,7 +332,7 @@ func TestAliasLookup(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test the alias index within the database, so first // create a new test node. @@ -363,7 +363,7 @@ func TestSourceNode(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test the setting/getting of the source node, so we // first create a fake node to use within the test. @@ -390,7 +390,7 @@ func TestEdgeInsertionDeletion(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test the insertion/deletion of edges, so we create two // vertexes to connect. @@ -513,7 +513,7 @@ func TestDisconnectBlockAtHeight(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) sourceNode := createTestVertex(t) if err := graph.SetSourceNode(ctx, sourceNode); err != nil { @@ -810,7 +810,7 @@ func TestEdgeInfoUpdates(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test the update of edges inserted into the database, so // we create two vertexes to connect. @@ -1128,7 +1128,7 @@ func TestAddEdgeProof(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // Add an edge with no proof. node1 := createTestVertex(t) @@ -1187,7 +1187,7 @@ func TestForEachSourceNodeChannel(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // Create a source node (A) and set it as such in the DB. nodeA := createTestVertex(t) @@ -1275,7 +1275,7 @@ func TestForEachSourceNodeChannel(t *testing.T) { func TestGraphTraversal(t *testing.T) { t.Parallel() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test some of the graph traversal capabilities within // the DB, so we'll create a series of fake nodes to insert into the @@ -1370,7 +1370,7 @@ func TestGraphTraversal(t *testing.T) { func TestGraphTraversalCacheable(t *testing.T) { t.Parallel() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test some of the graph traversal capabilities within // the DB, so we'll create a series of fake nodes to insert into the @@ -1440,7 +1440,7 @@ func TestGraphTraversalCacheable(t *testing.T) { func TestGraphCacheTraversal(t *testing.T) { t.Parallel() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test some of the graph traversal capabilities within // the DB, so we'll create a series of fake nodes to insert into the @@ -1685,7 +1685,7 @@ func TestGraphPruning(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) sourceNode := createTestVertex(t) if err := graph.SetSourceNode(ctx, sourceNode); err != nil { @@ -1875,7 +1875,7 @@ func TestHighestChanID(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // If we don't yet have any channels in the database, then we should // get a channel ID of zero if we ask for the highest channel ID. @@ -1935,7 +1935,7 @@ func TestChanUpdatesInHorizon(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // If we issue an arbitrary query before any channel updates are // inserted in the database, we should get zero results. @@ -2093,7 +2093,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) startTime := time.Unix(1234, 0) endTime := startTime @@ -2196,7 +2196,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) { func TestFilterKnownChanIDsZombieRevival(t *testing.T) { t.Parallel() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) var ( scid1 = lnwire.ShortChannelID{BlockHeight: 1} @@ -2262,7 +2262,7 @@ func TestFilterKnownChanIDs(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) isZombieUpdate := func(updateTime1 time.Time, updateTime2 time.Time) bool { @@ -2440,7 +2440,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) node1 := createTestVertex(t) require.NoError(t, graph.AddLightningNode(ctx, node1)) @@ -2729,7 +2729,7 @@ func TestFilterChannelRange(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'll first populate our graph with two nodes. All channels created // below will be made between these two nodes. @@ -2948,7 +2948,7 @@ func TestFetchChanInfos(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'll first populate our graph with two nodes. All channels created // below will be made between these two nodes. @@ -3051,7 +3051,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // Create two nodes. node1 := createTestVertex(t) @@ -3147,7 +3147,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // The update index only applies to the bbolt graph. boltStore, ok := graph.V1Store.(*KVStore) @@ -3295,7 +3295,7 @@ func TestPruneGraphNodes(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'll start off by inserting our source node, to ensure that it's // the only node left after we prune the graph. @@ -3361,7 +3361,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // To start, we'll create two nodes, and only add one of them to the // channel graph. @@ -3400,7 +3400,7 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'll first populate our graph with a single node that will be // removed shortly. @@ -3469,19 +3469,19 @@ func TestNodeIsPublic(t *testing.T) { // We'll need to create a separate database and channel graph for each // participant to replicate real-world scenarios (private edges being in // some graphs but not others, etc.). - aliceGraph := MakeTestGraphNew(t) + aliceGraph := MakeTestGraph(t) aliceNode := createTestVertex(t) if err := aliceGraph.SetSourceNode(ctx, aliceNode); err != nil { t.Fatalf("unable to set source node: %v", err) } - bobGraph := MakeTestGraphNew(t) + bobGraph := MakeTestGraph(t) bobNode := createTestVertex(t) if err := bobGraph.SetSourceNode(ctx, bobNode); err != nil { t.Fatalf("unable to set source node: %v", err) } - carolGraph := MakeTestGraphNew(t) + carolGraph := MakeTestGraph(t) carolNode := createTestVertex(t) if err := carolGraph.SetSourceNode(ctx, carolNode); err != nil { t.Fatalf("unable to set source node: %v", err) @@ -3596,7 +3596,7 @@ func TestDisabledChannelIDs(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // Create first node and add it to the graph. node1 := createTestVertex(t) @@ -3681,7 +3681,7 @@ func TestEdgePolicyMissingMaxHtcl(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // This test currently directly edits the bytes stored in the bbolt DB. boltStore, ok := graph.V1Store.(*KVStore) @@ -3828,7 +3828,7 @@ func TestGraphZombieIndex(t *testing.T) { ctx := context.Background() // We'll start by creating our test graph along with a test edge. - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) node1 := createTestVertex(t) node2 := createTestVertex(t) @@ -4010,7 +4010,7 @@ func TestBatchedAddChannelEdge(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) sourceNode := createTestVertex(t) require.Nil(t, graph.SetSourceNode(ctx, sourceNode)) @@ -4087,7 +4087,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // We'd like to test the update of edges inserted into the database, so // we create two vertexes to connect. @@ -4137,7 +4137,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) { // BenchmarkForEachChannel is a benchmark test that measures the number of // allocations and the total memory consumed by the full graph traversal. func BenchmarkForEachChannel(b *testing.B) { - graph := MakeTestGraphNew(b) + graph := MakeTestGraph(b) const numNodes = 100 const numChannels = 4 @@ -4190,7 +4190,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) { t.Parallel() ctx := context.Background() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) // Unset the channel graph cache to simulate the user running with the // option turned off. @@ -4325,7 +4325,7 @@ func TestGraphLoading(t *testing.T) { func TestClosedScid(t *testing.T) { t.Parallel() - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) scid := lnwire.ShortChannelID{} @@ -4362,7 +4362,7 @@ func TestLightningNodePersistence(t *testing.T) { ctx := context.Background() // Create a new test graph instance. - graph := MakeTestGraphNew(t) + graph := MakeTestGraph(t) nodeAnnBytes, err := hex.DecodeString(testNodeAnn) require.NoError(t, err) diff --git a/graph/notifications_test.go b/graph/notifications_test.go index 4f99a517c..e7d081c63 100644 --- a/graph/notifications_test.go +++ b/graph/notifications_test.go @@ -1059,7 +1059,7 @@ type testCtx struct { func createTestCtxSingleNode(t *testing.T, startingHeight uint32) *testCtx { - graph := graphdb.MakeTestGraphNew(t) + graph := graphdb.MakeTestGraph(t) sourceNode := createTestNode(t) require.NoError(t, diff --git a/peer/test_utils.go b/peer/test_utils.go index 37ffc6e30..673eceed8 100644 --- a/peer/test_utils.go +++ b/peer/test_utils.go @@ -602,7 +602,7 @@ func createTestPeer(t *testing.T) *peerTestCtx { const chanActiveTimeout = time.Minute - dbAliceGraph := graphdb.MakeTestGraphNew(t) + dbAliceGraph := graphdb.MakeTestGraph(t) require.NoError(t, dbAliceGraph.Start()) t.Cleanup(func() { require.NoError(t, dbAliceGraph.Stop()) diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 45faedaf1..eea1bb22e 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -160,7 +160,7 @@ func makeTestGraph(t *testing.T, useCache bool) (*graphdb.ChannelGraph, kvdb.Backend, error) { // Create channelgraph for the first time. - graph := graphdb.MakeTestGraphNew( + graph := graphdb.MakeTestGraph( t, graphdb.WithUseGraphCache(useCache), ) require.NoError(t, graph.Start())