diff --git a/lntest/itest/assertions.go b/lntest/itest/assertions.go index 4b540a09c..0702ba34d 100644 --- a/lntest/itest/assertions.go +++ b/lntest/itest/assertions.go @@ -146,15 +146,6 @@ func closeChannelAndAssertType(t *harnessTest, )[0] expectDisable := !curPolicy.Disabled - // If the current channel policy is enabled, begin subscribing the graph - // updates before initiating the channel closure. - var graphSub *graphSubscription - if expectDisable { - sub := subscribeGraphNotifications(ctxt, t, node) - graphSub = &sub - defer close(graphSub.quit) - } - closeUpdates, _, err := net.CloseChannel(node, fundingChanPoint, force) require.NoError(t.t, err, "unable to close channel") @@ -162,11 +153,9 @@ func closeChannelAndAssertType(t *harnessTest, // received the disabled update. if expectDisable { curPolicy.Disabled = true - waitForChannelUpdate( - t, *graphSub, - []expectedChanUpdate{ - {node.PubKeyStr, curPolicy, fundingChanPoint}, - }, + assertChannelPolicyUpdate( + t.t, node, node.PubKeyStr, + curPolicy, fundingChanPoint, false, ) } @@ -565,13 +554,6 @@ func getChannelBalance(t *harnessTest, return resp } -// expectedChanUpdate houses params we expect a ChannelUpdate to advertise. -type expectedChanUpdate struct { - advertisingNode string - expectedPolicy *lnrpc.RoutingPolicy - chanPoint *lnrpc.ChannelPoint -} - // txStr returns the string representation of the channel's funding transaction. func txStr(chanPoint *lnrpc.ChannelPoint) string { fundingTxID, err := lnrpc.GetChanPointFundingTxid(chanPoint) @@ -585,109 +567,6 @@ func txStr(chanPoint *lnrpc.ChannelPoint) string { return cp.String() } -// waitForChannelUpdate waits for a node to receive the expected channel -// updates. -func waitForChannelUpdate(t *harnessTest, subscription graphSubscription, - expUpdates []expectedChanUpdate) { - - // Create an array indicating which expected channel updates we have - // received. - found := make([]bool, len(expUpdates)) -out: - for { - select { - case graphUpdate := <-subscription.updateChan: - for _, update := range graphUpdate.ChannelUpdates { - require.NotZerof( - t.t, len(expUpdates), - "received unexpected channel "+ - "update from %v for channel %v", - update.AdvertisingNode, - update.ChanId, - ) - - // For each expected update, check if it matches - // the update we just received. - for i, exp := range expUpdates { - fundingTxStr := txStr(update.ChanPoint) - if fundingTxStr != txStr(exp.chanPoint) { - continue - } - - if update.AdvertisingNode != - exp.advertisingNode { - continue - } - - err := lntest.CheckChannelPolicy( - update.RoutingPolicy, - exp.expectedPolicy, - ) - if err != nil { - continue - } - - // We got a policy update that matched - // the values and channel point of what - // we expected, mark it as found. - found[i] = true - - // If we have no more channel updates - // we are waiting for, break out of the - // loop. - rem := 0 - for _, f := range found { - if !f { - rem++ - } - } - - if rem == 0 { - break out - } - - // Since we found a match among the - // expected updates, break out of the - // inner loop. - break - } - } - case err := <-subscription.errChan: - t.Fatalf("unable to recv graph update: %v", err) - case <-time.After(defaultTimeout): - if len(expUpdates) == 0 { - return - } - t.Fatalf("did not receive channel update") - } - } -} - -// assertNoChannelUpdates ensures that no ChannelUpdates are sent via the -// graphSubscription. This method will block for the provided duration before -// returning to the caller if successful. -func assertNoChannelUpdates(t *harnessTest, subscription graphSubscription, - duration time.Duration) { - - timeout := time.After(duration) - for { - select { - case graphUpdate := <-subscription.updateChan: - require.Zero( - t.t, len(graphUpdate.ChannelUpdates), - "no channel updates were expected", - ) - - case err := <-subscription.errChan: - t.Fatalf("graph subscription failure: %v", err) - - case <-timeout: - // No updates received, success. - return - } - } -} - // getChannelPolicies queries the channel graph and retrieves the current edge // policies for the provided channel points. func getChannelPolicies(t *harnessTest, node *lntest.HarnessNode, @@ -745,7 +624,7 @@ func assertChannelPolicy(t *harnessTest, node *lntest.HarnessNode, for _, policy := range policies { err := lntest.CheckChannelPolicy(policy, expectedPolicy) if err != nil { - t.Fatalf(err.Error()) + t.Fatalf(fmt.Sprintf("%v: %s", err.Error(), node)) } } } @@ -1761,3 +1640,21 @@ func assertNumUTXOs(t *testing.T, node *lntest.HarnessNode, expectedUtxos int) { }, defaultTimeout) require.NoError(t, err, "wait for listunspent") } + +// assertChannelPolicyUpdate checks that the required policy update has +// happened on the given node. +func assertChannelPolicyUpdate(t *testing.T, node *lntest.HarnessNode, + advertisingNode string, policy *lnrpc.RoutingPolicy, + chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) { + + ctxb := context.Background() + ctxt, cancel := context.WithTimeout(ctxb, lntest.DefaultTimeout) + defer cancel() + + require.NoError( + t, node.WaitForChannelPolicyUpdate( + ctxt, advertisingNode, policy, + chanPoint, includeUnannounced, + ), "error while waiting for channel update", + ) +} diff --git a/lntest/itest/lnd_channel_graph_test.go b/lntest/itest/lnd_channel_graph_test.go index 774f8e2b9..c7040e02e 100644 --- a/lntest/itest/lnd_channel_graph_test.go +++ b/lntest/itest/lnd_channel_graph_test.go @@ -86,8 +86,20 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { net.ConnectNodes(t.t, alice, carol) net.ConnectNodes(t.t, bob, carol) - carolSub := subscribeGraphNotifications(ctxb, t, carol) - defer close(carolSub.quit) + // assertChannelUpdate checks that the required policy update has + // happened on the given node. + assertChannelUpdate := func(node *lntest.HarnessNode, + policy *lnrpc.RoutingPolicy) { + + ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) + defer cancel() + + require.NoError( + t.t, carol.WaitForChannelPolicyUpdate( + ctxt, node.PubKeyStr, policy, chanPoint, false, + ), "error while waiting for channel update", + ) + } // sendReq sends an UpdateChanStatus request to the given node. sendReq := func(node *lntest.HarnessNode, chanPoint *lnrpc.ChannelPoint, @@ -169,23 +181,13 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { // update is propagated. sendReq(alice, chanPoint, routerrpc.ChanStatusAction_DISABLE) expectedPolicy.Disabled = true - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {alice.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(alice, expectedPolicy) // Re-enable the channel and ensure that a "Disabled = false" update // is propagated. sendReq(alice, chanPoint, routerrpc.ChanStatusAction_ENABLE) expectedPolicy.Disabled = false - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {alice.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(alice, expectedPolicy) // Manually enabling a channel should NOT prevent subsequent // disconnections from automatically disabling the channel again @@ -195,24 +197,14 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to disconnect Alice from Bob: %v", err) } expectedPolicy.Disabled = true - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {alice.PubKeyStr, expectedPolicy, chanPoint}, - {bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(alice, expectedPolicy) + assertChannelUpdate(bob, expectedPolicy) // Reconnecting the nodes should propagate a "Disabled = false" update. net.EnsureConnected(t.t, alice, bob) expectedPolicy.Disabled = false - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {alice.PubKeyStr, expectedPolicy, chanPoint}, - {bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(alice, expectedPolicy) + assertChannelUpdate(bob, expectedPolicy) // Manually disabling the channel should prevent a subsequent // disconnect / reconnect from re-enabling the channel on @@ -223,12 +215,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { // Alice sends out the "Disabled = true" update in response to // the ChanStatusAction_DISABLE request. expectedPolicy.Disabled = true - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {alice.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(alice, expectedPolicy) if err := net.DisconnectNodes(alice, bob); err != nil { t.Fatalf("unable to disconnect Alice from Bob: %v", err) @@ -237,23 +224,13 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { // Bob sends a "Disabled = true" update upon detecting the // disconnect. expectedPolicy.Disabled = true - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(bob, expectedPolicy) // Bob sends a "Disabled = false" update upon detecting the // reconnect. net.EnsureConnected(t.t, alice, bob) expectedPolicy.Disabled = false - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(bob, expectedPolicy) // However, since we manually disabled the channel on Alice's end, // the policy on Alice's end should still be "Disabled = true". Again, @@ -267,26 +244,17 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { // Bob sends a "Disabled = true" update upon detecting the // disconnect. expectedPolicy.Disabled = true - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(bob, expectedPolicy) // After restoring automatic channel state management on Alice's end, // BOTH Alice and Bob should set the channel state back to "enabled" // on reconnect. sendReq(alice, chanPoint, routerrpc.ChanStatusAction_AUTO) net.EnsureConnected(t.t, alice, bob) + expectedPolicy.Disabled = false - waitForChannelUpdate( - t, carolSub, - []expectedChanUpdate{ - {alice.PubKeyStr, expectedPolicy, chanPoint}, - {bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) + assertChannelUpdate(alice, expectedPolicy) + assertChannelUpdate(bob, expectedPolicy) assertEdgeDisabled(alice, chanPoint, false) } diff --git a/lntest/itest/lnd_channel_policy_test.go b/lntest/itest/lnd_channel_policy_test.go index 67c76f342..3bdadf86c 100644 --- a/lntest/itest/lnd_channel_policy_test.go +++ b/lntest/itest/lnd_channel_policy_test.go @@ -28,14 +28,6 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { ) defaultMaxHtlc := calculateMaxHtlc(funding.MaxBtcFundingAmount) - // Launch notification clients for all nodes, such that we can - // get notified when they discover new channels and updates in the - // graph. - aliceSub := subscribeGraphNotifications(ctxb, t, net.Alice) - defer close(aliceSub.quit) - bobSub := subscribeGraphNotifications(ctxb, t, net.Bob) - defer close(bobSub.quit) - chanAmt := funding.MaxBtcFundingAmount pushAmt := chanAmt / 2 @@ -47,12 +39,27 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { PushAmt: pushAmt, }, ) + defer closeChannelAndAssert(t, net, net.Alice, chanPoint, false) // We add all the nodes' update channels to a slice, such that we can // make sure they all receive the expected updates. - graphSubs := []graphSubscription{aliceSub, bobSub} nodes := []*lntest.HarnessNode{net.Alice, net.Bob} + // assertPolicyUpdate checks that a given policy update has been + // received by a list of given nodes. + assertPolicyUpdate := func(nodes []*lntest.HarnessNode, + advertisingNode string, policy *lnrpc.RoutingPolicy, + chanPoint *lnrpc.ChannelPoint) { + + for _, node := range nodes { + assertChannelPolicyUpdate( + t.t, node, advertisingNode, + policy, chanPoint, false, + ) + } + + } + // Alice and Bob should see each other's ChannelUpdates, advertising the // default routing policies. expectedPolicy := &lnrpc.RoutingPolicy{ @@ -63,15 +70,10 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { MaxHtlcMsat: defaultMaxHtlc, } - for _, graphSub := range graphSubs { - waitForChannelUpdate( - t, graphSub, - []expectedChanUpdate{ - {net.Alice.PubKeyStr, expectedPolicy, chanPoint}, - {net.Bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) - } + assertPolicyUpdate( + nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint, + ) + assertPolicyUpdate(nodes, net.Bob.PubKeyStr, expectedPolicy, chanPoint) // They should now know about the default policies. for _, node := range nodes { @@ -105,10 +107,6 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { // Clean up carol's node when the test finishes. defer shutdownAndAssert(net, t, carol) - carolSub := subscribeGraphNotifications(ctxb, t, carol) - defer close(carolSub.quit) - - graphSubs = append(graphSubs, carolSub) nodes = append(nodes, carol) // Send some coins to Carol that can be used for channel funding. @@ -129,6 +127,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { MinHtlc: customMinHtlc, }, ) + defer closeChannelAndAssert(t, net, net.Bob, chanPoint2, false) expectedPolicyBob := &lnrpc.RoutingPolicy{ FeeBaseMsat: defaultFeeBase, @@ -145,15 +144,12 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { MaxHtlcMsat: defaultMaxHtlc, } - for _, graphSub := range graphSubs { - waitForChannelUpdate( - t, graphSub, - []expectedChanUpdate{ - {net.Bob.PubKeyStr, expectedPolicyBob, chanPoint2}, - {carol.PubKeyStr, expectedPolicyCarol, chanPoint2}, - }, - ) - } + assertPolicyUpdate( + nodes, net.Bob.PubKeyStr, expectedPolicyBob, chanPoint2, + ) + assertPolicyUpdate( + nodes, carol.PubKeyStr, expectedPolicyCarol, chanPoint2, + ) // Check that all nodes now know about the updated policies. for _, node := range nodes { @@ -345,14 +341,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { } // Wait for all nodes to have seen the policy update done by Bob. - for _, graphSub := range graphSubs { - waitForChannelUpdate( - t, graphSub, - []expectedChanUpdate{ - {net.Bob.PubKeyStr, expectedPolicy, chanPoint}, - }, - ) - } + assertPolicyUpdate(nodes, net.Bob.PubKeyStr, expectedPolicy, chanPoint) // Check that all nodes now know about Bob's updated policy. for _, node := range nodes { @@ -396,6 +385,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { PushAmt: pushAmt, }, ) + defer closeChannelAndAssert(t, net, net.Alice, chanPoint3, false) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint3) @@ -436,15 +426,12 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { // Wait for all nodes to have seen the policy updates for both of // Alice's channels. - for _, graphSub := range graphSubs { - waitForChannelUpdate( - t, graphSub, - []expectedChanUpdate{ - {net.Alice.PubKeyStr, expectedPolicy, chanPoint}, - {net.Alice.PubKeyStr, expectedPolicy, chanPoint3}, - }, - ) - } + assertPolicyUpdate( + nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint, + ) + assertPolicyUpdate( + nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint3, + ) // And finally check that all nodes remembers the policy update they // received. @@ -469,47 +456,49 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) defer cancel() _, err = net.Alice.UpdateChannelPolicy(ctxt, req) - if err != nil { - t.Fatalf("unable to update alice's channel policy: %v", err) - } + require.NoError(t.t, err) // Wait for all nodes to have seen the policy updates for both // of Alice's channels. Carol will not see the last update as // the limit has been reached. - for idx, graphSub := range graphSubs { - expUpdates := []expectedChanUpdate{ - {net.Alice.PubKeyStr, expectedPolicy, chanPoint}, - {net.Alice.PubKeyStr, expectedPolicy, chanPoint3}, - } - // Carol was added last, which is why we check the last - // index. - if i == numUpdatesTilRateLimit-1 && idx == len(graphSubs)-1 { - expUpdates = nil - } - waitForChannelUpdate(t, graphSub, expUpdates) - } + assertPolicyUpdate( + []*lntest.HarnessNode{net.Alice, net.Bob}, + net.Alice.PubKeyStr, expectedPolicy, chanPoint, + ) + assertPolicyUpdate( + []*lntest.HarnessNode{net.Alice, net.Bob}, + net.Alice.PubKeyStr, expectedPolicy, chanPoint3, + ) + // Check that all nodes remembers the policy update + // they received. + assertChannelPolicy( + t, net.Alice, net.Alice.PubKeyStr, + expectedPolicy, chanPoint, chanPoint3, + ) + assertChannelPolicy( + t, net.Bob, net.Alice.PubKeyStr, + expectedPolicy, chanPoint, chanPoint3, + ) - // And finally check that all nodes remembers the policy update - // they received. Since Carol didn't receive the last update, - // she still has Alice's old policy. - for idx, node := range nodes { - policy := expectedPolicy - // Carol was added last, which is why we check the last - // index. - if i == numUpdatesTilRateLimit-1 && idx == len(nodes)-1 { - policy = &prevAlicePolicy - } - assertChannelPolicy( - t, node, net.Alice.PubKeyStr, policy, chanPoint, - chanPoint3, - ) + // Carol was added last, which is why we check the last index. + // Since Carol didn't receive the last update, she still has + // Alice's old policy. + if i == numUpdatesTilRateLimit-1 { + expectedPolicy = &prevAlicePolicy } + assertPolicyUpdate( + []*lntest.HarnessNode{carol}, + net.Alice.PubKeyStr, expectedPolicy, chanPoint, + ) + assertPolicyUpdate( + []*lntest.HarnessNode{carol}, + net.Alice.PubKeyStr, expectedPolicy, chanPoint3, + ) + assertChannelPolicy( + t, carol, net.Alice.PubKeyStr, + expectedPolicy, chanPoint, chanPoint3, + ) } - - // Close the channels. - closeChannelAndAssert(t, net, net.Alice, chanPoint, false) - closeChannelAndAssert(t, net, net.Bob, chanPoint2, false) - closeChannelAndAssert(t, net, net.Alice, chanPoint3, false) } // testSendUpdateDisableChannel ensures that a channel update with the disable @@ -583,9 +572,6 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { net.ConnectNodes(t.t, net.Bob, dave) - daveSub := subscribeGraphNotifications(ctxb, t, dave) - defer close(daveSub.quit) - // We should expect to see a channel update with the default routing // policy, except that it should indicate the channel is disabled. expectedPolicy := &lnrpc.RoutingPolicy{ @@ -597,18 +583,29 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { Disabled: true, } + // assertPolicyUpdate checks that the required policy update has + // happened on the given node. + assertPolicyUpdate := func(node *lntest.HarnessNode, + policy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint) { + + ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) + defer cancel() + + require.NoError( + t.t, dave.WaitForChannelPolicyUpdate( + ctxt, node.PubKeyStr, policy, chanPoint, false, + ), "error while waiting for channel update", + ) + } + // Let Carol go offline. Since Eve has an inactive timeout of 2s, we // expect her to send an update disabling the channel. restartCarol, err := net.SuspendNode(carol) if err != nil { t.Fatalf("unable to suspend carol: %v", err) } - waitForChannelUpdate( - t, daveSub, - []expectedChanUpdate{ - {eve.PubKeyStr, expectedPolicy, chanPointEveCarol}, - }, - ) + + assertPolicyUpdate(eve, expectedPolicy, chanPointEveCarol) // We restart Carol. Since the channel now becomes active again, Eve // should send a ChannelUpdate setting the channel no longer disabled. @@ -617,12 +614,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { } expectedPolicy.Disabled = false - waitForChannelUpdate( - t, daveSub, - []expectedChanUpdate{ - {eve.PubKeyStr, expectedPolicy, chanPointEveCarol}, - }, - ) + assertPolicyUpdate(eve, expectedPolicy, chanPointEveCarol) // Now we'll test a long disconnection. Disconnect Carol and Eve and // ensure they both detect each other as disabled. Their min backoffs @@ -633,26 +625,16 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { // Wait for a disable from both Carol and Eve to come through. expectedPolicy.Disabled = true - waitForChannelUpdate( - t, daveSub, - []expectedChanUpdate{ - {eve.PubKeyStr, expectedPolicy, chanPointEveCarol}, - {carol.PubKeyStr, expectedPolicy, chanPointEveCarol}, - }, - ) + assertPolicyUpdate(eve, expectedPolicy, chanPointEveCarol) + assertPolicyUpdate(carol, expectedPolicy, chanPointEveCarol) // Reconnect Carol and Eve, this should cause them to reenable the // channel from both ends after a short delay. net.EnsureConnected(t.t, carol, eve) expectedPolicy.Disabled = false - waitForChannelUpdate( - t, daveSub, - []expectedChanUpdate{ - {eve.PubKeyStr, expectedPolicy, chanPointEveCarol}, - {carol.PubKeyStr, expectedPolicy, chanPointEveCarol}, - }, - ) + assertPolicyUpdate(eve, expectedPolicy, chanPointEveCarol) + assertPolicyUpdate(carol, expectedPolicy, chanPointEveCarol) // Now we'll test a short disconnection. Disconnect Carol and Eve, then // reconnect them after one second so that their scheduled disables are @@ -667,8 +649,10 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { net.EnsureConnected(t.t, eve, carol) // Since the disable should have been canceled by both Carol and Eve, we - // expect no channel updates to appear on the network. - assertNoChannelUpdates(t, daveSub, 4*time.Second) + // expect no channel updates to appear on the network, which means we + // expect the polices stay unchanged(Disable == false). + assertPolicyUpdate(eve, expectedPolicy, chanPointEveCarol) + assertPolicyUpdate(carol, expectedPolicy, chanPointEveCarol) // Close Alice's channels with Bob and Carol cooperatively and // unilaterally respectively. @@ -685,13 +669,8 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { // Now that the channel close processes have been started, we should // receive an update marking each as disabled. expectedPolicy.Disabled = true - waitForChannelUpdate( - t, daveSub, - []expectedChanUpdate{ - {net.Alice.PubKeyStr, expectedPolicy, chanPointAliceBob}, - {net.Alice.PubKeyStr, expectedPolicy, chanPointAliceCarol}, - }, - ) + assertPolicyUpdate(net.Alice, expectedPolicy, chanPointAliceBob) + assertPolicyUpdate(net.Alice, expectedPolicy, chanPointAliceCarol) // Finally, close the channels by mining the closing transactions. mineBlocks(t, net, 1, 2) @@ -702,12 +681,8 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to close channel: %v", err) } - waitForChannelUpdate( - t, daveSub, - []expectedChanUpdate{ - {eve.PubKeyStr, expectedPolicy, chanPointEveCarol}, - }, - ) + assertPolicyUpdate(eve, expectedPolicy, chanPointEveCarol) + mineBlocks(t, net, 1, 1) // And finally, clean up the force closed channel by mining the diff --git a/lntest/itest/lnd_multi-hop-payments_test.go b/lntest/itest/lnd_multi-hop-payments_test.go index 734d5378f..d1b578dc4 100644 --- a/lntest/itest/lnd_multi-hop-payments_test.go +++ b/lntest/itest/lnd_multi-hop-payments_test.go @@ -418,14 +418,8 @@ func updateChannelPolicy(t *harnessTest, node *lntest.HarnessNode, } // Wait for listener node to receive the channel update from node. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - graphSub := subscribeGraphNotifications(ctxt, t, listenerNode) - defer close(graphSub.quit) - - waitForChannelUpdate( - t, graphSub, - []expectedChanUpdate{ - {node.PubKeyStr, expectedPolicy, chanPoint}, - }, + assertChannelPolicyUpdate( + t.t, listenerNode, node.PubKeyStr, + expectedPolicy, chanPoint, false, ) } diff --git a/lntest/itest/lnd_routing_test.go b/lntest/itest/lnd_routing_test.go index 6f33d3def..54ea43c13 100644 --- a/lntest/itest/lnd_routing_test.go +++ b/lntest/itest/lnd_routing_test.go @@ -1814,15 +1814,9 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) { } // Wait for Alice to receive the channel update from Carol. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - aliceSub := subscribeGraphNotifications(ctxt, t, net.Alice) - defer close(aliceSub.quit) - - waitForChannelUpdate( - t, aliceSub, - []expectedChanUpdate{ - {carol.PubKeyStr, expectedPolicy, chanPointCarolDave}, - }, + assertChannelPolicyUpdate( + t.t, net.Alice, carol.PubKeyStr, + expectedPolicy, chanPointCarolDave, false, ) // We'll also need the channel IDs for Bob's channels in order to