diff --git a/lntest/fee_service.go b/lntest/fee_service.go index cee9ae0ab53..dd76495ef99 100644 --- a/lntest/fee_service.go +++ b/lntest/fee_service.go @@ -33,6 +33,9 @@ type WebFeeService interface { // target. SetFeeRate(feeRate chainfee.SatPerKWeight, conf uint32) + // SetMinRelayFeerate sets a min relay feerate. + SetMinRelayFeerate(fee chainfee.SatPerKVByte) + // Reset resets the fee rate map to the default value. Reset() } @@ -52,8 +55,9 @@ const ( type FeeService struct { *testing.T - feeRateMap map[uint32]uint32 - url string + feeRateMap map[uint32]uint32 + minRelayFeerate chainfee.SatPerKVByte + url string srv *http.Server wg sync.WaitGroup @@ -79,6 +83,7 @@ func NewFeeService(t *testing.T) *FeeService { f.feeRateMap = map[uint32]uint32{ feeServiceTarget: DefaultFeeRateSatPerKw, } + f.minRelayFeerate = chainfee.FeePerKwFloor.FeePerKVByte() listenAddr := fmt.Sprintf(":%v", port) mux := http.NewServeMux() @@ -114,9 +119,12 @@ func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) { bytes, err := json.Marshal( struct { - Fees map[uint32]uint32 `json:"fee_by_block_target"` + //nolint:lll + Fees map[uint32]uint32 `json:"fee_by_block_target"` + MinRelayFeerate chainfee.SatPerKVByte `json:"min_relay_feerate"` }{ - Fees: f.feeRateMap, + Fees: f.feeRateMap, + MinRelayFeerate: f.minRelayFeerate, }, ) require.NoErrorf(f, err, "cannot serialize estimates") @@ -143,6 +151,14 @@ func (f *FeeService) SetFeeRate(fee chainfee.SatPerKWeight, conf uint32) { f.feeRateMap[conf] = uint32(fee.FeePerKVByte()) } +// SetMinRelayFeerate sets a min relay feerate. +func (f *FeeService) SetMinRelayFeerate(fee chainfee.SatPerKVByte) { + f.lock.Lock() + defer f.lock.Unlock() + + f.minRelayFeerate = fee +} + // Reset resets the fee rate map to the default value. func (f *FeeService) Reset() { f.lock.Lock() diff --git a/lntest/harness.go b/lntest/harness.go index 92549427f11..22bde98a448 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -858,6 +858,12 @@ func (h *HarnessTest) SetFeeEstimateWithConf( h.feeService.SetFeeRate(fee, conf) } +// SetMinRelayFeerate sets a min relay fee rate to be returned from fee +// estimator. +func (h *HarnessTest) SetMinRelayFeerate(fee chainfee.SatPerKVByte) { + h.feeService.SetMinRelayFeerate(fee) +} + // validateNodeState checks that the node doesn't have any uncleaned states // which will affect its following tests. func (h *HarnessTest) validateNodeState(hn *node.HarnessNode) error {