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
31
lnd_test.go
31
lnd_test.go
@ -6235,40 +6235,49 @@ func testGraphTopologyNotifications(net *lntest.NetworkHarness, t *harnessTest)
|
||||
ctxt, _ = context.WithTimeout(context.Background(), timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
||||
|
||||
// Similar to the case above, we should receive another notification
|
||||
// detailing the channel closure.
|
||||
// Now that the channel has been closed, we should receive a
|
||||
// notification indicating so.
|
||||
out:
|
||||
for {
|
||||
select {
|
||||
case graphUpdate := <-graphUpdates:
|
||||
if len(graphUpdate.ClosedChans) != 1 {
|
||||
t.Fatalf("expected a single update, instead "+
|
||||
"have %v", len(graphUpdate.ClosedChans))
|
||||
continue
|
||||
}
|
||||
|
||||
closedChan := graphUpdate.ClosedChans[0]
|
||||
if closedChan.ClosedHeight != uint32(blockHeight+1) {
|
||||
t.Fatalf("close heights of channel mismatch: expected "+
|
||||
"%v, got %v", blockHeight+1, closedChan.ClosedHeight)
|
||||
t.Fatalf("close heights of channel mismatch: "+
|
||||
"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)
|
||||
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)
|
||||
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)
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
// For the final portion of the test, we'll ensure that once a new node
|
||||
// appears in the network, the proper notification is dispatched. Note
|
||||
|
Loading…
Reference in New Issue
Block a user