mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 14:44:22 +01:00
itest: fix inheritance when creating timeout ctxt
This commit fixes the issue where a wrong context being inherited to create a timeout context. When a parent context timed out, all its children contexts also timed out, even the children contexts had a larger timeout value. This means it only makes sense to inherite from a parent when its children have smaller timeout value. Given the setup of the itest, all the timeout contexts need to be created from a context background(hence no timeout on the parent) unless there's an explicit timeout bound we want to set.
This commit is contained in:
@@ -67,8 +67,8 @@ func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
testContext.waitForChannels()
|
||||
|
||||
// Connect the interceptor.
|
||||
ctx := context.Background()
|
||||
ctxt, cancelInterceptor := context.WithTimeout(ctx, defaultTimeout)
|
||||
ctxb := context.Background()
|
||||
ctxt, cancelInterceptor := context.WithTimeout(ctxb, defaultTimeout)
|
||||
interceptor, err := testContext.bob.RouterClient.HtlcInterceptor(ctxt)
|
||||
require.NoError(t.t, err, "failed to create HtlcInterceptor")
|
||||
|
||||
@@ -230,8 +230,7 @@ func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
restartAlice, err := net.SuspendNode(alice)
|
||||
require.NoError(t.t, err, "failed to suspend alice")
|
||||
|
||||
ctx = context.Background()
|
||||
ctxt, cancelInterceptor = context.WithTimeout(ctx, defaultTimeout)
|
||||
ctxt, cancelInterceptor = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancelInterceptor()
|
||||
interceptor, err = testContext.bob.RouterClient.HtlcInterceptor(ctxt)
|
||||
require.NoError(t.t, err, "failed to create HtlcInterceptor")
|
||||
@@ -259,7 +258,7 @@ func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
}()
|
||||
|
||||
err = wait.Predicate(func() bool {
|
||||
channels, err := bob.ListChannels(ctx, &lnrpc.ListChannelsRequest{
|
||||
channels, err := bob.ListChannels(ctxt, &lnrpc.ListChannelsRequest{
|
||||
ActiveOnly: true, Peer: alice.PubKey[:],
|
||||
})
|
||||
return err == nil && len(channels.Channels) > 0
|
||||
|
||||
Reference in New Issue
Block a user