lnd_test: wrap check for expected number of channels in WaitPredicate
This commit is contained in:
parent
4bd45b22eb
commit
6573eed37b
23
lnd_test.go
23
lnd_test.go
@ -3063,21 +3063,36 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
return len(chanGraph.Edges)
|
return len(chanGraph.Edges)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var predErr error
|
||||||
|
err = lntest.WaitPredicate(func() bool {
|
||||||
aliceChans := numChannels(net.Alice)
|
aliceChans := numChannels(net.Alice)
|
||||||
if aliceChans != 4 {
|
if aliceChans != 4 {
|
||||||
t.Fatalf("expected Alice to know 4 edges, had %v", aliceChans)
|
predErr = fmt.Errorf("expected Alice to know 4 edges, "+
|
||||||
|
"had %v", aliceChans)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
bobChans := numChannels(net.Bob)
|
bobChans := numChannels(net.Bob)
|
||||||
if bobChans != 3 {
|
if bobChans != 3 {
|
||||||
t.Fatalf("expected Bob to know 3 edges, had %v", bobChans)
|
predErr = fmt.Errorf("expected Bob to know 3 edges, "+
|
||||||
|
"had %v", bobChans)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
carolChans := numChannels(carol)
|
carolChans := numChannels(carol)
|
||||||
if carolChans != 4 {
|
if carolChans != 4 {
|
||||||
t.Fatalf("expected Carol to know 4 edges, had %v", carolChans)
|
predErr = fmt.Errorf("expected Carol to know 4 edges, "+
|
||||||
|
"had %v", carolChans)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
daveChans := numChannels(dave)
|
daveChans := numChannels(dave)
|
||||||
if daveChans != 3 {
|
if daveChans != 3 {
|
||||||
t.Fatalf("expected Dave to know 3 edges, had %v", daveChans)
|
predErr = fmt.Errorf("expected Dave to know 3 edges, "+
|
||||||
|
"had %v", daveChans)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}, time.Second*15)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%v", predErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close all channels.
|
// Close all channels.
|
||||||
|
Loading…
Reference in New Issue
Block a user