Skip to content

Commit 8e6ef3f

Browse files
committed
itest: add default context timeout to all itests
1 parent c578280 commit 8e6ef3f

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

itest/litd_firewall_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ func assertStatusErr(t *testing.T, err error, code codes.Code) {
378378

379379
// testFirewallRules tests that the various firewall rules are enforced
380380
// correctly.
381-
func testFirewallRules(net *NetworkHarness, t *harnessTest) {
382-
ctx := context.Background()
381+
func testFirewallRules(ctx context.Context, net *NetworkHarness,
382+
t *harnessTest) {
383383

384384
// Some very basic functionality tests to make sure lnd is working fine
385385
// in integrated mode.
@@ -1142,8 +1142,8 @@ func testPeerAndChannelRestrictRules(net *NetworkHarness, t *harnessTest) {
11421142
require.NoError(t.t, err)
11431143
}
11441144

1145-
func testLargeHttpHeader(net *NetworkHarness, t *harnessTest) {
1146-
ctx := context.Background()
1145+
func testLargeHttpHeader(ctx context.Context, net *NetworkHarness,
1146+
t *harnessTest) {
11471147

11481148
// First we add all LND's permissions so that any call we make to LND to
11491149
// test that the connection is working will succeed.

itest/litd_mode_integrated_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ var (
259259

260260
// testModeIntegrated makes sure that in integrated mode all daemons work
261261
// correctly.
262-
func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
263-
ctx := context.Background()
262+
func testModeIntegrated(ctx context.Context, net *NetworkHarness,
263+
t *harnessTest) {
264264

265265
// Some very basic functionality tests to make sure lnd is working fine
266266
// in integrated mode.

itest/litd_mode_remote_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import (
1313
)
1414

1515
// testModeRemote makes sure that in remote mode all daemons work correctly.
16-
func testModeRemote(net *NetworkHarness, t *harnessTest) {
17-
ctx := context.Background()
18-
16+
func testModeRemote(ctx context.Context, net *NetworkHarness, t *harnessTest) {
1917
// Some very basic functionality tests to make sure lnd is working fine
2018
// in remote mode.
2119
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Bob)

itest/test_harness.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package itest
22

33
import (
44
"bytes"
5+
"context"
56
"flag"
67
"fmt"
78
"testing"
@@ -25,6 +26,8 @@ var (
2526
)
2627

2728
slowMineDelay = 20 * time.Millisecond
29+
30+
defaultITestTimeout = 10 * time.Minute
2831
)
2932

3033
const (
@@ -92,7 +95,12 @@ func (h *harnessTest) RunTestCase(testCase *testCase) {
9295
}
9396
}()
9497

95-
testCase.test(h.lndHarness, h)
98+
ctxt, cancel := context.WithTimeout(
99+
context.Background(), defaultITestTimeout,
100+
)
101+
defer cancel()
102+
103+
testCase.test(ctxt, h.lndHarness, h)
96104
}
97105

98106
func (h *harnessTest) Logf(format string, args ...interface{}) {
@@ -118,7 +126,7 @@ func getLitdBinary() string {
118126

119127
type testCase struct {
120128
name string
121-
test func(net *NetworkHarness, t *harnessTest)
129+
test func(ctx context.Context, net *NetworkHarness, t *harnessTest)
122130
}
123131

124132
// waitForNTxsInMempool polls until finding the desired number of transactions

0 commit comments

Comments
 (0)