itest: create context with timeout in closeChannelAndAssertType

This commit is contained in:
yyforyongyu 2021-08-10 14:42:01 +08:00
parent be341bcd68
commit 2e4417454b
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

View File

@ -203,11 +203,14 @@ func closeChannelAndAssert(ctx context.Context, t *harnessTest,
)
}
func closeChannelAndAssertType(ctx context.Context, t *harnessTest,
func closeChannelAndAssertType(ctxb context.Context, t *harnessTest,
net *lntest.NetworkHarness, node *lntest.HarnessNode,
fundingChanPoint *lnrpc.ChannelPoint,
anchors, force bool) *chainhash.Hash {
ctxt, cancel := context.WithTimeout(ctxb, channelCloseTimeout)
defer cancel()
// Fetch the current channel policy. If the channel is currently
// enabled, we will register for graph notifications before closing to
// assert that the node sends out a disabling update as a result of the
@ -221,13 +224,13 @@ func closeChannelAndAssertType(ctx context.Context, t *harnessTest,
// updates before initiating the channel closure.
var graphSub *graphSubscription
if expectDisable {
sub := subscribeGraphNotifications(ctx, t, node)
sub := subscribeGraphNotifications(ctxt, t, node)
graphSub = &sub
defer close(graphSub.quit)
}
closeUpdates, _, err := net.CloseChannel(
ctx, node, fundingChanPoint, force,
ctxt, node, fundingChanPoint, force,
)
require.NoError(t.t, err, "unable to close channel")
@ -244,7 +247,7 @@ func closeChannelAndAssertType(ctx context.Context, t *harnessTest,
}
return assertChannelClosed(
ctx, t, net, node, fundingChanPoint, anchors, closeUpdates,
ctxt, t, net, node, fundingChanPoint, anchors, closeUpdates,
)
}