test: implement MinRelayFee RPC

This commit is contained in:
Boris Nagaev 2025-02-20 01:51:07 -03:00
parent 149bffcad7
commit 45aa156977
No known key found for this signature in database
2 changed files with 24 additions and 0 deletions

View file

@ -29,6 +29,7 @@ func NewMockLnd() *LndMockServices {
lightningClient := &mockLightningClient{}
walletKit := &mockWalletKit{
feeEstimates: make(map[int32]chainfee.SatPerKWeight),
minRelayFee: chainfee.FeePerKwFloor,
}
chainNotifier := &mockChainNotifier{}
signer := &mockSigner{}
@ -278,3 +279,7 @@ func (s *LndMockServices) SetFeeEstimate(confTarget int32,
confTarget, feeEstimate,
)
}
func (s *LndMockServices) SetMinRelayFee(feeEstimate chainfee.SatPerKWeight) {
s.LndServices.WalletKit.(*mockWalletKit).setMinRelayFee(feeEstimate)
}

View file

@ -34,6 +34,7 @@ type mockWalletKit struct {
feeEstimateLock sync.Mutex
feeEstimates map[int32]chainfee.SatPerKWeight
minRelayFee chainfee.SatPerKWeight
}
var _ lndclient.WalletKitClient = (*mockWalletKit)(nil)
@ -169,6 +170,24 @@ func (m *mockWalletKit) EstimateFeeRate(ctx context.Context,
return feeEstimate, nil
}
func (m *mockWalletKit) setMinRelayFee(fee chainfee.SatPerKWeight) {
m.feeEstimateLock.Lock()
defer m.feeEstimateLock.Unlock()
m.minRelayFee = fee
}
// MinRelayFee returns the current minimum relay fee based on our chain backend
// in sat/kw. It can be set with setMinRelayFee.
func (m *mockWalletKit) MinRelayFee(
ctx context.Context) (chainfee.SatPerKWeight, error) {
m.feeEstimateLock.Lock()
defer m.feeEstimateLock.Unlock()
return m.minRelayFee, nil
}
// ListSweeps returns a list of the sweep transaction ids known to our node.
func (m *mockWalletKit) ListSweeps(_ context.Context, _ int32) (
[]string, error) {