mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
This commit makes the `ClusterInputs` directly returning the `InputSet` so the sweeper doesn't know about the existence of `Cluster` interface. This way we can have a deeper interface as the sweeper only needs to interact with `Aggregator` only to get the final input sets, leaving the implementation details being managed by `SimpleAggregator` and future aggregators.
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package sweep
|
|
|
|
import (
|
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
type MockFeePreference struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Compile-time constraint to ensure MockFeePreference implements FeePreference.
|
|
var _ FeePreference = (*MockFeePreference)(nil)
|
|
|
|
func (m *MockFeePreference) String() string {
|
|
return "mock fee preference"
|
|
}
|
|
|
|
func (m *MockFeePreference) Estimate(estimator chainfee.Estimator,
|
|
maxFeeRate chainfee.SatPerKWeight) (chainfee.SatPerKWeight, error) {
|
|
|
|
args := m.Called(estimator, maxFeeRate)
|
|
|
|
if args.Get(0) == nil {
|
|
return 0, args.Error(1)
|
|
}
|
|
|
|
return args.Get(0).(chainfee.SatPerKWeight), args.Error(1)
|
|
}
|
|
|
|
type mockUtxoAggregator struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Compile-time constraint to ensure mockUtxoAggregator implements
|
|
// UtxoAggregator.
|
|
var _ UtxoAggregator = (*mockUtxoAggregator)(nil)
|
|
|
|
// ClusterInputs takes a list of inputs and groups them into clusters.
|
|
func (m *mockUtxoAggregator) ClusterInputs(wallet Wallet,
|
|
inputs pendingInputs) []InputSet {
|
|
|
|
args := m.Called(wallet, inputs)
|
|
|
|
return args.Get(0).([]InputSet)
|
|
}
|