From 47a8cd36f77e4412ce5dbc50e7fbe45ea1fbf155 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 24 Apr 2019 16:06:14 -0700 Subject: [PATCH] lntest/itest: prevent direct connection within testNodeAnnouncement Alice and Dave don't need to be connected in order to receive the node announcement as we assume that she can receive it from Bob because they are connected at the beginning of every test. --- lntest/itest/lnd_test.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 0081d0cc..0d2797d8 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -9334,6 +9334,17 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to connect bob to carol: %v", err) } + // Alice shouldn't receive any new updates yet since the channel has yet + // to be opened. + select { + case <-aliceSub.updateChan: + t.Fatalf("received unexpected update from dave") + case <-time.After(time.Second): + } + + // We'll then go ahead and open a channel between Bob and Dave. This + // ensures that Alice receives the node announcement from Bob as part of + // the announcement broadcast. ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) chanPoint := openChannelAndAssert( ctxt, t, net, net.Bob, dave, @@ -9342,13 +9353,6 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) { }, ) - // When Alice now connects with Dave, Alice will get his node - // announcement. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - if err := net.ConnectNodes(ctxt, net.Alice, dave); err != nil { - t.Fatalf("unable to connect bob to carol: %v", err) - } - assertAddrs := func(addrsFound []string, targetAddrs ...string) { addrs := make(map[string]struct{}, len(addrsFound)) for _, addr := range addrsFound { @@ -9386,6 +9390,9 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) { } } + // We'll then wait for Alice to receive Dave's node announcement + // including the expected advertised addresses from Bob since they + // should already be connected. waitForAddrsInUpdate( aliceSub, dave.PubKeyStr, advertisedAddrs..., )