mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
itest: wait for server to start when restoring
To avoid running into the "server is still starting" error when trying to close a channel, we first wait for the error to disappear before we try closing the actual channel.
This commit is contained in:
parent
cdcbc0376d
commit
809d238364
@ -987,6 +987,33 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
|
||||
)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// We now need to make sure the server is fully started before we can
|
||||
// actually close the channel. This is the first check in CloseChannel
|
||||
// so we can try with a nil channel point until we get the correct error
|
||||
// to find out if Dave is fully started.
|
||||
err = wait.Predicate(func() bool {
|
||||
const expectedErr = "must specify channel point"
|
||||
ctxc, cancel := context.WithCancel(ctxt)
|
||||
defer cancel()
|
||||
|
||||
resp, err := dave.CloseChannel(
|
||||
ctxc, &lnrpc.CloseChannelRequest{},
|
||||
)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
defer func() { _ = resp.CloseSend() }()
|
||||
|
||||
_, err = resp.Recv()
|
||||
if err != nil && strings.Contains(err.Error(), expectedErr) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}, defaultTimeout)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// We also want to make sure we cannot force close in this state. That
|
||||
// would get the state machine in a weird state.
|
||||
chanPointParts := strings.Split(
|
||||
|
Loading…
Reference in New Issue
Block a user