Skip to content

Commit

Permalink
Merge pull request #9567 from ellemouton/graph18
Browse files Browse the repository at this point in the history
itest: make sure to not hit the natural ChannelUpdate rate limit
  • Loading branch information
ellemouton authored Mar 3, 2025
2 parents 1293f2e + 6047bef commit b7c5895
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ The underlying functionality between those two options remain the same.
* Add a new CI-step to do some basic [backwards compatibility
testing](https://github.com/lightningnetwork/lnd/pull/9540) for each PR.

* [Fix](https://github.com/lightningnetwork/lnd/pull/9567) an itest flake where
if a channel update is sent too quickly after the previous one, then it would
be ignored due to the timestamp of the second update not being after the
previous one.

## Database

* [Migrate the mission control
Expand Down
22 changes: 17 additions & 5 deletions itest/lnd_channel_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
// but not the second, as she only allows two updates per day and a day
// has yet to elapse from the previous update.

// assertAliceAndBob is a helper closure which updates Alice's policy
// and asserts that both Alice and Bob have heard and updated the
// updateAndAssertAliceAndBob is a helper closure which updates Alice's
// policy and asserts that both Alice and Bob have heard and updated the
// policy in their graph.
assertAliceAndBob := func(req *lnrpc.PolicyUpdateRequest,
updateAndAssertAliceAndBob := func(req *lnrpc.PolicyUpdateRequest,
expectedPolicy *lnrpc.RoutingPolicy) {

alice.RPC.UpdateChannelPolicy(req)
Expand Down Expand Up @@ -377,14 +377,20 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
)
}

// Channel Updates actually also have a natural rate limit of 1 update
// per second due to the fact that the timestamp carried in the update
// is only accurate to the second. So we need to ensure that the next
// update we send in the burst is at least 1 second after the last one.
time.Sleep(time.Second)

// Double the base fee and attach to the policy. Moreover, we set the
// inbound fee to nil and test that it does not change the propagated
// inbound fee.
baseFee1 := baseFee * 2
expectedPolicy.FeeBaseMsat = baseFee1
req.BaseFeeMsat = baseFee1
req.InboundFee = nil
assertAliceAndBob(req, expectedPolicy)
updateAndAssertAliceAndBob(req, expectedPolicy)

// Check that Carol has both heard the policy and updated it in her
// graph.
Expand All @@ -403,11 +409,17 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
carol, alice.PubKeyStr, expectedPolicy, chanPoint3,
)

// Similarly to above, we again wait for the natural rate limit of the
// ChannelUpdate to pass so that we are really testing that Carol is
// _not_ getting this next update due to her rate limiting settings and
// not due to the natural rate limit being met.
time.Sleep(time.Second)

// Double the base fee and attach to the policy.
baseFee2 := baseFee1 * 2
expectedPolicy.FeeBaseMsat = baseFee2
req.BaseFeeMsat = baseFee2
assertAliceAndBob(req, expectedPolicy)
updateAndAssertAliceAndBob(req, expectedPolicy)

// Since Carol didn't receive the last update, she still has Alice's
// old policy. We validate this by checking the base fee is the older
Expand Down

0 comments on commit b7c5895

Please sign in to comment.