mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 15:23:19 +02:00
sweep: pass default deadline height when clustering inputs
This commit changes the method `ClusterInputs` to also take a default deadline height. Previously, when calculating the default deadline height for a non-time sensitive input, we would first cluster it with other non-time sensitive inputs, then give it a deadline before we are about to `sweep`. This is now moved to the step where we decide to cluster inputs, allowing time-sensitive and non-sensitive inputs to be grouped together, if they happen to share the same deadline heights.
This commit is contained in:
@@ -39,6 +39,8 @@ var (
|
||||
wire.OutPoint{Hash: chainhash.Hash{}, Index: 11}: &SweeperInput{},
|
||||
wire.OutPoint{Hash: chainhash.Hash{}, Index: 12}: &SweeperInput{},
|
||||
}
|
||||
|
||||
testHeight = int32(800000)
|
||||
)
|
||||
|
||||
// TestMergeClusters check that we properly can merge clusters together,
|
||||
@@ -779,7 +781,7 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
||||
tc.setupMock()
|
||||
|
||||
// Call the method under test.
|
||||
result := b.createInputSets(tc.inputs)
|
||||
result := b.createInputSets(tc.inputs, testHeight)
|
||||
|
||||
// Validate the expected number of input sets are
|
||||
// returned.
|
||||
@@ -938,7 +940,8 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
|
||||
b := NewBudgetAggregator(estimator, DefaultMaxInputsPerTx)
|
||||
|
||||
// Call the method under test.
|
||||
result := b.ClusterInputs(inputs)
|
||||
defaultDeadline := testHeight + DefaultDeadlineDelta
|
||||
result := b.ClusterInputs(inputs, defaultDeadline)
|
||||
|
||||
// We expect four input sets to be returned, one for each deadline and
|
||||
// extra one for the exclusive input.
|
||||
@@ -949,7 +952,7 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
|
||||
require.Len(t, setExclusive.Inputs(), 1)
|
||||
|
||||
// Check the each of rest has exactly two inputs.
|
||||
deadlines := make(map[fn.Option[int32]]struct{})
|
||||
deadlines := make(map[int32]struct{})
|
||||
for _, set := range result[:3] {
|
||||
// We expect two inputs in each set.
|
||||
require.Len(t, set.Inputs(), 2)
|
||||
@@ -962,7 +965,7 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
|
||||
}
|
||||
|
||||
// We expect to see all three deadlines.
|
||||
require.Contains(t, deadlines, deadlineNone)
|
||||
require.Contains(t, deadlines, deadline1)
|
||||
require.Contains(t, deadlines, deadline2)
|
||||
require.Contains(t, deadlines, defaultDeadline)
|
||||
require.Contains(t, deadlines, deadline1.UnwrapOrFail(t))
|
||||
require.Contains(t, deadlines, deadline2.UnwrapOrFail(t))
|
||||
}
|
||||
|
Reference in New Issue
Block a user