test: modify assertNumConnections to use a stoppable ticker
This commit is contained in:
parent
b3000b621b
commit
34a165dd12
15
lnd_test.go
15
lnd_test.go
@ -266,19 +266,18 @@ func assertNumOpenChannelsPending(ctxt context.Context, t *harnessTest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//assertNumConnections asserts number current connections between two peers
|
// assertNumConnections asserts number current connections between two peers.
|
||||||
func assertNumConnections(
|
func assertNumConnections(ctxt context.Context, t *harnessTest,
|
||||||
ctxt context.Context,
|
alice, bob *lightningNode, expected int) {
|
||||||
t *harnessTest,
|
|
||||||
alice, bob *lightningNode,
|
|
||||||
expected int) {
|
|
||||||
|
|
||||||
const nPolls = 10
|
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-- {
|
for i := nPolls - 1; i >= 0; i-- {
|
||||||
select {
|
select {
|
||||||
case <-tick:
|
case <-tick.C:
|
||||||
aNumPeers, err := alice.ListPeers(ctxt, &lnrpc.ListPeersRequest{})
|
aNumPeers, err := alice.ListPeers(ctxt, &lnrpc.ListPeersRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to fetch alice's node (%v) list peers %v",
|
t.Fatalf("unable to fetch alice's node (%v) list peers %v",
|
||||||
|
Loading…
Reference in New Issue
Block a user