lntest: more descriptive errors for CloseChannel

This improves the error reporting for the harness' CloseChannel so that
the exact step where closure fails can be better indicated.

This is to help debug some flaky failures in the CI.
This commit is contained in:
Matheus Degiovani 2020-03-09 11:10:14 -03:00
parent 60446494e9
commit 19873f721f

@ -1128,7 +1128,8 @@ func (n *NetworkHarness) CloseChannel(ctx context.Context,
// within the network.
closeResp, err := closeRespStream.Recv()
if err != nil {
errChan <- err
errChan <- fmt.Errorf("unable to recv() from close "+
"stream: %v", err)
return
}
pendingClose, ok := closeResp.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
@ -1140,11 +1141,13 @@ func (n *NetworkHarness) CloseChannel(ctx context.Context,
closeTxid, err := chainhash.NewHash(pendingClose.ClosePending.Txid)
if err != nil {
errChan <- err
errChan <- fmt.Errorf("unable to decode closeTxid: "+
"%v", err)
return
}
if err := n.WaitForTxBroadcast(ctx, *closeTxid); err != nil {
errChan <- err
errChan <- fmt.Errorf("error while waiting for "+
"broadcast tx: %v", err)
return
}
fin <- closeTxid
@ -1153,9 +1156,6 @@ func (n *NetworkHarness) CloseChannel(ctx context.Context,
// Wait until either the deadline for the context expires, an error
// occurs, or the channel close update is received.
select {
case <-ctx.Done():
return nil, nil, fmt.Errorf("timeout reached before channel close " +
"initiated")
case err := <-errChan:
return nil, nil, err
case closeTxid := <-fin: