itest: fix lack of hop hint coverage in hold invoice test

Update our test to assert that we have hop hints present when we
expect them, and fix the "alice is a private node" issue that was
previously preventing us from adding hop hints. Asserting that we
have hop hints present in this itest ensures that we'll fail our
itests if a change to SelectHopHints results in our no longer
having hints in this secnario.
This commit is contained in:
carla 2022-02-07 09:03:09 +02:00
parent f6ba5be351
commit 4ac6f82b5e
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91

View file

@ -60,6 +60,26 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
"timeout: %v", err)
}
// For Carol to include her private channel with Alice as a hop hint,
// we need Alice to be perceived as a "public" node, meaning that she
// has at least one public channel in the graph. We open a public
// channel from Alice -> Bob and wait for Carol to see it.
chanPointBob := openChannelAndAssert(
t, net, net.Alice, net.Bob,
lntest.OpenChannelParams{
Amt: chanAmt,
},
)
// Wait for Alice and Carol to see the open channel
err = net.Alice.WaitForNetworkChannelOpen(chanPointBob)
require.NoError(t.t, err, "alice didn't see the alice->bob "+
"channel before timeout")
err = carol.WaitForNetworkChannelOpen(chanPointBob)
require.NoError(t.t, err, "carol didn't see the alice->bob "+
"channel before timeout")
// Create preimages for all payments we are going to initiate.
var preimages []lntypes.Preimage
for i := 0; i < numPayments; i++ {
@ -109,6 +129,18 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to subscribe to invoice: %v", err)
}
// We expect all of our invoices to have hop hints attached,
// since Carol and Alice are connected with a private channel.
// We assert that we have one hop hint present to ensure that
// we've got coverage for hop hints.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
decodeReq := &lnrpc.PayReqString{
PayReq: resp.PaymentRequest,
}
invoice, err := net.Alice.DecodePayReq(ctxt, decodeReq)
require.NoError(t.t, err, "could not decode invoice")
require.Len(t.t, invoice.RouteHints, 1)
invoiceStreams = append(invoiceStreams, stream)
payReqs = append(payReqs, resp.PaymentRequest)
}
@ -229,7 +261,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
}
// Now after a restart, we must re-track the payments. We set up a
// goroutine for each to track thir status updates.
// goroutine for each to track their status updates.
var (
statusUpdates []chan *lnrpc.Payment
wg sync.WaitGroup