mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-01 10:41:34 +02:00
lntest: allow specifying min relay feerate in itest
This commit is contained in:
parent
ce43e4bab7
commit
a1d71afde8
@ -33,6 +33,9 @@ type WebFeeService interface {
|
|||||||
// target.
|
// target.
|
||||||
SetFeeRate(feeRate chainfee.SatPerKWeight, conf uint32)
|
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 resets the fee rate map to the default value.
|
||||||
Reset()
|
Reset()
|
||||||
}
|
}
|
||||||
@ -52,8 +55,9 @@ const (
|
|||||||
type FeeService struct {
|
type FeeService struct {
|
||||||
*testing.T
|
*testing.T
|
||||||
|
|
||||||
feeRateMap map[uint32]uint32
|
feeRateMap map[uint32]uint32
|
||||||
url string
|
minRelayFeerate chainfee.SatPerKVByte
|
||||||
|
url string
|
||||||
|
|
||||||
srv *http.Server
|
srv *http.Server
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
@ -79,6 +83,7 @@ func NewFeeService(t *testing.T) *FeeService {
|
|||||||
f.feeRateMap = map[uint32]uint32{
|
f.feeRateMap = map[uint32]uint32{
|
||||||
feeServiceTarget: DefaultFeeRateSatPerKw,
|
feeServiceTarget: DefaultFeeRateSatPerKw,
|
||||||
}
|
}
|
||||||
|
f.minRelayFeerate = chainfee.FeePerKwFloor.FeePerKVByte()
|
||||||
|
|
||||||
listenAddr := fmt.Sprintf(":%v", port)
|
listenAddr := fmt.Sprintf(":%v", port)
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
@ -113,10 +118,9 @@ func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
|
|||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
bytes, err := json.Marshal(
|
bytes, err := json.Marshal(
|
||||||
struct {
|
chainfee.WebAPIResponse{
|
||||||
Fees map[uint32]uint32 `json:"fee_by_block_target"`
|
FeeByBlockTarget: f.feeRateMap,
|
||||||
}{
|
MinRelayFeerate: f.minRelayFeerate,
|
||||||
Fees: f.feeRateMap,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
require.NoErrorf(f, err, "cannot serialize estimates")
|
require.NoErrorf(f, err, "cannot serialize estimates")
|
||||||
@ -143,6 +147,14 @@ func (f *FeeService) SetFeeRate(fee chainfee.SatPerKWeight, conf uint32) {
|
|||||||
f.feeRateMap[conf] = uint32(fee.FeePerKVByte())
|
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.
|
// Reset resets the fee rate map to the default value.
|
||||||
func (f *FeeService) Reset() {
|
func (f *FeeService) Reset() {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
|
@ -860,6 +860,12 @@ func (h *HarnessTest) SetFeeEstimateWithConf(
|
|||||||
h.feeService.SetFeeRate(fee, conf)
|
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
|
// validateNodeState checks that the node doesn't have any uncleaned states
|
||||||
// which will affect its following tests.
|
// which will affect its following tests.
|
||||||
func (h *HarnessTest) validateNodeState(hn *node.HarnessNode) error {
|
func (h *HarnessTest) validateNodeState(hn *node.HarnessNode) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user