Skip to content

lnwallet/chancloser: fix flake in TestRbfCloseClosingNegotiationLocal #9652

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Roasbeef
Copy link
Member

In this commit, we fix a flake in the rbf loop sub-test for the TestRbfCloseClosingNegotiationLocal test case.

The fix here is that when we go from ClosePending for an RBF iteration loop, we first transition to LocalCloseStart. However we only do this extra transition if we're doing an iteration (starting from ClosePending).

To fix this, we add a new bool that tracks if this is an iteration or not. We can then also eliminate the extra assertion at the end, as we'll terminate in ClosePending which is checked by
assertLocalClosePending() in assertSingleRbfIteration.

Fixes #9526.

Copy link
Contributor

coderabbitai bot commented Mar 27, 2025

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a test flake in the RBF loop for the TestRbfCloseClosingNegotiationLocal by introducing an iteration flag to better track state transitions during iterations.

  • Adds an iteration boolean parameter to the functions expectHalfSignerIteration and assertSingleRbfIteration.
  • Updates test calls to pass the correct iteration flag.

// If we're in the middle of an iteration, then we expect a transition
// from ClosePending -> LocalCloseStart.
if iteration {
expectedStates = append(expectedStates, &ClosingNegotiation{})
Copy link
Preview

Copilot AI Mar 27, 2025

Choose a reason for hiding this comment

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

The comment indicates that during an iteration the state should transition from ClosePending to LocalCloseStart, but the code appends a ClosingNegotiation state. Verify if the intended behavior should append a LocalCloseStart state instead.

Suggested change
expectedStates = append(expectedStates, &ClosingNegotiation{})
expectedStates = append(expectedStates, &LocalCloseStart{})

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, but that's the inner state (which lives in ClosingNegotiation). If we wanted to make the assertion clearer, we could add something like assertInnerStateTransitions.

@Roasbeef
Copy link
Member Author

Looks like this revealed another flake:

--- FAIL: TestRbfChannelFlushingTransitions (0.02s)
    --- FAIL: TestRbfChannelFlushingTransitions/unknown_event (0.01s)
        rbf_coop_test.go:805: 
            	Error Trace:	/home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:116
            	            				/home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:257
            	            				/home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:805
            	            				/home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:144
            	Error:      	Received unexpected error:
            	            	timeout hit
            	Test:       	TestRbfChannelFlushingTransitions/unknown_event
            	Messages:   	expected state: *chancloser.ChannelFlushing

Will look into it.

In this commit, we fix a flake in the rbf loop sub-test for the
TestRbfCloseClosingNegotiationLocal test case.

The fix here is that when we go from ClosePending for an RBF iteration
loop, we first transition to LocalCloseStart. However we only do this
extra transition if we're doing an iteration (starting from ClosePending).

To fix this, we add a new bool that tracks if this is an iteration or
not. We can then also eliminate the extra assertion at the end, as we'll
terminate in `ClosePending` which is checked by
`assertLocalClosePending()` in `assertSingleRbfIteration`.

Fixes lightningnetwork#9526.
@Roasbeef Roasbeef force-pushed the rbf-iteration-loop-flake branch from 67e9826 to 40f58da Compare April 2, 2025 00:03
@Roasbeef
Copy link
Member Author

Roasbeef commented Apr 2, 2025

I think that was a flake that was fixed in my other PR. Pushed up a rebased version.

@Roasbeef Roasbeef requested review from a team, bhandras, bitromortac and yyforyongyu and removed request for a team, bhandras and bitromortac April 2, 2025 00:12
Copy link
Member

@yyforyongyu yyforyongyu left a 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! Looks like we have one more flake tho,

--- FAIL: TestRbfCloseClosingNegotiationLocal (0.04s)
    --- FAIL: TestRbfCloseClosingNegotiationLocal/send_offer_rbf_wrong_local_script (0.00s)
        rbf_coop_test.go:1565: FAIL:	ReportError(mock.argumentMatcher)
            		at: [/home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:398 /home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:1548]
        rbf_coop_test.go:1565: FAIL: 0 out of 1 expectation(s) were met.
            	The code you are testing needs to make 1 more call(s).
            	at: [/home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:238 /home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:248 /home/runner/work/lnd/lnd/lnwallet/chancloser/rbf_coop_test.go:1565]
FAIL
FAIL	github.com/lightningnetwork/lnd/lnwallet/chancloser	0.505s
FAIL

@Roasbeef
Copy link
Member Author

Roasbeef commented Apr 4, 2025

Hmm yeah I think this fix exposed some other ones. I think the issue is mainly with the way the test framework does the assertions.

I'll do a pass to try to make the state assertions more precise.

@lightninglabs-deploy
Copy link

@Roasbeef, remember to re-request review from reviewers when ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[unit test flake]: TestRbfCloseClosingNegotiationLocal fails
3 participants