@@ -242,6 +242,11 @@ type MockChainBridge struct {
242242
243243 ReqCount int
244244 ConfReqs map [int ]* chainntnfs.ConfirmationEvent
245+
246+ failFeeEstimates bool
247+ emptyConf bool
248+ errConf bool
249+ confErr chan error
245250}
246251
247252func NewMockChainBridge () * MockChainBridge {
@@ -255,11 +260,27 @@ func NewMockChainBridge() *MockChainBridge {
255260 }
256261}
257262
263+ func (m * MockChainBridge ) FailFeeEstimates (enable bool ) {
264+ m .failFeeEstimates = enable
265+ }
266+
267+ func (m * MockChainBridge ) FailConf (enable bool ) {
268+ m .errConf = enable
269+ }
270+ func (m * MockChainBridge ) EmptyConf (enable bool ) {
271+ m .emptyConf = enable
272+ }
273+
258274func (m * MockChainBridge ) SendConfNtfn (reqNo int , blockHash * chainhash.Hash ,
259275 blockHeight , blockIndex int , block * wire.MsgBlock ,
260276 tx * wire.MsgTx ) {
261277
262278 req := m .ConfReqs [reqNo ]
279+ if m .emptyConf {
280+ req .Confirmed <- nil
281+ return
282+ }
283+
263284 req .Confirmed <- & chainntnfs.TxConfirmation {
264285 BlockHash : blockHash ,
265286 BlockHeight : uint32 (blockHeight ),
@@ -287,7 +308,7 @@ func (m *MockChainBridge) RegisterConfirmationsNtfn(ctx context.Context,
287308 Confirmed : make (chan * chainntnfs.TxConfirmation ),
288309 Cancel : func () {},
289310 }
290- errChan : = make (chan error )
311+ m . confErr = make (chan error , 1 )
291312
292313 m .ConfReqs [m .ReqCount ] = req
293314
@@ -296,7 +317,11 @@ func (m *MockChainBridge) RegisterConfirmationsNtfn(ctx context.Context,
296317 case <- ctx .Done ():
297318 }
298319
299- return req , errChan , nil
320+ if m .errConf {
321+ m .confErr <- fmt .Errorf ("confirmation error" )
322+ }
323+
324+ return req , m .confErr , nil
300325}
301326
302327func (m * MockChainBridge ) RegisterBlockEpochNtfn (
@@ -361,6 +386,10 @@ func (m *MockChainBridge) EstimateFee(ctx context.Context,
361386 return 0 , fmt .Errorf ("shutting down" )
362387 }
363388
389+ if m .failFeeEstimates {
390+ return 0 , fmt .Errorf ("failed to estimate fee" )
391+ }
392+
364393 return 253 , nil
365394}
366395
0 commit comments