Merge pull request #4825 from guggero/itest-suspicion

itest: adjust parallelization, poll intervals and timeouts to not starve goroutines
This commit is contained in:
Conner Fromknecht 2020-12-08 13:28:45 -08:00 committed by GitHub
commit 592a0c5699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 115 additions and 98 deletions

@ -223,9 +223,9 @@ func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error {
// Now block until both wallets have fully synced up. // Now block until both wallets have fully synced up.
expectedBalance := int64(btcutil.SatoshiPerBitcoin * 10) expectedBalance := int64(btcutil.SatoshiPerBitcoin * 10)
balReq := &lnrpc.WalletBalanceRequest{} balReq := &lnrpc.WalletBalanceRequest{}
balanceTicker := time.NewTicker(time.Millisecond * 50) balanceTicker := time.NewTicker(time.Millisecond * 200)
defer balanceTicker.Stop() defer balanceTicker.Stop()
balanceTimeout := time.After(time.Second * 30) balanceTimeout := time.After(DefaultTimeout)
out: out:
for { for {
select { select {
@ -290,7 +290,6 @@ func (n *NetworkHarness) NewNodeWithSeed(name string, extraArgs []string,
return nil, nil, nil, err return nil, nil, nil, err
} }
timeout := time.Duration(time.Second * 15)
ctxb := context.Background() ctxb := context.Background()
// Create a request to generate a new aezeed. The new seed will have the // Create a request to generate a new aezeed. The new seed will have the
@ -299,7 +298,8 @@ func (n *NetworkHarness) NewNodeWithSeed(name string, extraArgs []string,
AezeedPassphrase: password, AezeedPassphrase: password,
} }
ctxt, _ := context.WithTimeout(ctxb, timeout) ctxt, cancel := context.WithTimeout(ctxb, DefaultTimeout)
defer cancel()
genSeedResp, err := node.GenSeed(ctxt, genSeedReq) genSeedResp, err := node.GenSeed(ctxt, genSeedReq)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
@ -424,7 +424,7 @@ func (n *NetworkHarness) RegisterNode(node *HarnessNode) {
func (n *NetworkHarness) connect(ctx context.Context, func (n *NetworkHarness) connect(ctx context.Context,
req *lnrpc.ConnectPeerRequest, a *HarnessNode) error { req *lnrpc.ConnectPeerRequest, a *HarnessNode) error {
syncTimeout := time.After(15 * time.Second) syncTimeout := time.After(DefaultTimeout)
tryconnect: tryconnect:
if _, err := a.ConnectPeer(ctx, req); err != nil { if _, err := a.ConnectPeer(ctx, req); err != nil {
// If the chain backend is still syncing, retry. // If the chain backend is still syncing, retry.
@ -457,7 +457,8 @@ func (n *NetworkHarness) EnsureConnected(ctx context.Context, a, b *HarnessNode)
errConnectionRequested := errors.New("connection request in progress") errConnectionRequested := errors.New("connection request in progress")
tryConnect := func(a, b *HarnessNode) error { tryConnect := func(a, b *HarnessNode) error {
ctxt, _ := context.WithTimeout(ctx, 15*time.Second) ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout)
defer cancel()
bInfo, err := b.GetInfo(ctxt, &lnrpc.GetInfoRequest{}) bInfo, err := b.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
if err != nil { if err != nil {
return err return err
@ -472,7 +473,7 @@ func (n *NetworkHarness) EnsureConnected(ctx context.Context, a, b *HarnessNode)
var predErr error var predErr error
err = wait.Predicate(func() bool { err = wait.Predicate(func() bool {
ctx, cancel := context.WithTimeout(ctx, 15*time.Second) ctx, cancel := context.WithTimeout(ctx, DefaultTimeout)
defer cancel() defer cancel()
err := n.connect(ctx, req, a) err := n.connect(ctx, req, a)
@ -530,7 +531,8 @@ func (n *NetworkHarness) EnsureConnected(ctx context.Context, a, b *HarnessNode)
// If node B is seen in the ListPeers response from node A, // If node B is seen in the ListPeers response from node A,
// then we can exit early as the connection has been fully // then we can exit early as the connection has been fully
// established. // established.
ctxt, _ := context.WithTimeout(ctx, 15*time.Second) ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout)
defer cancel()
resp, err := b.ListPeers(ctxt, &lnrpc.ListPeersRequest{}) resp, err := b.ListPeers(ctxt, &lnrpc.ListPeersRequest{})
if err != nil { if err != nil {
return false return false
@ -547,7 +549,7 @@ func (n *NetworkHarness) EnsureConnected(ctx context.Context, a, b *HarnessNode)
err := wait.Predicate(func() bool { err := wait.Predicate(func() bool {
return findSelfInPeerList(a, b) && findSelfInPeerList(b, a) return findSelfInPeerList(a, b) && findSelfInPeerList(b, a)
}, time.Second*15) }, DefaultTimeout)
if err != nil { if err != nil {
return fmt.Errorf("peers not connected within 15 seconds") return fmt.Errorf("peers not connected within 15 seconds")
} }
@ -594,7 +596,7 @@ func (n *NetworkHarness) ConnectNodes(ctx context.Context, a, b *HarnessNode) er
} }
return false return false
}, time.Second*15) }, DefaultTimeout)
if err != nil { if err != nil {
return fmt.Errorf("peers not connected within 15 seconds") return fmt.Errorf("peers not connected within 15 seconds")
} }
@ -1038,7 +1040,7 @@ func (n *NetworkHarness) CloseChannel(ctx context.Context,
// We'll wait for *both* nodes to read the channel as active if we're // We'll wait for *both* nodes to read the channel as active if we're
// performing a cooperative channel closure. // performing a cooperative channel closure.
if !force { if !force {
timeout := time.Second * 15 timeout := DefaultTimeout
listReq := &lnrpc.ListChannelsRequest{} listReq := &lnrpc.ListChannelsRequest{}
// We define two helper functions, one two locate a particular // We define two helper functions, one two locate a particular
@ -1223,7 +1225,7 @@ func (n *NetworkHarness) AssertChannelExists(ctx context.Context,
} }
return fmt.Errorf("channel %s not found", chanPoint) return fmt.Errorf("channel %s not found", chanPoint)
}, 15*time.Second) }, DefaultTimeout)
} }
// DumpLogs reads the current logs generated by the passed node, and returns // DumpLogs reads the current logs generated by the passed node, and returns
@ -1355,7 +1357,7 @@ func (n *NetworkHarness) sendCoins(ctx context.Context, amt btcutil.Amount,
} }
return nil return nil
}, 15*time.Second) }, DefaultTimeout)
if err != nil { if err != nil {
return fmt.Errorf("unconfirmed utxo was not found in "+ return fmt.Errorf("unconfirmed utxo was not found in "+
"ListUnspent: %v", err) "ListUnspent: %v", err)

@ -520,7 +520,7 @@ func testChannelBackupUpdates(net *lntest.NetworkHarness, t *harnessTest) {
} }
return nil return nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("backup state invalid: %v", err) t.Fatalf("backup state invalid: %v", err)
} }
@ -987,6 +987,33 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
) )
require.NoError(t.t, err) 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 // We also want to make sure we cannot force close in this state. That
// would get the state machine in a weird state. // would get the state machine in a weird state.
chanPointParts := strings.Split( chanPointParts := strings.Split(

@ -272,7 +272,7 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout) ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol)
if err != nil { if err != nil {
t.Fatalf("unable to send coins to Alice: %v", err) t.Fatalf("unable to send coins to Carol: %v", err)
} }
} }

@ -373,7 +373,7 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("closing transaction not marked as fully closed") t.Fatalf("closing transaction not marked as fully closed")
} }
@ -532,7 +532,7 @@ func assertNumOpenChannelsPending(ctxt context.Context, t *harnessTest,
} }
return nil return nil
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
@ -703,7 +703,7 @@ func completePaymentRequests(ctx context.Context, client lnrpc.LightningClient,
} }
return false return false
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
return err return err
} }
@ -848,7 +848,7 @@ func testGetRecoveryInfo(net *lntest.NetworkHarness, t *harnessTest) {
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("expected recovery mode to be %v, got %v, "+ t.Fatalf("expected recovery mode to be %v, got %v, "+
"expected recovery finished to be %v, got %v, "+ "expected recovery finished to be %v, got %v, "+
@ -952,7 +952,7 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("expected restored node to have %d satoshis, "+ t.Fatalf("expected restored node to have %d satoshis, "+
"instead has %d satoshis, expected %d utxos "+ "instead has %d satoshis, expected %d utxos "+
@ -1805,7 +1805,7 @@ out:
} }
case err := <-subscription.errChan: case err := <-subscription.errChan:
t.Fatalf("unable to recv graph update: %v", err) t.Fatalf("unable to recv graph update: %v", err)
case <-time.After(20 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("did not receive channel update") t.Fatalf("did not receive channel update")
} }
} }
@ -2396,7 +2396,7 @@ func waitForNodeBlockHeight(ctx context.Context, node *lntest.HarnessNode,
height int32) error { height int32) error {
var predErr error var predErr error
err := wait.Predicate(func() bool { err := wait.Predicate(func() bool {
ctxt, _ := context.WithTimeout(ctx, 10*time.Second) ctxt, _ := context.WithTimeout(ctx, defaultTimeout)
info, err := node.GetInfo(ctxt, &lnrpc.GetInfoRequest{}) info, err := node.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
if err != nil { if err != nil {
predErr = err predErr = err
@ -2409,7 +2409,7 @@ func waitForNodeBlockHeight(ctx context.Context, node *lntest.HarnessNode,
return false return false
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
return predErr return predErr
} }
@ -2445,7 +2445,7 @@ func assertMinerBlockHeightDelta(t *harnessTest,
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -2680,7 +2680,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -3619,7 +3619,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -3821,7 +3821,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return nil return nil
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -3936,7 +3936,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return nil return nil
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
@ -4069,7 +4069,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -4143,7 +4143,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return nil return nil
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
@ -4307,7 +4307,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -4437,7 +4437,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -4475,7 +4475,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
} }
return true return true
}, 15*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -5299,7 +5299,7 @@ func assertAmountPaid(t *harnessTest, channelName string,
// are in place // are in place
var timeover uint32 var timeover uint32
go func() { go func() {
<-time.After(time.Second * 20) <-time.After(defaultTimeout)
atomic.StoreUint32(&timeover, 1) atomic.StoreUint32(&timeover, 1)
}() }()
@ -6182,7 +6182,7 @@ func testUnannouncedChannels(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -6534,7 +6534,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -6716,7 +6716,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
} }
@ -7749,7 +7749,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -7785,7 +7785,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -7807,7 +7807,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -7855,7 +7855,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -7948,18 +7948,12 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to restart carol's node: %v", err) t.Fatalf("unable to restart carol's node: %v", err)
} }
err = wait.Predicate(func() bool { require.Eventually(t.t, func() bool {
return isConnected(net.Bob.PubKeyStr) return isConnected(net.Bob.PubKeyStr)
}, 15*time.Second) }, defaultTimeout, 20*time.Millisecond)
if err != nil { require.Eventually(t.t, func() bool {
t.Fatalf("alice did not reconnect to bob")
}
err = wait.Predicate(func() bool {
return isConnected(carol.PubKeyStr) return isConnected(carol.PubKeyStr)
}, 15*time.Second) }, defaultTimeout, 20*time.Millisecond)
if err != nil {
t.Fatalf("alice did not reconnect to carol")
}
// We'll also restart Alice to ensure she can reconnect to her peers // We'll also restart Alice to ensure she can reconnect to her peers
// with open channels. // with open channels.
@ -7967,24 +7961,18 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to restart alice's node: %v", err) t.Fatalf("unable to restart alice's node: %v", err)
} }
err = wait.Predicate(func() bool { require.Eventually(t.t, func() bool {
return isConnected(net.Bob.PubKeyStr) return isConnected(net.Bob.PubKeyStr)
}, 15*time.Second) }, defaultTimeout, 20*time.Millisecond)
if err != nil { require.Eventually(t.t, func() bool {
t.Fatalf("alice did not reconnect to bob")
}
err = wait.Predicate(func() bool {
return isConnected(carol.PubKeyStr) return isConnected(carol.PubKeyStr)
}, 15*time.Second) }, defaultTimeout, 20*time.Millisecond)
if err != nil { require.Eventually(t.t, func() bool {
t.Fatalf("alice did not reconnect to carol") return isConnected(dave.PubKeyStr)
} }, defaultTimeout, 20*time.Millisecond)
err = wait.Predicate(func() bool { err = wait.Predicate(func() bool {
return isConnected(dave.PubKeyStr) return isConnected(dave.PubKeyStr)
}, 15*time.Second) }, defaultTimeout)
if err != nil {
t.Fatalf("alice did not reconnect to dave")
}
// testReconnection is a helper closure that restarts the nodes at both // testReconnection is a helper closure that restarts the nodes at both
// ends of a channel to ensure they do not reconnect after restarting. // ends of a channel to ensure they do not reconnect after restarting.
@ -8019,7 +8007,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
} }
err = wait.Predicate(func() bool { err = wait.Predicate(func() bool {
return isConnected(dave.PubKeyStr) return isConnected(dave.PubKeyStr)
}, 20*time.Second) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("alice didn't reconnect to Dave") t.Fatalf("alice didn't reconnect to Dave")
} }
@ -8091,7 +8079,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("channels not marked as fully resolved: %v", predErr) t.Fatalf("channels not marked as fully resolved: %v", predErr)
} }
@ -8223,7 +8211,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
bobChan = bChan bobChan = bChan
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -8301,7 +8289,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
} }
return true return true
}, time.Second*10) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("unable to close channel: %v", predErr) t.Fatalf("unable to close channel: %v", predErr)
} }
@ -8555,7 +8543,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
ctxt, carol, chanPoint, force, ctxt, carol, chanPoint, force,
) )
return closeErr == nil return closeErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("unable to close channel: %v", closeErr) t.Fatalf("unable to close channel: %v", closeErr)
} }
@ -8966,7 +8954,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
justiceTxid = txid justiceTxid = txid
return true return true
}, time.Second*10) }, defaultTimeout)
if err != nil && predErr == errNotFound { if err != nil && predErr == errNotFound {
// If Dave is unable to broadcast his justice tx on first // If Dave is unable to broadcast his justice tx on first
// attempt because of the second layer transactions, he will // attempt because of the second layer transactions, he will
@ -8986,7 +8974,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
justiceTxid = txid justiceTxid = txid
return true return true
}, time.Second*10) }, defaultTimeout)
} }
if err != nil { if err != nil {
t.Fatalf(predErr.Error()) t.Fatalf(predErr.Error())
@ -9480,7 +9468,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -9504,7 +9492,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -9543,7 +9531,7 @@ func assertNumPendingChannels(t *harnessTest, node *lntest.HarnessNode,
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -9798,7 +9786,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
nodeChan = bChan nodeChan = bChan
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", predErr) t.Fatalf("%v", predErr)
} }
@ -10001,7 +9989,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
} }
return nil return nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("%v", err) t.Fatalf("%v", err)
} }
@ -10037,7 +10025,7 @@ func assertNodeNumChannels(t *harnessTest, node *lntest.HarnessNode,
return true return true
} }
if err := wait.Predicate(pred, time.Second*15); err != nil { if err := wait.Predicate(pred, defaultTimeout); err != nil {
t.Fatalf("node has incorrect number of channels: %v", predErr) t.Fatalf("node has incorrect number of channels: %v", predErr)
} }
} }
@ -10583,7 +10571,7 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) {
} }
case err := <-graphSub.errChan: case err := <-graphSub.errChan:
t.Fatalf("unable to recv graph update: %v", err) t.Fatalf("unable to recv graph update: %v", err)
case <-time.After(20 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("did not receive node ann update") t.Fatalf("did not receive node ann update")
} }
} }
@ -11338,7 +11326,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -11373,7 +11361,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
err = wait.Predicate(func() bool { err = wait.Predicate(func() bool {
predErr = assertNumActiveHtlcs(nodes, numPayments) predErr = assertNumActiveHtlcs(nodes, numPayments)
return predErr == nil return predErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -11397,7 +11385,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
predErr = assertNumActiveHtlcs(nodes, 0) predErr = assertNumActiveHtlcs(nodes, 0)
return predErr == nil return predErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -11655,7 +11643,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
err = wait.Predicate(func() bool { err = wait.Predicate(func() bool {
predErr = assertNumActiveHtlcs(nodes, numPayments) predErr = assertNumActiveHtlcs(nodes, numPayments)
return predErr == nil return predErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -11678,7 +11666,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
err = wait.Invariant(func() bool { err = wait.Invariant(func() bool {
predErr = assertNumActiveHtlcs(nodes, numPayments) predErr = assertNumActiveHtlcs(nodes, numPayments)
return predErr == nil return predErr == nil
}, time.Second*2) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc change: %v", predErr) t.Fatalf("htlc change: %v", predErr)
} }
@ -11702,7 +11690,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
err = wait.Predicate(func() bool { err = wait.Predicate(func() bool {
predErr = assertNumActiveHtlcs(carolNode, 0) predErr = assertNumActiveHtlcs(carolNode, 0)
return predErr == nil return predErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -11721,7 +11709,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -11982,7 +11970,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -12019,7 +12007,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
predErr = assertNumActiveHtlcsChanPoint(dave, carolFundPoint, 0) predErr = assertNumActiveHtlcsChanPoint(dave, carolFundPoint, 0)
return predErr == nil return predErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -12049,7 +12037,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -12316,7 +12304,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -12344,7 +12332,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
predErr = assertNumActiveHtlcsChanPoint(dave, carolFundPoint, 0) predErr = assertNumActiveHtlcsChanPoint(dave, carolFundPoint, 0)
return predErr == nil return predErr == nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -12389,7 +12377,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
return false return false
} }
return true return true
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("htlc mismatch: %v", predErr) t.Fatalf("htlc mismatch: %v", predErr)
} }
@ -13723,7 +13711,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
} }
return nil return nil
}, time.Second*15) }, defaultTimeout)
if err != nil { if err != nil {
t.Fatalf("predicate not satisfied: %v", err) t.Fatalf("predicate not satisfied: %v", err)
} }

@ -660,7 +660,7 @@ func (hn *HarnessNode) initClientWhenReady() error {
if err := wait.NoError(func() error { if err := wait.NoError(func() error {
conn, connErr = hn.ConnectRPC(true) conn, connErr = hn.ConnectRPC(true)
return connErr return connErr
}, 5*time.Second); err != nil { }, DefaultTimeout); err != nil {
return err return err
} }
@ -1005,7 +1005,7 @@ func (hn *HarnessNode) stop() error {
// Wait for lnd process and other goroutines to exit. // Wait for lnd process and other goroutines to exit.
select { select {
case <-hn.processExit: case <-hn.processExit:
case <-time.After(60 * time.Second): case <-time.After(DefaultTimeout * 2):
return fmt.Errorf("process did not exit") return fmt.Errorf("process did not exit")
} }
@ -1357,7 +1357,7 @@ func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount, confirmed
return btcutil.Amount(balance.UnconfirmedBalance) == expectedBalance return btcutil.Amount(balance.UnconfirmedBalance) == expectedBalance
} }
err := wait.Predicate(doesBalanceMatch, 30*time.Second) err := wait.Predicate(doesBalanceMatch, DefaultTimeout)
if err != nil { if err != nil {
return fmt.Errorf("balances not synced after deadline: "+ return fmt.Errorf("balances not synced after deadline: "+
"expected %v, only have %v", expectedBalance, lastBalance) "expected %v, only have %v", expectedBalance, lastBalance)

@ -11,7 +11,7 @@ import (
// several running lnd nodes. This function gives callers a way to assert that // several running lnd nodes. This function gives callers a way to assert that
// some property is upheld within a particular time frame. // some property is upheld within a particular time frame.
func Predicate(pred func() bool, timeout time.Duration) error { func Predicate(pred func() bool, timeout time.Duration) error {
const pollInterval = 20 * time.Millisecond const pollInterval = 200 * time.Millisecond
exitTimer := time.After(timeout) exitTimer := time.After(timeout)
for { for {

@ -5,7 +5,7 @@ TEST_FLAGS =
ITEST_FLAGS = ITEST_FLAGS =
EXEC_SUFFIX = EXEC_SUFFIX =
COVER_PKG = $$(go list -deps ./... | grep '$(PKG)' | grep -v lnrpc) COVER_PKG = $$(go list -deps ./... | grep '$(PKG)' | grep -v lnrpc)
NUM_ITEST_TRANCHES = 6 NUM_ITEST_TRANCHES = 4
ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES) ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
# If rpc option is set also add all extra RPC tags to DEV_TAGS # If rpc option is set also add all extra RPC tags to DEV_TAGS