Skip to content

Commit

Permalink
itest: Switch force close detection to WaitNoError
Browse files Browse the repository at this point in the history
This switches the waitForPendingChannelForceClose aux function to use
the WaitNoError variant of predicate fullfiment. This fixes a possible
logic error and improves the reliability of tests using this function.
  • Loading branch information
matheusd committed Jul 8, 2019
1 parent cb95abf commit 56c0d7f
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions lntest/itest/lnd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,36 +422,30 @@ func waitForChannelPendingForceClose(ctx context.Context,
Index: fundingChanPoint.OutputIndex,
}

var predErr error
err = lntest.WaitPredicate(func() bool {
return lntest.WaitNoError(func() error {
pendingChansRequest := &lnrpc.PendingChannelsRequest{}
pendingChanResp, err := node.PendingChannels(
ctx, pendingChansRequest,
)
if err != nil {
predErr = fmt.Errorf("unable to get pending "+
return fmt.Errorf("unable to get pending "+
"channels: %v", err)
return false
}

forceClose, err := findForceClosedChannel(pendingChanResp, &op)
if err != nil {
predErr = err
return false
return fmt.Errorf("unable to find force-closed "+
"channel: %v", err)
}

// We must wait until the UTXO nursery has received the channel
// and is aware of its maturity height.
if forceClose.MaturityHeight == 0 {
predErr = fmt.Errorf("channel had maturity height of 0")
return false
return fmt.Errorf("channel had maturity height of 0")
}
return true
}, time.Second*15)
if err != nil {
return err
}
return predErr

return nil
}, 15*time.Second)
}

// cleanupForceClose mines a force close commitment found in the mempool and
Expand Down

0 comments on commit 56c0d7f

Please sign in to comment.