itest: add default context timeout to all itests

This commit is contained in:
positiveblue 2023-02-23 02:26:02 -08:00
parent c578280c7c
commit 8e6ef3f567
No known key found for this signature in database
GPG key ID: 4FFF2510928804DC
4 changed files with 17 additions and 11 deletions

View file

@ -378,8 +378,8 @@ func assertStatusErr(t *testing.T, err error, code codes.Code) {
// testFirewallRules tests that the various firewall rules are enforced
// correctly.
func testFirewallRules(net *NetworkHarness, t *harnessTest) {
ctx := context.Background()
func testFirewallRules(ctx context.Context, net *NetworkHarness,
t *harnessTest) {
// Some very basic functionality tests to make sure lnd is working fine
// in integrated mode.
@ -1142,8 +1142,8 @@ func testPeerAndChannelRestrictRules(net *NetworkHarness, t *harnessTest) {
require.NoError(t.t, err)
}
func testLargeHttpHeader(net *NetworkHarness, t *harnessTest) {
ctx := context.Background()
func testLargeHttpHeader(ctx context.Context, net *NetworkHarness,
t *harnessTest) {
// First we add all LND's permissions so that any call we make to LND to
// test that the connection is working will succeed.

View file

@ -259,8 +259,8 @@ var (
// testModeIntegrated makes sure that in integrated mode all daemons work
// correctly.
func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
ctx := context.Background()
func testModeIntegrated(ctx context.Context, net *NetworkHarness,
t *harnessTest) {
// Some very basic functionality tests to make sure lnd is working fine
// in integrated mode.

View file

@ -13,9 +13,7 @@ import (
)
// testModeRemote makes sure that in remote mode all daemons work correctly.
func testModeRemote(net *NetworkHarness, t *harnessTest) {
ctx := context.Background()
func testModeRemote(ctx context.Context, net *NetworkHarness, t *harnessTest) {
// Some very basic functionality tests to make sure lnd is working fine
// in remote mode.
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Bob)

View file

@ -2,6 +2,7 @@ package itest
import (
"bytes"
"context"
"flag"
"fmt"
"testing"
@ -25,6 +26,8 @@ var (
)
slowMineDelay = 20 * time.Millisecond
defaultITestTimeout = 10 * time.Minute
)
const (
@ -92,7 +95,12 @@ func (h *harnessTest) RunTestCase(testCase *testCase) {
}
}()
testCase.test(h.lndHarness, h)
ctxt, cancel := context.WithTimeout(
context.Background(), defaultITestTimeout,
)
defer cancel()
testCase.test(ctxt, h.lndHarness, h)
}
func (h *harnessTest) Logf(format string, args ...interface{}) {
@ -118,7 +126,7 @@ func getLitdBinary() string {
type testCase struct {
name string
test func(net *NetworkHarness, t *harnessTest)
test func(ctx context.Context, net *NetworkHarness, t *harnessTest)
}
// waitForNTxsInMempool polls until finding the desired number of transactions