test: make assertNumOpenChannelsPending poll every 200ms
In this commit, we modify the assertNumOpenChannelsPending to poll every 200ms rather than just a single attempt. The goal of this commit is to reduce the number of flakes on travis caused by slow instances.
This commit is contained in:
parent
34a165dd12
commit
8a9cf9af16
56
lnd_test.go
56
lnd_test.go
@ -245,24 +245,44 @@ func numOpenChannelsPending(ctxt context.Context, node *lightningNode) (int, err
|
|||||||
// number of pending channels between them.
|
// number of pending channels between them.
|
||||||
func assertNumOpenChannelsPending(ctxt context.Context, t *harnessTest,
|
func assertNumOpenChannelsPending(ctxt context.Context, t *harnessTest,
|
||||||
alice, bob *lightningNode, expected int) {
|
alice, bob *lightningNode, expected int) {
|
||||||
aliceNumChans, err := numOpenChannelsPending(ctxt, alice)
|
|
||||||
if err != nil {
|
const nPolls = 10
|
||||||
t.Fatalf("error fetching alice's node (%v) pending channels %v",
|
|
||||||
alice.nodeID, err)
|
ticker := time.NewTicker(200 * time.Millisecond)
|
||||||
}
|
defer ticker.Stop()
|
||||||
bobNumChans, err := numOpenChannelsPending(ctxt, bob)
|
|
||||||
if err != nil {
|
for i := 0; i < nPolls; i++ {
|
||||||
t.Fatalf("error fetching bob's node (%v) pending channels %v",
|
aliceNumChans, err := numOpenChannelsPending(ctxt, alice)
|
||||||
bob.nodeID, err)
|
if err != nil {
|
||||||
}
|
t.Fatalf("error fetching alice's node (%v) pending channels %v",
|
||||||
if aliceNumChans != expected {
|
alice.nodeID, err)
|
||||||
t.Fatalf("number of pending channels for alice incorrect. "+
|
}
|
||||||
"expected %v, got %v", expected, aliceNumChans)
|
bobNumChans, err := numOpenChannelsPending(ctxt, bob)
|
||||||
}
|
if err != nil {
|
||||||
if bobNumChans != expected {
|
t.Fatalf("error fetching bob's node (%v) pending channels %v",
|
||||||
t.Fatalf("number of pending channels for bob incorrect. "+
|
bob.nodeID, err)
|
||||||
"expected %v, got %v",
|
}
|
||||||
expected, bobNumChans)
|
|
||||||
|
isLastIteration := i == nPolls-1
|
||||||
|
|
||||||
|
aliceStateCorrect := aliceNumChans == expected
|
||||||
|
if !aliceStateCorrect && isLastIteration {
|
||||||
|
t.Fatalf("number of pending channels for alice incorrect. "+
|
||||||
|
"expected %v, got %v", expected, aliceNumChans)
|
||||||
|
}
|
||||||
|
|
||||||
|
bobStateCorrect := bobNumChans == expected
|
||||||
|
if !bobStateCorrect && isLastIteration {
|
||||||
|
t.Fatalf("number of pending channels for bob incorrect. "+
|
||||||
|
"expected %v, got %v",
|
||||||
|
expected, bobNumChans)
|
||||||
|
}
|
||||||
|
|
||||||
|
if aliceStateCorrect && bobStateCorrect {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
<-ticker.C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user