From 6686ae300179722a5929b25ecd3126f85b35dd04 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 17 Oct 2018 16:14:31 -0700 Subject: [PATCH] lnd_test: update testInvoiceRoutingHints to account In this commit, we open an additional channel between Bob and Carol to ensure that Bob gets selected as the only routing hint. Previously Bob would get selected, but with the recent changes, it would no longer happen due to him not having any advertised edges. --- lnd_test.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lnd_test.go b/lnd_test.go index 9a72e994..f3e2b93d 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -4661,6 +4661,23 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { }, ) + // We'll also create a public channel between Bob and Carol to ensure + // that Bob gets selected as the only routing hint. We do this as + // we should only include routing hints for nodes that are publicly + // advertised, otherwise we'd end up leaking information about nodes + // that wish to stay unadvertised. + if err := net.ConnectNodes(ctxb, net.Bob, carol); err != nil { + t.Fatalf("unable to connect alice to carol: %v", err) + } + ctxt, _ = context.WithTimeout(ctxb, timeout) + chanPointBobCarol := openChannelAndAssert( + ctxt, t, net, net.Bob, carol, + lntest.OpenChannelParams{ + Amt: chanAmt, + PushAmt: chanAmt / 2, + }, + ) + // Then, we'll create Dave's node and open a private channel between him // and Alice. We will not include a push amount in order to not consider // this channel as a routing hint as it will not have enough remote @@ -4707,7 +4724,8 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { // Make sure all the channels have been opened. nodeNames := []string{"bob", "carol", "dave", "eve"} aliceChans := []*lnrpc.ChannelPoint{ - chanPointBob, chanPointCarol, chanPointDave, chanPointEve, + chanPointBob, chanPointCarol, chanPointBobCarol, chanPointDave, + chanPointEve, } for i, chanPoint := range aliceChans { ctxt, _ := context.WithTimeout(ctxb, timeout) @@ -4799,6 +4817,8 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { ctxt, _ = context.WithTimeout(ctxb, timeout) closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointCarol, false) ctxt, _ = context.WithTimeout(ctxb, timeout) + closeChannelAndAssert(ctxt, t, net, net.Bob, chanPointBobCarol, false) + ctxt, _ = context.WithTimeout(ctxb, timeout) closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointDave, false) // The channel between Alice and Eve should be force closed since Eve