Skip to content

Conversation

@joostjager
Copy link
Contributor

@joostjager joostjager commented Oct 6, 2025

Store the latest persisted monitor in TestChainMonitor so it no longer needs to be passed into reload. This change also makes the test more realistic. If the monitor wasn't actually persisted, it won't reload properly.

This is a preparation for the larger channel manager refactor project.

@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@joostjager joostjager changed the title Real persist Simplify node reload logic in tests Oct 6, 2025
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.74%. Comparing base (7439528) to head (3727fbc).
⚠️ Report is 61 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4142      +/-   ##
==========================================
+ Coverage   88.63%   88.74%   +0.11%     
==========================================
  Files         180      180              
  Lines      135230   135507     +277     
  Branches   135230   135507     +277     
==========================================
+ Hits       119865   120261     +396     
+ Misses      12594    12482     -112     
+ Partials     2771     2764       -7     
Flag Coverage Δ
fuzzing 21.72% <0.00%> (-0.04%) ⬇️
tests 88.59% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Store the latest persisted monitor in TestChainMonitor so it no longer
needs to be passed into reload. This change also makes the test more
realistic. If the monitor wasn't actually persisted, it won't reload
properly.
Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

LGTM, I think we can land with 1 ack


let mut deserialized_fwd_htlcs = nodes[0].node.forward_htlcs.lock().unwrap();
for scid in [scid_1, scid_2].iter() {
let mut deserialized_fwd_htlcs = nodes[0].node.forward_htlcs.lock().unwrap(); for scid in [scid_1, scid_2].iter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: needs newline

}

#[cfg(test)]
macro_rules! reload_node_and_monitors {
Copy link
Contributor

Choose a reason for hiding this comment

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

Split into two macros? 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm why am I even adding new macros. Maybe I should fn'ify it.

@joostjager joostjager self-assigned this Oct 9, 2025
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

This means we can't write async-persist tests that load from a ChannelMonitor that never finished its persistence, afaict?

@joostjager
Copy link
Contributor Author

This means we can't write async-persist tests that load from a ChannelMonitor that never finished its persistence, afaict?

My thought was to use the new macro only when possible and with scenarios that are simple reloads. With the way the tests are currently set up (manual monitor serialization, without a connection to persister), I don't think it would be possible to test storing channels alongside channel monitors? Because for that, somehow the call to persister needs to store it's arguments, so that they can be used when reloading chan mgr. I guess that could also be done manually though...?

@TheBlueMatt
Copy link
Collaborator

With the way the tests are currently set up (manual monitor serialization, without a connection to persister), I don't think it would be possible to test storing channels alongside channel monitors?

Not sure I understand this? If we're storing channels in monitors (+ in channelmonitorupdates) it should be easy to test?

@joostjager
Copy link
Contributor Author

If we're storing channels in monitors (+ in channelmonitorupdates) it should be easy to test?

I just wanted to avoid manually extracting the serialized channels in the test code and passing them in when reloading the node. But it seems that there are too many special cases to make this nice and clean.

Closing this and going to try modifying the tests to get the serialized channels from TestPersister and passing them to reload node.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants