mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
multi: rename FeePreference
to FeeEstimateInfo
Results from running, ``` gofmt -d -w -r 'FeePreference -> FeeEstimateInfo' . ```
This commit is contained in:
parent
6ff6c86155
commit
530eed92a0
@ -115,7 +115,7 @@ func (c *anchorResolver) Resolve() (ContractResolver, error) {
|
|||||||
resultChan, err := c.Sweeper.SweepInput(
|
resultChan, err := c.Sweeper.SweepInput(
|
||||||
&anchorInput,
|
&anchorInput,
|
||||||
sweep.Params{
|
sweep.Params{
|
||||||
Fee: sweep.FeePreference{
|
Fee: sweep.FeeEstimateInfo{
|
||||||
FeeRate: relayFeeRate,
|
FeeRate: relayFeeRate,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1359,7 +1359,7 @@ func (c *ChannelArbitrator) sweepAnchors(anchors *lnwallet.AnchorResolutions,
|
|||||||
_, err = c.cfg.Sweeper.SweepInput(
|
_, err = c.cfg.Sweeper.SweepInput(
|
||||||
&anchorInput,
|
&anchorInput,
|
||||||
sweep.Params{
|
sweep.Params{
|
||||||
Fee: sweep.FeePreference{
|
Fee: sweep.FeeEstimateInfo{
|
||||||
ConfTarget: deadline,
|
ConfTarget: deadline,
|
||||||
},
|
},
|
||||||
Force: force,
|
Force: force,
|
||||||
|
@ -351,7 +351,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
|
|||||||
// sweeper.
|
// sweeper.
|
||||||
c.log.Infof("sweeping commit output")
|
c.log.Infof("sweeping commit output")
|
||||||
|
|
||||||
feePref := sweep.FeePreference{ConfTarget: commitOutputConfTarget}
|
feePref := sweep.FeeEstimateInfo{ConfTarget: commitOutputConfTarget}
|
||||||
resultChan, err := c.Sweeper.SweepInput(inp, sweep.Params{Fee: feePref})
|
resultChan, err := c.Sweeper.SweepInput(inp, sweep.Params{Fee: feePref})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Errorf("unable to sweep input: %v", err)
|
c.log.Errorf("unable to sweep input: %v", err)
|
||||||
|
@ -141,7 +141,7 @@ func (s *mockSweeper) SweepInput(input input.Input, params sweep.Params) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *mockSweeper) CreateSweepTx(inputs []input.Input,
|
func (s *mockSweeper) CreateSweepTx(inputs []input.Input,
|
||||||
feePref sweep.FeePreference) (*wire.MsgTx, error) {
|
feePref sweep.FeeEstimateInfo) (*wire.MsgTx, error) {
|
||||||
|
|
||||||
// We will wait for the test to supply the sweep tx to return.
|
// We will wait for the test to supply the sweep tx to return.
|
||||||
sweepTx := <-s.createSweepTxChan
|
sweepTx := <-s.createSweepTxChan
|
||||||
|
@ -263,7 +263,7 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx() (
|
|||||||
_, err := h.Sweeper.SweepInput(
|
_, err := h.Sweeper.SweepInput(
|
||||||
&secondLevelInput,
|
&secondLevelInput,
|
||||||
sweep.Params{
|
sweep.Params{
|
||||||
Fee: sweep.FeePreference{
|
Fee: sweep.FeeEstimateInfo{
|
||||||
ConfTarget: secondLevelConfTarget,
|
ConfTarget: secondLevelConfTarget,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -375,7 +375,7 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx() (
|
|||||||
_, err = h.Sweeper.SweepInput(
|
_, err = h.Sweeper.SweepInput(
|
||||||
inp,
|
inp,
|
||||||
sweep.Params{
|
sweep.Params{
|
||||||
Fee: sweep.FeePreference{
|
Fee: sweep.FeeEstimateInfo{
|
||||||
ConfTarget: sweepConfTarget,
|
ConfTarget: sweepConfTarget,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -436,7 +436,7 @@ func (h *htlcSuccessResolver) resolveRemoteCommitOutput() (
|
|||||||
var err error
|
var err error
|
||||||
h.sweepTx, err = h.Sweeper.CreateSweepTx(
|
h.sweepTx, err = h.Sweeper.CreateSweepTx(
|
||||||
[]input.Input{inp},
|
[]input.Input{inp},
|
||||||
sweep.FeePreference{
|
sweep.FeeEstimateInfo{
|
||||||
ConfTarget: sweepConfTarget,
|
ConfTarget: sweepConfTarget,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -486,7 +486,7 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx() error {
|
|||||||
_, err := h.Sweeper.SweepInput(
|
_, err := h.Sweeper.SweepInput(
|
||||||
inp,
|
inp,
|
||||||
sweep.Params{
|
sweep.Params{
|
||||||
Fee: sweep.FeePreference{
|
Fee: sweep.FeeEstimateInfo{
|
||||||
ConfTarget: secondLevelConfTarget,
|
ConfTarget: secondLevelConfTarget,
|
||||||
},
|
},
|
||||||
Force: true,
|
Force: true,
|
||||||
@ -702,7 +702,7 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
|
|||||||
_, err = h.Sweeper.SweepInput(
|
_, err = h.Sweeper.SweepInput(
|
||||||
inp,
|
inp,
|
||||||
sweep.Params{
|
sweep.Params{
|
||||||
Fee: sweep.FeePreference{
|
Fee: sweep.FeeEstimateInfo{
|
||||||
ConfTarget: sweepConfTarget,
|
ConfTarget: sweepConfTarget,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -54,7 +54,7 @@ type UtxoSweeper interface {
|
|||||||
// that spends from them. This method also makes an accurate fee
|
// that spends from them. This method also makes an accurate fee
|
||||||
// estimate before generating the required witnesses.
|
// estimate before generating the required witnesses.
|
||||||
CreateSweepTx(inputs []input.Input,
|
CreateSweepTx(inputs []input.Input,
|
||||||
feePref sweep.FeePreference) (*wire.MsgTx, error)
|
feePref sweep.FeeEstimateInfo) (*wire.MsgTx, error)
|
||||||
|
|
||||||
// RelayFeePerKW returns the minimum fee rate required for transactions
|
// RelayFeePerKW returns the minimum fee rate required for transactions
|
||||||
// to be relayed.
|
// to be relayed.
|
||||||
|
@ -823,7 +823,7 @@ func (u *UtxoNursery) sweepMatureOutputs(classHeight uint32,
|
|||||||
utxnLog.Infof("Sweeping %v CSV-delayed outputs with sweep tx for "+
|
utxnLog.Infof("Sweeping %v CSV-delayed outputs with sweep tx for "+
|
||||||
"height %v", len(kgtnOutputs), classHeight)
|
"height %v", len(kgtnOutputs), classHeight)
|
||||||
|
|
||||||
feePref := sweep.FeePreference{ConfTarget: kgtnOutputConfTarget}
|
feePref := sweep.FeeEstimateInfo{ConfTarget: kgtnOutputConfTarget}
|
||||||
for _, output := range kgtnOutputs {
|
for _, output := range kgtnOutputs {
|
||||||
// Create local copy to prevent pointer to loop variable to be
|
// Create local copy to prevent pointer to loop variable to be
|
||||||
// passed in with disastrous consequences.
|
// passed in with disastrous consequences.
|
||||||
|
@ -222,7 +222,7 @@ func CalculateFeeRate(satPerByte, satPerVByte uint64, targetConf uint32,
|
|||||||
|
|
||||||
// Based on the passed fee related parameters, we'll determine an
|
// Based on the passed fee related parameters, we'll determine an
|
||||||
// appropriate fee rate for this transaction.
|
// appropriate fee rate for this transaction.
|
||||||
feePref := sweep.FeePreference{
|
feePref := sweep.FeeEstimateInfo{
|
||||||
ConfTarget: targetConf,
|
ConfTarget: targetConf,
|
||||||
FeeRate: satPerKw,
|
FeeRate: satPerKw,
|
||||||
}
|
}
|
||||||
|
@ -965,7 +965,7 @@ func (w *WalletKit) BumpFee(ctx context.Context,
|
|||||||
in.SatPerByte * 1000,
|
in.SatPerByte * 1000,
|
||||||
).FeePerKWeight()
|
).FeePerKWeight()
|
||||||
}
|
}
|
||||||
feePreference := sweep.FeePreference{
|
feePreference := sweep.FeeEstimateInfo{
|
||||||
ConfTarget: uint32(in.TargetConf),
|
ConfTarget: uint32(in.TargetConf),
|
||||||
FeeRate: satPerKw,
|
FeeRate: satPerKw,
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1175,7 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
|
|||||||
// Query the fee estimator for the fee rate for the given confirmation
|
// Query the fee estimator for the fee rate for the given confirmation
|
||||||
// target.
|
// target.
|
||||||
target := in.TargetConf
|
target := in.TargetConf
|
||||||
feePref := sweep.FeePreference{
|
feePref := sweep.FeeEstimateInfo{
|
||||||
ConfTarget: uint32(target),
|
ConfTarget: uint32(target),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ type Params struct {
|
|||||||
// Fee is the fee preference of the client who requested the input to be
|
// Fee is the fee preference of the client who requested the input to be
|
||||||
// swept. If a confirmation target is specified, then we'll map it into
|
// swept. If a confirmation target is specified, then we'll map it into
|
||||||
// a fee rate whenever we attempt to cluster inputs for a sweep.
|
// a fee rate whenever we attempt to cluster inputs for a sweep.
|
||||||
Fee FeePreference
|
Fee FeeEstimateInfo
|
||||||
|
|
||||||
// Force indicates whether the input should be swept regardless of
|
// Force indicates whether the input should be swept regardless of
|
||||||
// whether it is economical to do so.
|
// whether it is economical to do so.
|
||||||
@ -84,7 +84,7 @@ type ParamsUpdate struct {
|
|||||||
// Fee is the fee preference of the client who requested the input to be
|
// Fee is the fee preference of the client who requested the input to be
|
||||||
// swept. If a confirmation target is specified, then we'll map it into
|
// swept. If a confirmation target is specified, then we'll map it into
|
||||||
// a fee rate whenever we attempt to cluster inputs for a sweep.
|
// a fee rate whenever we attempt to cluster inputs for a sweep.
|
||||||
Fee FeePreference
|
Fee FeeEstimateInfo
|
||||||
|
|
||||||
// Force indicates whether the input should be swept regardless of
|
// Force indicates whether the input should be swept regardless of
|
||||||
// whether it is economical to do so.
|
// whether it is economical to do so.
|
||||||
@ -1426,7 +1426,7 @@ func (s *UtxoSweeper) handleUpdateReq(req *updateReq) (
|
|||||||
// - Thwart future possible fee sniping attempts.
|
// - Thwart future possible fee sniping attempts.
|
||||||
// - Make us blend in with the bitcoind wallet.
|
// - Make us blend in with the bitcoind wallet.
|
||||||
func (s *UtxoSweeper) CreateSweepTx(inputs []input.Input,
|
func (s *UtxoSweeper) CreateSweepTx(inputs []input.Input,
|
||||||
feePref FeePreference) (*wire.MsgTx, error) {
|
feePref FeeEstimateInfo) (*wire.MsgTx, error) {
|
||||||
|
|
||||||
feePerKw, err := feePref.Estimate(
|
feePerKw, err := feePref.Estimate(
|
||||||
s.cfg.FeeEstimator, s.cfg.MaxFeeRate.FeePerKWeight(),
|
s.cfg.FeeEstimator, s.cfg.MaxFeeRate.FeePerKWeight(),
|
||||||
|
@ -31,7 +31,7 @@ var (
|
|||||||
|
|
||||||
testMaxInputsPerTx = 3
|
testMaxInputsPerTx = 3
|
||||||
|
|
||||||
defaultFeePref = Params{Fee: FeePreference{ConfTarget: 1}}
|
defaultFeePref = Params{Fee: FeeEstimateInfo{ConfTarget: 1}}
|
||||||
)
|
)
|
||||||
|
|
||||||
type sweeperTestContext struct {
|
type sweeperTestContext struct {
|
||||||
@ -432,7 +432,7 @@ func TestWalletUtxo(t *testing.T) {
|
|||||||
|
|
||||||
_, err := ctx.sweeper.SweepInput(
|
_, err := ctx.sweeper.SweepInput(
|
||||||
&dustInput,
|
&dustInput,
|
||||||
Params{Fee: FeePreference{FeeRate: chainfee.FeePerKwFloor}},
|
Params{Fee: FeeEstimateInfo{FeeRate: chainfee.FeePerKwFloor}},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -926,11 +926,11 @@ func TestDifferentFeePreferences(t *testing.T) {
|
|||||||
// with the higher fee preference, and the last with the lower. We do
|
// with the higher fee preference, and the last with the lower. We do
|
||||||
// this to ensure the sweeper can broadcast distinct transactions for
|
// this to ensure the sweeper can broadcast distinct transactions for
|
||||||
// each sweep with a different fee preference.
|
// each sweep with a different fee preference.
|
||||||
lowFeePref := FeePreference{ConfTarget: 12}
|
lowFeePref := FeeEstimateInfo{ConfTarget: 12}
|
||||||
lowFeeRate := chainfee.SatPerKWeight(5000)
|
lowFeeRate := chainfee.SatPerKWeight(5000)
|
||||||
ctx.estimator.blocksToFee[lowFeePref.ConfTarget] = lowFeeRate
|
ctx.estimator.blocksToFee[lowFeePref.ConfTarget] = lowFeeRate
|
||||||
|
|
||||||
highFeePref := FeePreference{ConfTarget: 6}
|
highFeePref := FeeEstimateInfo{ConfTarget: 6}
|
||||||
highFeeRate := chainfee.SatPerKWeight(10000)
|
highFeeRate := chainfee.SatPerKWeight(10000)
|
||||||
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
|
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
|
||||||
|
|
||||||
@ -995,12 +995,12 @@ func TestPendingInputs(t *testing.T) {
|
|||||||
highFeeRate = 10000
|
highFeeRate = 10000
|
||||||
)
|
)
|
||||||
|
|
||||||
lowFeePref := FeePreference{
|
lowFeePref := FeeEstimateInfo{
|
||||||
ConfTarget: 12,
|
ConfTarget: 12,
|
||||||
}
|
}
|
||||||
ctx.estimator.blocksToFee[lowFeePref.ConfTarget] = lowFeeRate
|
ctx.estimator.blocksToFee[lowFeePref.ConfTarget] = lowFeeRate
|
||||||
|
|
||||||
highFeePref := FeePreference{
|
highFeePref := FeeEstimateInfo{
|
||||||
ConfTarget: 6,
|
ConfTarget: 6,
|
||||||
}
|
}
|
||||||
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
|
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
|
||||||
@ -1060,7 +1060,7 @@ func TestPendingInputs(t *testing.T) {
|
|||||||
func TestBumpFeeRBF(t *testing.T) {
|
func TestBumpFeeRBF(t *testing.T) {
|
||||||
ctx := createSweeperTestContext(t)
|
ctx := createSweeperTestContext(t)
|
||||||
|
|
||||||
lowFeePref := FeePreference{ConfTarget: 144}
|
lowFeePref := FeeEstimateInfo{ConfTarget: 144}
|
||||||
lowFeeRate := chainfee.FeePerKwFloor
|
lowFeeRate := chainfee.FeePerKwFloor
|
||||||
ctx.estimator.blocksToFee[lowFeePref.ConfTarget] = lowFeeRate
|
ctx.estimator.blocksToFee[lowFeePref.ConfTarget] = lowFeeRate
|
||||||
|
|
||||||
@ -1095,7 +1095,7 @@ func TestBumpFeeRBF(t *testing.T) {
|
|||||||
assertTxFeeRate(t, &lowFeeTx, lowFeeRate, changePk, &input)
|
assertTxFeeRate(t, &lowFeeTx, lowFeeRate, changePk, &input)
|
||||||
|
|
||||||
// We'll then attempt to bump its fee rate.
|
// We'll then attempt to bump its fee rate.
|
||||||
highFeePref := FeePreference{ConfTarget: 6}
|
highFeePref := FeeEstimateInfo{ConfTarget: 6}
|
||||||
highFeeRate := DefaultMaxFeeRate.FeePerKWeight()
|
highFeeRate := DefaultMaxFeeRate.FeePerKWeight()
|
||||||
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
|
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
|
||||||
|
|
||||||
@ -1132,7 +1132,7 @@ func TestExclusiveGroup(t *testing.T) {
|
|||||||
exclusiveGroup := uint64(1)
|
exclusiveGroup := uint64(1)
|
||||||
result, err := ctx.sweeper.SweepInput(
|
result, err := ctx.sweeper.SweepInput(
|
||||||
spendableInputs[i], Params{
|
spendableInputs[i], Params{
|
||||||
Fee: FeePreference{ConfTarget: 6},
|
Fee: FeeEstimateInfo{ConfTarget: 6},
|
||||||
ExclusiveGroup: &exclusiveGroup,
|
ExclusiveGroup: &exclusiveGroup,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -1209,7 +1209,7 @@ func TestCpfp(t *testing.T) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
feePref := FeePreference{ConfTarget: 6}
|
feePref := FeeEstimateInfo{ConfTarget: 6}
|
||||||
result, err := ctx.sweeper.SweepInput(
|
result, err := ctx.sweeper.SweepInput(
|
||||||
&input, Params{Fee: feePref, Force: true},
|
&input, Params{Fee: feePref, Force: true},
|
||||||
)
|
)
|
||||||
@ -1564,7 +1564,7 @@ func TestLockTimes(t *testing.T) {
|
|||||||
|
|
||||||
result, err := ctx.sweeper.SweepInput(
|
result, err := ctx.sweeper.SweepInput(
|
||||||
inp, Params{
|
inp, Params{
|
||||||
Fee: FeePreference{ConfTarget: 6},
|
Fee: FeeEstimateInfo{ConfTarget: 6},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1582,7 +1582,7 @@ func TestLockTimes(t *testing.T) {
|
|||||||
inp := spendableInputs[i+numSweeps*2]
|
inp := spendableInputs[i+numSweeps*2]
|
||||||
result, err := ctx.sweeper.SweepInput(
|
result, err := ctx.sweeper.SweepInput(
|
||||||
inp, Params{
|
inp, Params{
|
||||||
Fee: FeePreference{ConfTarget: 6},
|
Fee: FeeEstimateInfo{ConfTarget: 6},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2027,7 +2027,9 @@ func TestRequiredTxOuts(t *testing.T) {
|
|||||||
for _, inp := range testCase.inputs {
|
for _, inp := range testCase.inputs {
|
||||||
result, err := ctx.sweeper.SweepInput(
|
result, err := ctx.sweeper.SweepInput(
|
||||||
inp, Params{
|
inp, Params{
|
||||||
Fee: FeePreference{ConfTarget: 6},
|
Fee: FeeEstimateInfo{
|
||||||
|
ConfTarget: 6,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2141,7 +2143,7 @@ func TestClusterByLockTime(t *testing.T) {
|
|||||||
|
|
||||||
// Create a test param with a dummy fee preference. This is needed so
|
// Create a test param with a dummy fee preference. This is needed so
|
||||||
// `feeRateForPreference` won't throw an error.
|
// `feeRateForPreference` won't throw an error.
|
||||||
param := Params{Fee: FeePreference{ConfTarget: 1}}
|
param := Params{Fee: FeeEstimateInfo{ConfTarget: 1}}
|
||||||
|
|
||||||
// We begin the test by creating three clusters of inputs, the first
|
// We begin the test by creating three clusters of inputs, the first
|
||||||
// cluster has a locktime of 1, the second has a locktime of 2, and the
|
// cluster has a locktime of 1, the second has a locktime of 2, and the
|
||||||
@ -2316,7 +2318,7 @@ func TestGetInputLists(t *testing.T) {
|
|||||||
|
|
||||||
// Create a test param with a dummy fee preference. This is needed so
|
// Create a test param with a dummy fee preference. This is needed so
|
||||||
// `feeRateForPreference` won't throw an error.
|
// `feeRateForPreference` won't throw an error.
|
||||||
param := Params{Fee: FeePreference{ConfTarget: 1}}
|
param := Params{Fee: FeeEstimateInfo{ConfTarget: 1}}
|
||||||
|
|
||||||
// Create a mock input and mock all the methods used in this test.
|
// Create a mock input and mock all the methods used in this test.
|
||||||
testInput := &input.MockInput{}
|
testInput := &input.MockInput{}
|
||||||
|
@ -33,9 +33,9 @@ var (
|
|||||||
ErrFeePreferenceConflict = errors.New("fee preference conflict")
|
ErrFeePreferenceConflict = errors.New("fee preference conflict")
|
||||||
)
|
)
|
||||||
|
|
||||||
// FeePreference allows callers to express their time value for inclusion of a
|
// FeeEstimateInfo allows callers to express their time value for inclusion of
|
||||||
// transaction into a block via either a confirmation target, or a fee rate.
|
// a transaction into a block via either a confirmation target, or a fee rate.
|
||||||
type FeePreference struct {
|
type FeeEstimateInfo struct {
|
||||||
// ConfTarget if non-zero, signals a fee preference expressed in the
|
// ConfTarget if non-zero, signals a fee preference expressed in the
|
||||||
// number of desired blocks between first broadcast, and confirmation.
|
// number of desired blocks between first broadcast, and confirmation.
|
||||||
ConfTarget uint32
|
ConfTarget uint32
|
||||||
@ -46,7 +46,7 @@ type FeePreference struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// String returns a human-readable string of the fee preference.
|
// String returns a human-readable string of the fee preference.
|
||||||
func (p FeePreference) String() string {
|
func (p FeeEstimateInfo) String() string {
|
||||||
if p.ConfTarget != 0 {
|
if p.ConfTarget != 0 {
|
||||||
return fmt.Sprintf("%v blocks", p.ConfTarget)
|
return fmt.Sprintf("%v blocks", p.ConfTarget)
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ func (p FeePreference) String() string {
|
|||||||
// Estimate returns a fee rate for the given fee preference. It ensures that
|
// Estimate returns a fee rate for the given fee preference. It ensures that
|
||||||
// the fee rate respects the bounds of the relay fee and the max fee rates, if
|
// the fee rate respects the bounds of the relay fee and the max fee rates, if
|
||||||
// specified.
|
// specified.
|
||||||
func (f FeePreference) Estimate(estimator chainfee.Estimator,
|
func (f FeeEstimateInfo) Estimate(estimator chainfee.Estimator,
|
||||||
maxFeeRate chainfee.SatPerKWeight) (chainfee.SatPerKWeight, error) {
|
maxFeeRate chainfee.SatPerKWeight) (chainfee.SatPerKWeight, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestFeePreferenceEstimate checks `Estimate` method works as expected.
|
// TestFeeEstimateInfo checks `Estimate` method works as expected.
|
||||||
func TestFeePreferenceEstimate(t *testing.T) {
|
func TestFeeEstimateInfo(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
dummyErr := errors.New("dummy")
|
dummyErr := errors.New("dummy")
|
||||||
@ -44,7 +44,7 @@ func TestFeePreferenceEstimate(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
setupMocker func()
|
setupMocker func()
|
||||||
feePref FeePreference
|
feePref FeeEstimateInfo
|
||||||
expectedFeeRate chainfee.SatPerKWeight
|
expectedFeeRate chainfee.SatPerKWeight
|
||||||
expectedErr error
|
expectedErr error
|
||||||
}{
|
}{
|
||||||
@ -52,14 +52,14 @@ func TestFeePreferenceEstimate(t *testing.T) {
|
|||||||
// When the fee preference is empty, we should see an
|
// When the fee preference is empty, we should see an
|
||||||
// error.
|
// error.
|
||||||
name: "empty fee preference",
|
name: "empty fee preference",
|
||||||
feePref: FeePreference{},
|
feePref: FeeEstimateInfo{},
|
||||||
expectedErr: ErrNoFeePreference,
|
expectedErr: ErrNoFeePreference,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// When the fee preference has conflicts, we should see
|
// When the fee preference has conflicts, we should see
|
||||||
// an error.
|
// an error.
|
||||||
name: "conflict fee preference",
|
name: "conflict fee preference",
|
||||||
feePref: FeePreference{
|
feePref: FeeEstimateInfo{
|
||||||
FeeRate: validFeeRate,
|
FeeRate: validFeeRate,
|
||||||
ConfTarget: conf,
|
ConfTarget: conf,
|
||||||
},
|
},
|
||||||
@ -74,12 +74,12 @@ func TestFeePreferenceEstimate(t *testing.T) {
|
|||||||
chainfee.SatPerKWeight(0), dummyErr,
|
chainfee.SatPerKWeight(0), dummyErr,
|
||||||
).Once()
|
).Once()
|
||||||
},
|
},
|
||||||
feePref: FeePreference{ConfTarget: conf},
|
feePref: FeeEstimateInfo{ConfTarget: conf},
|
||||||
expectedErr: dummyErr,
|
expectedErr: dummyErr,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// When FeePreference uses a too small value, we should
|
// When FeeEstimateInfo uses a too small value, we
|
||||||
// return an error.
|
// should return an error.
|
||||||
name: "fee rate below relay fee rate",
|
name: "fee rate below relay fee rate",
|
||||||
setupMocker: func() {
|
setupMocker: func() {
|
||||||
// Mock the relay fee rate.
|
// Mock the relay fee rate.
|
||||||
@ -87,11 +87,11 @@ func TestFeePreferenceEstimate(t *testing.T) {
|
|||||||
chainfee.SatPerKWeight(relayFeeRate),
|
chainfee.SatPerKWeight(relayFeeRate),
|
||||||
).Once()
|
).Once()
|
||||||
},
|
},
|
||||||
feePref: FeePreference{FeeRate: relayFeeRate - 1},
|
feePref: FeeEstimateInfo{FeeRate: relayFeeRate - 1},
|
||||||
expectedErr: ErrFeePreferenceTooLow,
|
expectedErr: ErrFeePreferenceTooLow,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// When FeePreference gives a too large value, we
|
// When FeeEstimateInfo gives a too large value, we
|
||||||
// should cap it at the max fee rate.
|
// should cap it at the max fee rate.
|
||||||
name: "fee rate above max fee rate",
|
name: "fee rate above max fee rate",
|
||||||
setupMocker: func() {
|
setupMocker: func() {
|
||||||
@ -100,7 +100,9 @@ func TestFeePreferenceEstimate(t *testing.T) {
|
|||||||
chainfee.SatPerKWeight(relayFeeRate),
|
chainfee.SatPerKWeight(relayFeeRate),
|
||||||
).Once()
|
).Once()
|
||||||
},
|
},
|
||||||
feePref: FeePreference{FeeRate: maxFeeRate + 1},
|
feePref: FeeEstimateInfo{
|
||||||
|
FeeRate: maxFeeRate + 1,
|
||||||
|
},
|
||||||
expectedFeeRate: maxFeeRate,
|
expectedFeeRate: maxFeeRate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -117,7 +119,7 @@ func TestFeePreferenceEstimate(t *testing.T) {
|
|||||||
chainfee.SatPerKWeight(relayFeeRate),
|
chainfee.SatPerKWeight(relayFeeRate),
|
||||||
).Once()
|
).Once()
|
||||||
},
|
},
|
||||||
feePref: FeePreference{ConfTarget: conf},
|
feePref: FeeEstimateInfo{ConfTarget: conf},
|
||||||
expectedFeeRate: validFeeRate,
|
expectedFeeRate: validFeeRate,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user