test: modify assertNumConnections to use a stoppable ticker

This commit is contained in:
Olaoluwa Osuntokun 2017-11-02 15:45:13 -07:00
parent b3000b621b
commit 34a165dd12
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -266,19 +266,18 @@ func assertNumOpenChannelsPending(ctxt context.Context, t *harnessTest,
}
}
//assertNumConnections asserts number current connections between two peers
func assertNumConnections(
ctxt context.Context,
t *harnessTest,
alice, bob *lightningNode,
expected int) {
// assertNumConnections asserts number current connections between two peers.
func assertNumConnections(ctxt context.Context, t *harnessTest,
alice, bob *lightningNode, expected int) {
const nPolls = 10
tick := time.Tick(300 * time.Millisecond)
tick := time.NewTicker(300 * time.Millisecond)
defer tick.Stop()
for i := nPolls - 1; i >= 0; i-- {
select {
case <-tick:
case <-tick.C:
aNumPeers, err := alice.ListPeers(ctxt, &lnrpc.ListPeersRequest{})
if err != nil {
t.Fatalf("unable to fetch alice's node (%v) list peers %v",