From e5052f124bfbccb1b74fc294704a783306018c3e Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 10 May 2018 19:18:58 -0400 Subject: [PATCH] lnd_test: fix update channel policy flake In this commit, we address a timeout issue on our Travis builds within the update channel policy integration test. Before asserting the policy for the channel between Alice and Bob, we need to make sure we receive the updates responsible for modifying this policy first. At times, the update wasn't received in time before checking the policy, which led to us checking the old policy. We fix this by explicitly making sure we wait for the updates first. --- lnd_test.go | 68 ++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 39951a19..3cc478bf 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -793,39 +793,37 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { for { select { case graphUpdate := <-graphUpdates: - if len(graphUpdate.ChannelUpdates) == 0 { - continue - } - chanUpdate := graphUpdate.ChannelUpdates[0] - fundingTxStr := txStr(chanUpdate.ChanPoint) - if _, ok := cps[fundingTxStr]; !ok { - continue - } + for _, update := range graphUpdate.ChannelUpdates { + fundingTxStr := txStr(update.ChanPoint) + if _, ok := cps[fundingTxStr]; !ok { + continue + } - if chanUpdate.AdvertisingNode != advertisingNode { - continue - } + if update.AdvertisingNode != advertisingNode { + continue + } - policy := chanUpdate.RoutingPolicy - if policy.FeeBaseMsat != baseFee { - continue - } - if policy.FeeRateMilliMsat != feeRate*feeBase { - continue - } - if policy.TimeLockDelta != timeLockDelta { - continue - } + policy := update.RoutingPolicy + if policy.FeeBaseMsat != baseFee { + continue + } + if policy.FeeRateMilliMsat != feeRate*feeBase { + continue + } + if policy.TimeLockDelta != timeLockDelta { + continue + } - // We got a policy update that matched the - // values and channel point of what we - // expected, delete it from the map. - delete(cps, fundingTxStr) + // We got a policy update that matched the + // values and channel point of what we + // expected, delete it from the map. + delete(cps, fundingTxStr) - // If we have no more channel points we are - // waiting for, break out of the loop. - if len(cps) == 0 { - break Loop + // If we have no more channel points we are + // waiting for, break out of the loop. + if len(cps) == 0 { + break Loop + } } case <-time.After(20 * time.Second): t.Fatalf("did not receive channel update") @@ -967,9 +965,15 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { // Wait for all nodes to have seen the policy updates for both of // Alice's channels. - waitForChannelUpdate(aliceUpdates, net.Alice.PubKeyStr, chanPoint3) - waitForChannelUpdate(bobUpdates, net.Alice.PubKeyStr, chanPoint3) - waitForChannelUpdate(carolUpdates, net.Alice.PubKeyStr, chanPoint3) + waitForChannelUpdate( + aliceUpdates, net.Alice.PubKeyStr, chanPoint, chanPoint3, + ) + waitForChannelUpdate( + bobUpdates, net.Alice.PubKeyStr, chanPoint, chanPoint3, + ) + waitForChannelUpdate( + carolUpdates, net.Alice.PubKeyStr, chanPoint, chanPoint3, + ) // And finally check that all nodes remembers the policy update they // received.