multi: rename MakeTestGraphNew to MakeTestGraph

This commit is contained in:
Elle Mouton committed 2025-06-26 10:12:30 +02:00
1 parent c06036d2b4
commit 3ccaacd16f
7 files changed
+46 -46

No files matched your search

+2 -2
View File
@@ -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()
+38 -38
View File
@@ -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)