sweep+lnrpc: add new interface FeePreference

This commit adds a new interface `FeePreference` which makes it easier
to write unit tests and allows more customized implementation in
following commits.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:21 +08:00
1 parent 530eed92a0
commit 3bcac318eb
6 files changed
+108 -21

No files matched your search

+9 -2
View File
@@ -1,6 +1,7 @@
package contractcourt
import (
"fmt"
"testing"
"time"
@@ -127,9 +128,15 @@ func (s *mockSweeper) SweepInput(input input.Input, params sweep.Params) (
s.sweptInputs <- input
// TODO(yy): use `mock.Mock` to avoid the conversion.
fee, ok := params.Fee.(sweep.FeeEstimateInfo)
if !ok {
return nil, fmt.Errorf("unexpected fee type: %T", params.Fee)
}
// Update the deadlines used if it's set.
if params.Fee.ConfTarget != 0 {
s.deadlines = append(s.deadlines, int(params.Fee.ConfTarget))
if fee.ConfTarget != 0 {
s.deadlines = append(s.deadlines, int(fee.ConfTarget))
}
result := make(chan sweep.Result, 1)