Skip to content

tests: fixe test_multichan_stress flake - #9401

Merged
daywalker90 merged 1 commit into
ElementsProject:masterfrom
daywalker90:fix-multichan-stress-test-flake
Aug 11, 2026
Merged

tests: fixe test_multichan_stress flake#9401
daywalker90 merged 1 commit into
ElementsProject:masterfrom
daywalker90:fix-multichan-stress-test-flake

Conversation

@daywalker90

Copy link
Copy Markdown
Collaborator
         def send_many_payments():
             passes = 0
             fails = 0
             # Make sure we try many times, and get at least one pass and fail.
             while passes == 0 or fails == 0 or passes + fails < 30:
                 inv = l3.rpc.invoice(100, "label-" + str(passes + fails), "desc")
                 l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])
                 time.sleep(0.05)
                 try:
                     l1.rpc.waitsendpay(inv['payment_hash'])
                     passes += 1
                 except RpcError:
                     fails += 1
                     pass

         # Send a heap of payments, while reconnecting...
         fut = executor.submit(send_many_payments)

         for _ in range(30):
             l3.rpc.disconnect(l2.info['id'], force=True)
             time.sleep(0.1)
             l3.rpc.connect(l2.info['id'], 'localhost', l2.port)
 >       fut.result(TIMEOUT)

The while loop would somtimes go infinitely long if no payments fail.

Fixes: #9326

```
         def send_many_payments():
             passes = 0
             fails = 0
             # Make sure we try many times, and get at least one pass and fail.
             while passes == 0 or fails == 0 or passes + fails < 30:
                 inv = l3.rpc.invoice(100, "label-" + str(passes + fails), "desc")
                 l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])
                 time.sleep(0.05)
                 try:
                     l1.rpc.waitsendpay(inv['payment_hash'])
                     passes += 1
                 except RpcError:
                     fails += 1
                     pass

         # Send a heap of payments, while reconnecting...
         fut = executor.submit(send_many_payments)

         for _ in range(30):
             l3.rpc.disconnect(l2.info['id'], force=True)
             time.sleep(0.1)
             l3.rpc.connect(l2.info['id'], 'localhost', l2.port)
 >       fut.result(TIMEOUT)
```

The while loop would somtimes go infinitely long if no payments fail.

Changelog-None
@daywalker90 daywalker90 added the Status::Ready for Review The work has been completed and is now awaiting evaluation or approval. label Aug 11, 2026
@daywalker90
daywalker90 requested a review from Andezion August 11, 2026 12:08

@Andezion Andezion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look cool to me!

Comment thread tests/test_connection.py
# (reconnects are fast), so we can't rely on getting either.
# Send a bounded number while the reconnects run, and let the
# payments below verify the channels work afterwards.
for i in range(50):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly 50 loops?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it was minimum 30 and the sleep is shorter in the payments loop so i added a bit for good measure. I have not measured it but the goal is for the payments loop and the reconnect loop to take roughly equally long.

@daywalker90
daywalker90 enabled auto-merge (rebase) August 11, 2026 14:53
@daywalker90
daywalker90 merged commit 7faac86 into ElementsProject:master Aug 11, 2026
87 of 89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status::Ready for Review The work has been completed and is now awaiting evaluation or approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI flake test_multichan_stress

2 participants