Skip to content
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

Add test coverage of async BP and fix minor bug #2145

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

Also may help debug #2144, though now that I look at it I don't see how async-specific changes could have broken tests - the tests didn't test async at all lol.

@TheBlueMatt TheBlueMatt added this to the 0.0.115 milestone Apr 3, 2023
@TheBlueMatt TheBlueMatt linked an issue Apr 3, 2023 that may be closed by this pull request
Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

LGTM

lightning-background-processor/src/lib.rs Show resolved Hide resolved
lightning-background-processor/src/lib.rs Outdated Show resolved Hide resolved
@wpaulino
Copy link
Contributor

wpaulino commented Apr 4, 2023

Feel free to squash

Instead of asserting a `Result` `is_ok`, we should always simply
`unwrap` to get a backgrace, and we should avoid doing so if the
thread is already panicking.
If `ChannelManager` is persistable before the async background
processor even starts, it may not even get around to overwriting
the `should_exit` flag before testing it, and the default value is
(incorrectly) true, causing an immediate unconditional exit.

The default value should simply be false.

Fixes lightningdevkit#2140
If the user's sleep future passed to an async background processor
only returns true for exiting once and then reverts back to false,
we should exit anyway when we get a chance to. We do to this here
by always ensuring we check the exit flag even when only polling
sleep futures with no intent to (yet) exit. This is utilized in the
tests added in the coming commit(s).
This finally gives us a bit of test coverage of the async BP, which
was embarrassingly missing until now.
This gives us coverage of an async BP returning an error.
@TheBlueMatt
Copy link
Collaborator Author

Squashed without further changes.

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (3b8bf93) 91.35% compared to head (0618fbe) 91.38%.

❗ Current head 0618fbe differs from pull request most recent head 068d2c6. Consider uploading reports for the commit 068d2c6 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2145      +/-   ##
==========================================
+ Coverage   91.35%   91.38%   +0.03%     
==========================================
  Files         102      102              
  Lines       49909    49852      -57     
  Branches    49909    49852      -57     
==========================================
- Hits        45592    45556      -36     
+ Misses       4317     4296      -21     
Impacted Files Coverage Δ
lightning-background-processor/src/lib.rs 76.66% <100.00%> (-1.12%) ⬇️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1186,7 +1186,9 @@ mod tests {
let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "scorer".to_string());
check_persisted_data!(nodes[0].scorer, filepath.clone());

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking nit: Since we're touching them, all of these could also be expect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it matters? Its a test and I think the expectation here is clear, we don't really need to document why we shouldnt get an error?

@TheBlueMatt TheBlueMatt merged commit 8fcbe64 into lightningdevkit:main Apr 5, 2023
14 checks passed
@valentinewallace valentinewallace mentioned this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always honor return value in BP process_events_async
4 participants