mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
autopilot: update AttachmentHeuristics with context
Continue threading context through the autopilot system and remove the remaining context.TODOs.
This commit is contained in:
@@ -88,6 +88,8 @@ var chanGraphs = []struct {
|
||||
// TestPrefAttachmentSelectEmptyGraph ensures that when passed an
|
||||
// empty graph, the NodeSores function always returns a score of 0.
|
||||
func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
prefAttach := NewPrefAttachment()
|
||||
|
||||
// Create a random public key, which we will query to get a score for.
|
||||
@@ -108,7 +110,7 @@ func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
|
||||
// attempt to get the score for this one node.
|
||||
const walletFunds = btcutil.SatoshiPerBitcoin
|
||||
scores, err := prefAttach.NodeScores(
|
||||
graph, nil, walletFunds, nodes,
|
||||
ctx, graph, nil, walletFunds, nodes,
|
||||
)
|
||||
require.NoError(t1, err)
|
||||
|
||||
@@ -172,7 +174,7 @@ func TestPrefAttachmentSelectTwoVertexes(t *testing.T) {
|
||||
// attempt to get our candidates channel score given
|
||||
// the current state of the graph.
|
||||
candidates, err := prefAttach.NodeScores(
|
||||
graph, nil, maxChanSize, nodes,
|
||||
ctx, graph, nil, maxChanSize, nodes,
|
||||
)
|
||||
require.NoError(t1, err)
|
||||
|
||||
@@ -280,7 +282,7 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
|
||||
// result, the heuristic should try to greedily
|
||||
// allocate funds to channels.
|
||||
scores, err := prefAttach.NodeScores(
|
||||
graph, nil, maxChanSize, nodes,
|
||||
ctx, graph, nil, maxChanSize, nodes,
|
||||
)
|
||||
require.NoError(t1, err)
|
||||
|
||||
@@ -298,7 +300,7 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
|
||||
// candidates of that size.
|
||||
const remBalance = btcutil.SatoshiPerBitcoin * 0.5
|
||||
scores, err = prefAttach.NodeScores(
|
||||
graph, nil, remBalance, nodes,
|
||||
ctx, graph, nil, remBalance, nodes,
|
||||
)
|
||||
require.NoError(t1, err)
|
||||
|
||||
@@ -358,7 +360,7 @@ func TestPrefAttachmentSelectSkipNodes(t *testing.T) {
|
||||
// With our graph created, we'll now get the scores for
|
||||
// all nodes in the graph.
|
||||
scores, err := prefAttach.NodeScores(
|
||||
graph, nil, maxChanSize, nodes,
|
||||
ctx, graph, nil, maxChanSize, nodes,
|
||||
)
|
||||
require.NoError(t1, err)
|
||||
|
||||
@@ -386,7 +388,7 @@ func TestPrefAttachmentSelectSkipNodes(t *testing.T) {
|
||||
// then all nodes should have a score of zero, since we
|
||||
// already got channels to them.
|
||||
scores, err = prefAttach.NodeScores(
|
||||
graph, chans, maxChanSize, nodes,
|
||||
ctx, graph, chans, maxChanSize, nodes,
|
||||
)
|
||||
require.NoError(t1, err)
|
||||
|
||||
|
Reference in New Issue
Block a user