lnd_test: don't shadow predErr
Would lead to the printed predErr not being set. We instead use the new WaitNoError method to avoid this.
This commit is contained in:
parent
0714ffa0d7
commit
33b2d92b80
69
lnd_test.go
69
lnd_test.go
@ -2708,27 +2708,26 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Alice should see the channel in her set of pending force closed
|
// Alice should see the channel in her set of pending force closed
|
||||||
// channels with her funds still in limbo.
|
// channels with her funds still in limbo.
|
||||||
err = lntest.WaitPredicate(func() bool {
|
err = lntest.WaitNoError(func() error {
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
pendingChanResp, err := net.Alice.PendingChannels(
|
pendingChanResp, err := net.Alice.PendingChannels(
|
||||||
ctxt, pendingChansRequest,
|
ctxt, pendingChansRequest,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
predErr = fmt.Errorf("unable to query for pending "+
|
return fmt.Errorf("unable to query for pending "+
|
||||||
"channels: %v", err)
|
"channels: %v", err)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
predErr = checkNumForceClosedChannels(pendingChanResp, 1)
|
err = checkNumForceClosedChannels(pendingChanResp, 1)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
forceClose, predErr := findForceClosedChannel(
|
forceClose, err := findForceClosedChannel(
|
||||||
pendingChanResp, &op,
|
pendingChanResp, &op,
|
||||||
)
|
)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, the nursery should show that the commitment
|
// At this point, the nursery should show that the commitment
|
||||||
@ -2736,29 +2735,27 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// total, we have mined exactly defaultCSV blocks, so the htlc
|
// total, we have mined exactly defaultCSV blocks, so the htlc
|
||||||
// outputs should also reflect that this many blocks have
|
// outputs should also reflect that this many blocks have
|
||||||
// passed.
|
// passed.
|
||||||
predErr = checkCommitmentMaturity(
|
err = checkCommitmentMaturity(
|
||||||
forceClose, commCsvMaturityHeight, 1,
|
forceClose, commCsvMaturityHeight, 1,
|
||||||
)
|
)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// All funds should still be shown in limbo.
|
// All funds should still be shown in limbo.
|
||||||
if forceClose.LimboBalance == 0 {
|
if forceClose.LimboBalance == 0 {
|
||||||
predErr = errors.New("all funds should still be in " +
|
return errors.New("all funds should still be in " +
|
||||||
"limbo")
|
"limbo")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
if forceClose.RecoveredBalance != 0 {
|
if forceClose.RecoveredBalance != 0 {
|
||||||
predErr = errors.New("no funds should yet be shown " +
|
return errors.New("no funds should yet be shown " +
|
||||||
"as recovered")
|
"as recovered")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return nil
|
||||||
}, 15*time.Second)
|
}, 15*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(predErr.Error())
|
t.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate an additional block, which should cause the CSV delayed
|
// Generate an additional block, which should cause the CSV delayed
|
||||||
@ -2878,40 +2875,39 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Alice should now see the channel in her set of pending force closed
|
// Alice should now see the channel in her set of pending force closed
|
||||||
// channels with one pending HTLC.
|
// channels with one pending HTLC.
|
||||||
err = lntest.WaitPredicate(func() bool {
|
err = lntest.WaitNoError(func() error {
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
pendingChanResp, err := net.Alice.PendingChannels(
|
pendingChanResp, err := net.Alice.PendingChannels(
|
||||||
ctxt, pendingChansRequest,
|
ctxt, pendingChansRequest,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
predErr = fmt.Errorf("unable to query for pending "+
|
return fmt.Errorf("unable to query for pending "+
|
||||||
"channels: %v", err)
|
"channels: %v", err)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
predErr = checkNumForceClosedChannels(pendingChanResp, 1)
|
err = checkNumForceClosedChannels(pendingChanResp, 1)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
forceClose, predErr := findForceClosedChannel(
|
forceClose, err := findForceClosedChannel(
|
||||||
pendingChanResp, &op,
|
pendingChanResp, &op,
|
||||||
)
|
)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should now be at the block just before the utxo nursery
|
// We should now be at the block just before the utxo nursery
|
||||||
// will attempt to broadcast the htlc timeout transactions.
|
// will attempt to broadcast the htlc timeout transactions.
|
||||||
predErr = checkPendingChannelNumHtlcs(forceClose, numInvoices)
|
err = checkPendingChannelNumHtlcs(forceClose, numInvoices)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
predErr = checkPendingHtlcStageAndMaturity(
|
err = checkPendingHtlcStageAndMaturity(
|
||||||
forceClose, 1, htlcExpiryHeight, 1,
|
forceClose, 1, htlcExpiryHeight, 1,
|
||||||
)
|
)
|
||||||
if predErr != nil {
|
if err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that our commitment confirmation depth has been
|
// Now that our commitment confirmation depth has been
|
||||||
@ -2919,15 +2915,14 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// All htlc outputs are still left in limbo, so it should be
|
// All htlc outputs are still left in limbo, so it should be
|
||||||
// non-zero as well.
|
// non-zero as well.
|
||||||
if forceClose.LimboBalance == 0 {
|
if forceClose.LimboBalance == 0 {
|
||||||
predErr = errors.New("htlc funds should still be in " +
|
return errors.New("htlc funds should still be in " +
|
||||||
"limbo")
|
"limbo")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return nil
|
||||||
}, 15*time.Second)
|
}, 15*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(predErr.Error())
|
t.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, generate the block which will cause Alice to broadcast the
|
// Now, generate the block which will cause Alice to broadcast the
|
||||||
|
Loading…
Reference in New Issue
Block a user