test: wait until closed channel notification is received
In this commit, we modify the graph topology notifications test to wait until a graph update notification has been received for a closed channel, rather than assume the next graph update will be for the closed channel itself.
This commit is contained in:
parent
a6136c16b0
commit
7bc9eb96ac
71
lnd_test.go
71
lnd_test.go
@ -6235,39 +6235,48 @@ func testGraphTopologyNotifications(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
ctxt, _ = context.WithTimeout(context.Background(), timeout)
|
ctxt, _ = context.WithTimeout(context.Background(), timeout)
|
||||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
||||||
|
|
||||||
// Similar to the case above, we should receive another notification
|
// Now that the channel has been closed, we should receive a
|
||||||
// detailing the channel closure.
|
// notification indicating so.
|
||||||
select {
|
out:
|
||||||
case graphUpdate := <-graphUpdates:
|
for {
|
||||||
if len(graphUpdate.ClosedChans) != 1 {
|
select {
|
||||||
t.Fatalf("expected a single update, instead "+
|
case graphUpdate := <-graphUpdates:
|
||||||
"have %v", len(graphUpdate.ClosedChans))
|
if len(graphUpdate.ClosedChans) != 1 {
|
||||||
}
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
closedChan := graphUpdate.ClosedChans[0]
|
closedChan := graphUpdate.ClosedChans[0]
|
||||||
if closedChan.ClosedHeight != uint32(blockHeight+1) {
|
if closedChan.ClosedHeight != uint32(blockHeight+1) {
|
||||||
t.Fatalf("close heights of channel mismatch: expected "+
|
t.Fatalf("close heights of channel mismatch: "+
|
||||||
"%v, got %v", blockHeight+1, closedChan.ClosedHeight)
|
"expected %v, got %v", blockHeight+1,
|
||||||
|
closedChan.ClosedHeight)
|
||||||
|
}
|
||||||
|
chanPointTxid, err := getChanPointFundingTxid(chanPoint)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to get txid: %v", err)
|
||||||
|
}
|
||||||
|
closedChanTxid, err := getChanPointFundingTxid(
|
||||||
|
closedChan.ChanPoint,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to get txid: %v", err)
|
||||||
|
}
|
||||||
|
if !bytes.Equal(closedChanTxid, chanPointTxid) {
|
||||||
|
t.Fatalf("channel point hash mismatch: "+
|
||||||
|
"expected %v, got %v", chanPointTxid,
|
||||||
|
closedChanTxid)
|
||||||
|
}
|
||||||
|
if closedChan.ChanPoint.OutputIndex != chanPoint.OutputIndex {
|
||||||
|
t.Fatalf("output index mismatch: expected %v, "+
|
||||||
|
"got %v", chanPoint.OutputIndex,
|
||||||
|
closedChan.ChanPoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
break out
|
||||||
|
case <-time.After(time.Second * 10):
|
||||||
|
t.Fatalf("notification for channel closure not " +
|
||||||
|
"sent")
|
||||||
}
|
}
|
||||||
chanPointTxid, err := getChanPointFundingTxid(chanPoint)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to get txid: %v", err)
|
|
||||||
}
|
|
||||||
closedChanTxid, err := getChanPointFundingTxid(closedChan.ChanPoint)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to get txid: %v", err)
|
|
||||||
}
|
|
||||||
if !bytes.Equal(closedChanTxid, chanPointTxid) {
|
|
||||||
t.Fatalf("channel point hash mismatch: expected %v, "+
|
|
||||||
"got %v", chanPointTxid, closedChanTxid)
|
|
||||||
}
|
|
||||||
if closedChan.ChanPoint.OutputIndex != chanPoint.OutputIndex {
|
|
||||||
t.Fatalf("output index mismatch: expected %v, got %v",
|
|
||||||
chanPoint.OutputIndex, closedChan.ChanPoint)
|
|
||||||
}
|
|
||||||
case <-time.After(time.Second * 10):
|
|
||||||
t.Fatalf("notification for channel closure not " +
|
|
||||||
"sent")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the final portion of the test, we'll ensure that once a new node
|
// For the final portion of the test, we'll ensure that once a new node
|
||||||
|
Loading…
Reference in New Issue
Block a user