itest+lntest: fix flake in MPP-related tests

This commit is contained in:
yyforyongyu 2024-11-21 14:09:57 +08:00
parent fb59669ae8
commit cfb5713cda
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
2 changed files with 31 additions and 3 deletions

View File

@ -378,6 +378,33 @@ func (c *mppTestScenario) setupSendPaymentCase() btcutil.Amount {
// - 2nd attempt(75,000 sats): Alice->Dave->Bob: 155,000 sats. // - 2nd attempt(75,000 sats): Alice->Dave->Bob: 155,000 sats.
// - 3rd attempt(75,000 sats): Alice->Carol->Eve->Bob: 155,000 sats. // - 3rd attempt(75,000 sats): Alice->Carol->Eve->Bob: 155,000 sats.
// //
// There is a case where the payment will fail due to the channel
// bandwidth not being updated in the graph, which has been seen many
// times:
// 1. the 1st attempt (150,000 sats) is sent via
// Alice->Carol->Eve->Bob, after which the capacity in Carol->Eve
// should decrease.
// 2. the 2nd attempt (75,000 sats) is sent via Alice->Carol->Eve->Bob,
// which shouldn't happen because the capacity in Carol->Eve is
// depleted. However, since the HTLCs are sent in parallel, the 2nd
// attempt can be sent before the capacity is updated in the graph.
// 3. if the 2nd attempt succeeds, the 1st attempt will fail and be
// split into two attempts, each holding 75,000 sats. At this point,
// we have three attempts to send, but only two routes are
// available, causing the payment to be failed.
// 4. In addition, with recent fee buffer addition, the attempts will
// fail even earlier without being further split.
//
// To avoid this case, we now increase the channel capacity of the
// route Carol->Eve->Bob and Carol->Bob such that even the above case
// happened, we can still send the HTLCs.
//
// TODO(yy): we should properly fix this in the router. Atm we only
// perform this hack to unblock the CI.
req.amtCarolBob = 285_000
req.amtEveBob = 285_000
req.amtCarolEve = 285_000
// Open the channels as described above. // Open the channels as described above.
c.openChannels(req) c.openChannels(req)

View File

@ -1513,13 +1513,14 @@ func (h *HarnessTest) AssertNumHTLCsAndStage(hn *node.HarnessNode,
lnutils.SpewLogClosure(target.PendingHtlcs)()) lnutils.SpewLogClosure(target.PendingHtlcs)())
} }
for i, htlc := range target.PendingHtlcs { for _, htlc := range target.PendingHtlcs {
if htlc.Stage == stage { if htlc.Stage == stage {
continue continue
} }
return fmt.Errorf("HTLC %d got stage: %v, "+ return fmt.Errorf("HTLC %s got stage: %v, "+
"want stage: %v", i, htlc.Stage, stage) "want stage: %v", htlc.Outpoint, htlc.Stage,
stage)
} }
return nil return nil