Skip to content

Commit a1d71af

Browse files
committed
lntest: allow specifying min relay feerate in itest
1 parent ce43e4b commit a1d71af

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

lntest/fee_service.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ type WebFeeService interface {
3333
// target.
3434
SetFeeRate(feeRate chainfee.SatPerKWeight, conf uint32)
3535

36+
// SetMinRelayFeerate sets a min relay feerate.
37+
SetMinRelayFeerate(fee chainfee.SatPerKVByte)
38+
3639
// Reset resets the fee rate map to the default value.
3740
Reset()
3841
}
@@ -52,8 +55,9 @@ const (
5255
type FeeService struct {
5356
*testing.T
5457

55-
feeRateMap map[uint32]uint32
56-
url string
58+
feeRateMap map[uint32]uint32
59+
minRelayFeerate chainfee.SatPerKVByte
60+
url string
5761

5862
srv *http.Server
5963
wg sync.WaitGroup
@@ -79,6 +83,7 @@ func NewFeeService(t *testing.T) *FeeService {
7983
f.feeRateMap = map[uint32]uint32{
8084
feeServiceTarget: DefaultFeeRateSatPerKw,
8185
}
86+
f.minRelayFeerate = chainfee.FeePerKwFloor.FeePerKVByte()
8287

8388
listenAddr := fmt.Sprintf(":%v", port)
8489
mux := http.NewServeMux()
@@ -113,10 +118,9 @@ func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
113118
defer f.lock.Unlock()
114119

115120
bytes, err := json.Marshal(
116-
struct {
117-
Fees map[uint32]uint32 `json:"fee_by_block_target"`
118-
}{
119-
Fees: f.feeRateMap,
121+
chainfee.WebAPIResponse{
122+
FeeByBlockTarget: f.feeRateMap,
123+
MinRelayFeerate: f.minRelayFeerate,
120124
},
121125
)
122126
require.NoErrorf(f, err, "cannot serialize estimates")
@@ -143,6 +147,14 @@ func (f *FeeService) SetFeeRate(fee chainfee.SatPerKWeight, conf uint32) {
143147
f.feeRateMap[conf] = uint32(fee.FeePerKVByte())
144148
}
145149

150+
// SetMinRelayFeerate sets a min relay feerate.
151+
func (f *FeeService) SetMinRelayFeerate(fee chainfee.SatPerKVByte) {
152+
f.lock.Lock()
153+
defer f.lock.Unlock()
154+
155+
f.minRelayFeerate = fee
156+
}
157+
146158
// Reset resets the fee rate map to the default value.
147159
func (f *FeeService) Reset() {
148160
f.lock.Lock()

lntest/harness.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,12 @@ func (h *HarnessTest) SetFeeEstimateWithConf(
860860
h.feeService.SetFeeRate(fee, conf)
861861
}
862862

863+
// SetMinRelayFeerate sets a min relay fee rate to be returned from fee
864+
// estimator.
865+
func (h *HarnessTest) SetMinRelayFeerate(fee chainfee.SatPerKVByte) {
866+
h.feeService.SetMinRelayFeerate(fee)
867+
}
868+
863869
// validateNodeState checks that the node doesn't have any uncleaned states
864870
// which will affect its following tests.
865871
func (h *HarnessTest) validateNodeState(hn *node.HarnessNode) error {

0 commit comments

Comments
 (0)