mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-11 19:47:30 +02:00
graph/db: remove kvdb.Backend from test helpers
Remove unused kvdb.Backend param from `randEdgePolicy` and `newEdgePolicy` test helpers.
This commit is contained in:
@@ -954,10 +954,10 @@ func assertEdgeWithPolicyInCache(t *testing.T, g *ChannelGraph,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func randEdgePolicy(chanID uint64, db kvdb.Backend) *models.ChannelEdgePolicy {
|
func randEdgePolicy(chanID uint64) *models.ChannelEdgePolicy {
|
||||||
update := prand.Int63()
|
update := prand.Int63()
|
||||||
|
|
||||||
return newEdgePolicy(chanID, db, update)
|
return newEdgePolicy(chanID, update)
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyEdgePolicy(p *models.ChannelEdgePolicy) *models.ChannelEdgePolicy {
|
func copyEdgePolicy(p *models.ChannelEdgePolicy) *models.ChannelEdgePolicy {
|
||||||
@@ -977,9 +977,7 @@ func copyEdgePolicy(p *models.ChannelEdgePolicy) *models.ChannelEdgePolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEdgePolicy(chanID uint64, db kvdb.Backend,
|
func newEdgePolicy(chanID uint64, updateTime int64) *models.ChannelEdgePolicy {
|
||||||
updateTime int64) *models.ChannelEdgePolicy {
|
|
||||||
|
|
||||||
return &models.ChannelEdgePolicy{
|
return &models.ChannelEdgePolicy{
|
||||||
ChannelID: chanID,
|
ChannelID: chanID,
|
||||||
LastUpdate: time.Unix(updateTime, 0),
|
LastUpdate: time.Unix(updateTime, 0),
|
||||||
@@ -1277,7 +1275,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
|||||||
|
|
||||||
// Create and add an edge with random data that points
|
// Create and add an edge with random data that points
|
||||||
// from node1 -> node2.
|
// from node1 -> node2.
|
||||||
edge := randEdgePolicy(chanID, graph.db)
|
edge := randEdgePolicy(chanID)
|
||||||
edge.ChannelFlags = 0
|
edge.ChannelFlags = 0
|
||||||
edge.ToNode = node2.PubKeyBytes
|
edge.ToNode = node2.PubKeyBytes
|
||||||
edge.SigBytes = testSig.Serialize()
|
edge.SigBytes = testSig.Serialize()
|
||||||
@@ -1285,7 +1283,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
|||||||
|
|
||||||
// Create another random edge that points from
|
// Create another random edge that points from
|
||||||
// node2 -> node1 this time.
|
// node2 -> node1 this time.
|
||||||
edge = randEdgePolicy(chanID, graph.db)
|
edge = randEdgePolicy(chanID)
|
||||||
edge.ChannelFlags = 1
|
edge.ChannelFlags = 1
|
||||||
edge.ToNode = node1.PubKeyBytes
|
edge.ToNode = node1.PubKeyBytes
|
||||||
edge.SigBytes = testSig.Serialize()
|
edge.SigBytes = testSig.Serialize()
|
||||||
@@ -1476,7 +1474,7 @@ func TestGraphPruning(t *testing.T) {
|
|||||||
|
|
||||||
// Create and add an edge with random data that points from
|
// Create and add an edge with random data that points from
|
||||||
// node_i -> node_i+1
|
// node_i -> node_i+1
|
||||||
edge := randEdgePolicy(chanID, graph.db)
|
edge := randEdgePolicy(chanID)
|
||||||
edge.ChannelFlags = 0
|
edge.ChannelFlags = 0
|
||||||
edge.ToNode = graphNodes[i].PubKeyBytes
|
edge.ToNode = graphNodes[i].PubKeyBytes
|
||||||
edge.SigBytes = testSig.Serialize()
|
edge.SigBytes = testSig.Serialize()
|
||||||
@@ -1486,7 +1484,7 @@ func TestGraphPruning(t *testing.T) {
|
|||||||
|
|
||||||
// Create another random edge that points from node_i+1 ->
|
// Create another random edge that points from node_i+1 ->
|
||||||
// node_i this time.
|
// node_i this time.
|
||||||
edge = randEdgePolicy(chanID, graph.db)
|
edge = randEdgePolicy(chanID)
|
||||||
edge.ChannelFlags = 1
|
edge.ChannelFlags = 1
|
||||||
edge.ToNode = graphNodes[i].PubKeyBytes
|
edge.ToNode = graphNodes[i].PubKeyBytes
|
||||||
edge.SigBytes = testSig.Serialize()
|
edge.SigBytes = testSig.Serialize()
|
||||||
@@ -1696,7 +1694,7 @@ func TestChanUpdatesInHorizon(t *testing.T) {
|
|||||||
endTime = endTime.Add(time.Second * 10)
|
endTime = endTime.Add(time.Second * 10)
|
||||||
|
|
||||||
edge1 := newEdgePolicy(
|
edge1 := newEdgePolicy(
|
||||||
chanID.ToUint64(), graph.db, edge1UpdateTime.Unix(),
|
chanID.ToUint64(), edge1UpdateTime.Unix(),
|
||||||
)
|
)
|
||||||
edge1.ChannelFlags = 0
|
edge1.ChannelFlags = 0
|
||||||
edge1.ToNode = node2.PubKeyBytes
|
edge1.ToNode = node2.PubKeyBytes
|
||||||
@@ -1706,7 +1704,7 @@ func TestChanUpdatesInHorizon(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
edge2 := newEdgePolicy(
|
edge2 := newEdgePolicy(
|
||||||
chanID.ToUint64(), graph.db, edge2UpdateTime.Unix(),
|
chanID.ToUint64(), edge2UpdateTime.Unix(),
|
||||||
)
|
)
|
||||||
edge2.ChannelFlags = 1
|
edge2.ChannelFlags = 1
|
||||||
edge2.ToNode = node1.PubKeyBytes
|
edge2.ToNode = node1.PubKeyBytes
|
||||||
@@ -2712,9 +2710,7 @@ func TestFetchChanInfos(t *testing.T) {
|
|||||||
updateTime := endTime
|
updateTime := endTime
|
||||||
endTime = updateTime.Add(time.Second * 10)
|
endTime = updateTime.Add(time.Second * 10)
|
||||||
|
|
||||||
edge1 := newEdgePolicy(
|
edge1 := newEdgePolicy(chanID.ToUint64(), updateTime.Unix())
|
||||||
chanID.ToUint64(), graph.db, updateTime.Unix(),
|
|
||||||
)
|
|
||||||
edge1.ChannelFlags = 0
|
edge1.ChannelFlags = 0
|
||||||
edge1.ToNode = node2.PubKeyBytes
|
edge1.ToNode = node2.PubKeyBytes
|
||||||
edge1.SigBytes = testSig.Serialize()
|
edge1.SigBytes = testSig.Serialize()
|
||||||
@@ -2722,9 +2718,7 @@ func TestFetchChanInfos(t *testing.T) {
|
|||||||
t.Fatalf("unable to update edge: %v", err)
|
t.Fatalf("unable to update edge: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
edge2 := newEdgePolicy(
|
edge2 := newEdgePolicy(chanID.ToUint64(), updateTime.Unix())
|
||||||
chanID.ToUint64(), graph.db, updateTime.Unix(),
|
|
||||||
)
|
|
||||||
edge2.ChannelFlags = 1
|
edge2.ChannelFlags = 1
|
||||||
edge2.ToNode = node1.PubKeyBytes
|
edge2.ToNode = node1.PubKeyBytes
|
||||||
edge2.SigBytes = testSig.Serialize()
|
edge2.SigBytes = testSig.Serialize()
|
||||||
@@ -2851,9 +2845,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
|||||||
// unknown.
|
// unknown.
|
||||||
updateTime := time.Unix(1234, 0)
|
updateTime := time.Unix(1234, 0)
|
||||||
|
|
||||||
edgePolicy := newEdgePolicy(
|
edgePolicy := newEdgePolicy(chanID.ToUint64(), updateTime.Unix())
|
||||||
chanID.ToUint64(), graph.db, updateTime.Unix(),
|
|
||||||
)
|
|
||||||
edgePolicy.ChannelFlags = 0
|
edgePolicy.ChannelFlags = 0
|
||||||
edgePolicy.ToNode = node2.PubKeyBytes
|
edgePolicy.ToNode = node2.PubKeyBytes
|
||||||
edgePolicy.SigBytes = testSig.Serialize()
|
edgePolicy.SigBytes = testSig.Serialize()
|
||||||
@@ -2866,9 +2858,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
|||||||
|
|
||||||
// Create second policy and assert that both policies are reported
|
// Create second policy and assert that both policies are reported
|
||||||
// as present.
|
// as present.
|
||||||
edgePolicy = newEdgePolicy(
|
edgePolicy = newEdgePolicy(chanID.ToUint64(), updateTime.Unix())
|
||||||
chanID.ToUint64(), graph.db, updateTime.Unix(),
|
|
||||||
)
|
|
||||||
edgePolicy.ChannelFlags = 1
|
edgePolicy.ChannelFlags = 1
|
||||||
edgePolicy.ToNode = node1.PubKeyBytes
|
edgePolicy.ToNode = node1.PubKeyBytes
|
||||||
edgePolicy.SigBytes = testSig.Serialize()
|
edgePolicy.SigBytes = testSig.Serialize()
|
||||||
@@ -2912,7 +2902,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
t.Fatalf("unable to add edge: %v", err)
|
t.Fatalf("unable to add edge: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
edge1 := randEdgePolicy(chanID.ToUint64(), graph.db)
|
edge1 := randEdgePolicy(chanID.ToUint64())
|
||||||
edge1.ChannelFlags = 0
|
edge1.ChannelFlags = 0
|
||||||
edge1.ToNode = node1.PubKeyBytes
|
edge1.ToNode = node1.PubKeyBytes
|
||||||
edge1.SigBytes = testSig.Serialize()
|
edge1.SigBytes = testSig.Serialize()
|
||||||
@@ -2921,7 +2911,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
edge1 = copyEdgePolicy(edge1) // Avoid read/write race conditions.
|
edge1 = copyEdgePolicy(edge1) // Avoid read/write race conditions.
|
||||||
|
|
||||||
edge2 := randEdgePolicy(chanID.ToUint64(), graph.db)
|
edge2 := randEdgePolicy(chanID.ToUint64())
|
||||||
edge2.ChannelFlags = 1
|
edge2.ChannelFlags = 1
|
||||||
edge2.ToNode = node2.PubKeyBytes
|
edge2.ToNode = node2.PubKeyBytes
|
||||||
edge2.SigBytes = testSig.Serialize()
|
edge2.SigBytes = testSig.Serialize()
|
||||||
@@ -3063,7 +3053,7 @@ func TestPruneGraphNodes(t *testing.T) {
|
|||||||
|
|
||||||
// We'll now insert an advertised edge, but it'll only be the edge that
|
// We'll now insert an advertised edge, but it'll only be the edge that
|
||||||
// points from the first to the second node.
|
// points from the first to the second node.
|
||||||
edge1 := randEdgePolicy(chanID.ToUint64(), graph.db)
|
edge1 := randEdgePolicy(chanID.ToUint64())
|
||||||
edge1.ChannelFlags = 0
|
edge1.ChannelFlags = 0
|
||||||
edge1.ToNode = node1.PubKeyBytes
|
edge1.ToNode = node1.PubKeyBytes
|
||||||
edge1.SigBytes = testSig.Serialize()
|
edge1.SigBytes = testSig.Serialize()
|
||||||
|
Reference in New Issue
Block a user