tests: fix several timeout issues

This commit is contained in:
Alex authored and Olaoluwa Osuntokun committed 2017-08-14 17:02:31 -07:00
1 parent 48be9261ef
commit 58c6989e74
2 files changed
+7 -4

No files matched your search

+1 -1
View File
@@ -2980,7 +2980,7 @@ func testBidirectionalAsyncPayments(net *networkHarness, t *harnessTest) {
if err != nil {
t.Fatalf(err.Error())
}
case <-time.After(time.Second * maxTime):
case <-time.After(maxTime):
t.Fatalf("waiting for payments to finish too long "+
"(%v)", maxTime)
}
+6 -3
View File
@@ -805,6 +805,7 @@ func (n *networkHarness) SetUp() error {
expectedBalance := int64(btcutil.SatoshiPerBitcoin * 10)
balReq := &lnrpc.WalletBalanceRequest{}
balanceTicker := time.Tick(time.Millisecond * 50)
balanceTimeout := time.After(time.Second * 30)
out:
for {
select {
@@ -822,7 +823,7 @@ out:
bobResp.Balance == expectedBalance {
break out
}
case <-time.After(time.Second * 30):
case <-balanceTimeout:
return fmt.Errorf("balances not synced after deadline")
}
}
@@ -1371,9 +1372,11 @@ func (n *networkHarness) SendCoins(ctx context.Context, amt btcutil.Amount,
// Pause until the nodes current wallet balances reflects the amount
// sent to it above.
// TODO(roasbeef): factor out into helper func
balanceTicker := time.Tick(time.Millisecond * 50)
balanceTimeout := time.After(time.Second * 30)
for {
select {
case <-time.Tick(time.Millisecond * 50):
case <-balanceTicker:
currentBal, err := target.WalletBalance(ctx, balReq)
if err != nil {
return err
@@ -1382,7 +1385,7 @@ func (n *networkHarness) SendCoins(ctx context.Context, amt btcutil.Amount,
if currentBal.Balance == initialBalance.Balance+int64(amt) {
return nil
}
case <-time.After(time.Second * 30):
case <-balanceTimeout:
return fmt.Errorf("balances not synced after deadline")
}
}