Skip to content

Commit 45aa156

Browse files
committed
test: implement MinRelayFee RPC
1 parent 149bffc commit 45aa156

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/lnd_services_mock.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func NewMockLnd() *LndMockServices {
2929
lightningClient := &mockLightningClient{}
3030
walletKit := &mockWalletKit{
3131
feeEstimates: make(map[int32]chainfee.SatPerKWeight),
32+
minRelayFee: chainfee.FeePerKwFloor,
3233
}
3334
chainNotifier := &mockChainNotifier{}
3435
signer := &mockSigner{}
@@ -278,3 +279,7 @@ func (s *LndMockServices) SetFeeEstimate(confTarget int32,
278279
confTarget, feeEstimate,
279280
)
280281
}
282+
283+
func (s *LndMockServices) SetMinRelayFee(feeEstimate chainfee.SatPerKWeight) {
284+
s.LndServices.WalletKit.(*mockWalletKit).setMinRelayFee(feeEstimate)
285+
}

test/walletkit_mock.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type mockWalletKit struct {
3434

3535
feeEstimateLock sync.Mutex
3636
feeEstimates map[int32]chainfee.SatPerKWeight
37+
minRelayFee chainfee.SatPerKWeight
3738
}
3839

3940
var _ lndclient.WalletKitClient = (*mockWalletKit)(nil)
@@ -169,6 +170,24 @@ func (m *mockWalletKit) EstimateFeeRate(ctx context.Context,
169170
return feeEstimate, nil
170171
}
171172

173+
func (m *mockWalletKit) setMinRelayFee(fee chainfee.SatPerKWeight) {
174+
m.feeEstimateLock.Lock()
175+
defer m.feeEstimateLock.Unlock()
176+
177+
m.minRelayFee = fee
178+
}
179+
180+
// MinRelayFee returns the current minimum relay fee based on our chain backend
181+
// in sat/kw. It can be set with setMinRelayFee.
182+
func (m *mockWalletKit) MinRelayFee(
183+
ctx context.Context) (chainfee.SatPerKWeight, error) {
184+
185+
m.feeEstimateLock.Lock()
186+
defer m.feeEstimateLock.Unlock()
187+
188+
return m.minRelayFee, nil
189+
}
190+
172191
// ListSweeps returns a list of the sweep transaction ids known to our node.
173192
func (m *mockWalletKit) ListSweeps(_ context.Context, _ int32) (
174193
[]string, error) {

0 commit comments

Comments
 (0)