mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loop/test: simplify preimage push test to be less dependent on height
Our preimage push test previously relied on our dropping down to the default sweep conf target to mock a drop in chain fees. This makes our test dependent on height, which makes changes to our sweep logic regarding when we reveal our preimage break this test. In this commit that logic is replaced with simply locking our mock and updating fees on the fly.
This commit is contained in:
parent
db56b31b11
commit
ab9a662758
3 changed files with 27 additions and 26 deletions
|
|
@ -258,5 +258,5 @@ func (s *LndMockServices) DecodeInvoice(request string) (*zpay32.Invoice,
|
|||
func (s *LndMockServices) SetFeeEstimate(confTarget int32,
|
||||
feeEstimate chainfee.SatPerKWeight) {
|
||||
|
||||
s.WalletKit.(*mockWalletKit).feeEstimates[confTarget] = feeEstimate
|
||||
s.WalletKit.(*mockWalletKit).setFeeEstimate(confTarget, feeEstimate)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package test
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
|
|
@ -21,9 +22,11 @@ import (
|
|||
var DefaultMockFee = chainfee.SatPerKWeight(10000)
|
||||
|
||||
type mockWalletKit struct {
|
||||
lnd *LndMockServices
|
||||
keyIndex int32
|
||||
feeEstimates map[int32]chainfee.SatPerKWeight
|
||||
lnd *LndMockServices
|
||||
keyIndex int32
|
||||
|
||||
feeEstimateLock sync.Mutex
|
||||
feeEstimates map[int32]chainfee.SatPerKWeight
|
||||
}
|
||||
|
||||
var _ lndclient.WalletKitClient = (*mockWalletKit)(nil)
|
||||
|
|
@ -118,9 +121,19 @@ func (m *mockWalletKit) SendOutputs(ctx context.Context, outputs []*wire.TxOut,
|
|||
return &tx, nil
|
||||
}
|
||||
|
||||
func (m *mockWalletKit) setFeeEstimate(confTarget int32, fee chainfee.SatPerKWeight) {
|
||||
m.feeEstimateLock.Lock()
|
||||
defer m.feeEstimateLock.Unlock()
|
||||
|
||||
m.feeEstimates[confTarget] = fee
|
||||
}
|
||||
|
||||
func (m *mockWalletKit) EstimateFee(ctx context.Context, confTarget int32) (
|
||||
chainfee.SatPerKWeight, error) {
|
||||
|
||||
m.feeEstimateLock.Lock()
|
||||
defer m.feeEstimateLock.Unlock()
|
||||
|
||||
if confTarget <= 1 {
|
||||
return 0, errors.New("conf target must be greater than 1")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue