lntest/itest: wait for on-chain balance restore
We add a wait predicate to make sure the node's on-chain balance is restored before continuing the restore test case. This is needed since the DLP test scenario includes several restarts of the node, and if the node isn't done scanning for on-chain balance before the restart happens, it would be unlocked without a recovery window, causing funds to be left undiscovered.
This commit is contained in:
parent
2d194c9672
commit
97093b4223
@ -8121,7 +8121,9 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest,
|
|||||||
assertTxInBlock(t, block, forceClose)
|
assertTxInBlock(t, block, forceClose)
|
||||||
|
|
||||||
// Dave should sweep his funds immediately, as they are not timelocked.
|
// Dave should sweep his funds immediately, as they are not timelocked.
|
||||||
daveSweep, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
|
daveSweep, err := waitForTxInMempool(
|
||||||
|
net.Miner.Node, minerMempoolTimeout,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to find Dave's sweep tx in mempool: %v", err)
|
t.Fatalf("unable to find Dave's sweep tx in mempool: %v", err)
|
||||||
}
|
}
|
||||||
@ -13559,6 +13561,27 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
|
|||||||
t.Fatalf("unable to restore node: %v", err)
|
t.Fatalf("unable to restore node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First ensure that the on-chain balance is restored.
|
||||||
|
err = wait.NoError(func() error {
|
||||||
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
balReq := &lnrpc.WalletBalanceRequest{}
|
||||||
|
daveBalResp, err := dave.WalletBalance(ctxt, balReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
daveBal := daveBalResp.ConfirmedBalance
|
||||||
|
if daveBal <= 0 {
|
||||||
|
return fmt.Errorf("expected positive balance, had %v",
|
||||||
|
daveBal)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}, defaultTimeout)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("On-chain balance not restored: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we have our new node up, we expect that it'll re-connect to
|
// Now that we have our new node up, we expect that it'll re-connect to
|
||||||
// Carol automatically based on the restored backup.
|
// Carol automatically based on the restored backup.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user