@@ -294,12 +294,13 @@ func testHtlcTimeoutResolver(t *testing.T, testCase htlcTimeoutTestCase) {
294294 chainCfg := ChannelArbitratorConfig {
295295 ChainArbitratorConfig : ChainArbitratorConfig {
296296 Notifier : notifier ,
297+ Sweeper : newMockSweeper (),
297298 PreimageDB : witnessBeacon ,
298299 IncubateOutputs : func (wire.OutPoint ,
299300 fn.Option [lnwallet.OutgoingHtlcResolution ],
300301 fn.Option [lnwallet.IncomingHtlcResolution ],
301- uint32 , fn.Option [int32 ],
302- ) error {
302+ uint32 , fn.Option [int32 ]) error {
303+
303304 incubateChan <- struct {}{}
304305 return nil
305306 },
@@ -311,26 +312,28 @@ func testHtlcTimeoutResolver(t *testing.T, testCase htlcTimeoutTestCase) {
311312 }
312313
313314 resolutionChan <- msgs [0 ]
315+
314316 return nil
315317 },
316318 Budget : * DefaultBudgetConfig (),
317319 QueryIncomingCircuit : func (circuit models.CircuitKey ,
318320 ) * models.CircuitKey {
321+
319322 return nil
320323 },
321324 },
322325 PutResolverReport : func (_ kvdb.RwTx ,
323- _ * channeldb.ResolverReport ,
324- ) error {
326+ _ * channeldb.ResolverReport ) error {
327+
325328 return nil
326329 },
327330 }
328331
329332 cfg := ResolverConfig {
330333 ChannelArbitratorConfig : chainCfg ,
331334 Checkpoint : func (_ ContractResolver ,
332- reports ... * channeldb.ResolverReport ,
333- ) error {
335+ reports ... * channeldb.ResolverReport ) error {
336+
334337 checkPointChan <- struct {}{}
335338
336339 // Send all of our reports into the channel.
@@ -367,13 +370,15 @@ func testHtlcTimeoutResolver(t *testing.T, testCase htlcTimeoutTestCase) {
367370
368371 if testCase .timeout {
369372 timeoutTxID := timeoutTx .TxHash ()
370- reports = append ( reports , & channeldb.ResolverReport {
371- OutPoint : timeoutTx .TxIn [0 ].PreviousOutPoint ,
373+ report := & channeldb.ResolverReport {
374+ OutPoint : timeoutTx .TxIn [0 ].PreviousOutPoint , //nolint:lll
372375 Amount : testHtlcAmt .ToSatoshis (),
373- ResolverType : channeldb .ResolverTypeOutgoingHtlc ,
374- ResolverOutcome : channeldb .ResolverOutcomeFirstStage ,
376+ ResolverType : channeldb .ResolverTypeOutgoingHtlc , //nolint:lll
377+ ResolverOutcome : channeldb .ResolverOutcomeFirstStage , //nolint:lll
375378 SpendTxID : & timeoutTxID ,
376- })
379+ }
380+
381+ reports = append (reports , report )
377382 }
378383 }
379384
@@ -391,10 +396,21 @@ func testHtlcTimeoutResolver(t *testing.T, testCase htlcTimeoutTestCase) {
391396 }
392397 }()
393398
394- // As the output isn't yet in the nursery, we expect that we
395- // should receive an incubation request.
399+ // If this is a remote commit, then we expct the outputs should receive
400+ // an incubation request to go through the sweeper, otherwise the
401+ // nursery.
402+ var sweepChan chan input.Input
403+ if testCase .remoteCommit {
404+ mockSweeper , ok := resolver .Sweeper .(* mockSweeper )
405+ require .True (t , ok )
406+ sweepChan = mockSweeper .sweptInputs
407+ }
408+
409+ // The output should be offered to either the sweeper or
410+ // the nursery.
396411 select {
397412 case <- incubateChan :
413+ case <- sweepChan :
398414 case err := <- resolveErr :
399415 t .Fatalf ("unable to resolve HTLC: %v" , err )
400416 case <- time .After (time .Second * 5 ):
@@ -450,7 +466,6 @@ func testHtlcTimeoutResolver(t *testing.T, testCase htlcTimeoutTestCase) {
450466 t .Fatalf ("resolution not sent" )
451467 }
452468 } else {
453-
454469 // Otherwise, the HTLC should now timeout. First, we
455470 // should get a resolution message with a populated
456471 // failure message.
@@ -559,10 +574,6 @@ func TestHtlcTimeoutSingleStage(t *testing.T) {
559574 }
560575
561576 checkpoints := []checkpoint {
562- {
563- // Output should be handed off to the nursery.
564- incubating : true ,
565- },
566577 {
567578 // We send a confirmation the sweep tx from published
568579 // by the nursery.
@@ -594,7 +605,7 @@ func TestHtlcTimeoutSingleStage(t *testing.T) {
594605 // After the sweep has confirmed, we expect the
595606 // checkpoint to be resolved, and with the above
596607 // report.
597- incubating : true ,
608+ incubating : false ,
598609 resolved : true ,
599610 reports : []* channeldb.ResolverReport {
600611 claim ,
@@ -849,9 +860,9 @@ func TestHtlcTimeoutSingleStageRemoteSpend(t *testing.T) {
849860 )
850861}
851862
852- // TestHtlcTimeoutSecondStageRemoteSpend tests that when a remite commitment
853- // confirms, and the remote spends the output using the success tx, we
854- // properly detect this and extract the preimage.
863+ // TestHtlcTimeoutSecondStageRemoteSpend tests that when a remote commitment
864+ // confirms, and the remote spends the output using the success tx, we properly
865+ // detect this and extract the preimage.
855866func TestHtlcTimeoutSecondStageRemoteSpend (t * testing.T ) {
856867 commitOutpoint := wire.OutPoint {Index : 2 }
857868
@@ -895,10 +906,6 @@ func TestHtlcTimeoutSecondStageRemoteSpend(t *testing.T) {
895906 }
896907
897908 checkpoints := []checkpoint {
898- {
899- // Output should be handed off to the nursery.
900- incubating : true ,
901- },
902909 {
903910 // We send a confirmation for the remote's second layer
904911 // success transcation.
@@ -944,7 +951,7 @@ func TestHtlcTimeoutSecondStageRemoteSpend(t *testing.T) {
944951 // After the sweep has confirmed, we expect the
945952 // checkpoint to be resolved, and with the above
946953 // report.
947- incubating : true ,
954+ incubating : false ,
948955 resolved : true ,
949956 reports : []* channeldb.ResolverReport {
950957 claim ,
@@ -1321,8 +1328,8 @@ func TestHtlcTimeoutSecondStageSweeperRemoteSpend(t *testing.T) {
13211328}
13221329
13231330func testHtlcTimeout (t * testing.T , resolution lnwallet.OutgoingHtlcResolution ,
1324- checkpoints []checkpoint ,
1325- ) {
1331+ checkpoints []checkpoint ) {
1332+
13261333 t .Helper ()
13271334
13281335 defer timeout ()()
0 commit comments