-
Notifications
You must be signed in to change notification settings - Fork 2.2k
chancloser: fix flakes in chancloser tests #10052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @guggero, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses and fixes flaky tests within the chancloser package. The primary goal is to enhance the stability and reliability of cooperative channel closing tests, particularly those involving RBF and Taproot fast closes, by refining test logic related to transaction broadcasting and correcting assertion expectations for dust outputs.
Highlights
- Improved Test Determinism: Refactored the
TestTaprootFastCloseinchancloser_test.goto use distinct broadcast channels for Alice and Bob. This change replaces a single shared broadcast signal with separate channels (aliceBroadcastandbobBroadcast), ensuring that the test correctly waits for the specific party's transaction broadcast, thereby preventing potential race conditions and improving test reliability. - Corrected RBF Test Assertions: Updated the
rbf_coop_test.gofile to correct an assertion parameter within theassertSingleRbfIterationfunction. The parameter passed toexpectHalfSignerIterationwas changed fromnoDustExpecttodustExpect, indicating a more accurate expectation regarding dust outputs during RBF (Replace-by-Fee) cooperative closing iterations, which resolves a source of test flakiness.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to fix flaky tests in the chancloser package. The changes are well-targeted and improve test stability.
In chancloser_test.go, the TestTaprootFastClose test is refactored to use two separate channels for broadcast signals from Alice and Bob, instead of a single shared channel. This is an excellent change that eliminates potential race conditions and makes the test more deterministic.
In rbf_coop_test.go, a bug in the assertSingleRbfIteration test helper is fixed. The function was previously ignoring its dustExpect parameter. This has been corrected to properly propagate the parameter, ensuring the helper function behaves as intended.
The changes are correct and improve the quality of the test suite. I have no further suggestions.
yyforyongyu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you🙏
yyforyongyu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm looks like we still got one more flake
Makefile
Outdated
| $(UNIT_BENCH) | ||
|
|
||
| #? unit-flake: Run the unit tests continuously until one fails | ||
| unit-flake: $(BTCD_BIN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: name it flakehunter-unit-all to keep them consistent below?
Yeah, whenever I think I've patched one flake, another pops up... Not sure this is easy to fix. Or I (and Gemini) are just missing something simple... Tried quite a few iterations locally. |
yeah why don't we merge what we have so far and then fix it in another PR? Think as long as the number of flaky tests decreases it's still a win. |
Makes sense. I pushed up one more commit that increases some of the timeouts, perhaps that also helps a bit. |
yyforyongyu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! LGTM❤️
ellemouton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the flake fixes!
just a few questions
The param previously was unused so this was likely an oversight or copy/paste error. This does not change any behavior, as the method was always called with the constant previously used. But it makes things more explicit.
This doesn't change the behavior but makes the use of the broadcast channels more clear.
|
Okay, after investing HUMAN debugging minutes, I actually found the flake :D |
ellemouton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!! ✅
These two new goals take all the usual flags like pkg=, case=, nocache= and so on.
This fixes the actual flake: We didn't wait for next iterations to _not_ come in, so depending on timing, we could read another transition in a second run. But making sure we expect all transitions at the same time and then make sure no further transitions come in makes this not depend on time.
These tests previously only worked because we didn't properly wait for all transitions to come in. We fix them by correctly asserting the expected number of state transitions.
Fixes another flake in the unit-race test: Sometimes we miss startup events if there's a high CPU load (in CI for example). To avoid that, we register our subscriber before starting the state machine.
|
Added another flake fix, this time for the race unit test. Also fixed some more formatting issues. |
ellemouton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 🧼
| // We register our subscriber before starting the state machine, to make | ||
| // sure we don't miss any events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixed by
gemini-cli.Attempts to fix the following flake: