tests: fix several timeout issues

This commit is contained in:
Alex 2017-08-10 15:05:04 -06:00 committed by Olaoluwa Osuntokun
parent 48be9261ef
commit 58c6989e74
2 changed files with 7 additions and 4 deletions

@ -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)
}

@ -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")
}
}