Correct and clarify comments in `ChannelMonitor` loading test utils
What changed, and why it matters
This commit only changes comments in a test utility file. It clarifies what a test is checking and why it does not perform a certain assertion. No code behavior was changed, so there is no security impact.
No action needed. This is a non-functional documentation-only change in test code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies three comment blocks in lightning/src/util/test_utils.rs within TestChainMonitor. It rewords an explanation about round-tripping ChannelMonitor serialization and notes why one test path does not assert exact equality after round-trip. No executable code, logic, or serialization format changed.
Changed components
lightning/src/util/test_utils.rsInspect captured patch +6 / −4
diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs
index 8709cbc..b61916a 100644
--- a/lightning/src/util/test_utils.rs
+++ b/lightning/src/util/test_utils.rs
@@ -524,8 +524,8 @@ impl<'a> TestChainMonitor<'a> {
blocker.recv().unwrap();
}
- // At every point where we get a monitor update, we should be able to send a useful monitor
- // to a watchtower and disk...
+ // Test that a monitor survives a round-trip, and use the round-tripped monitor in the
+ // underlying `ChainMonitor`.
let mut w = TestVecWriter(Vec::new());
monitor.write(&mut w).unwrap();
let new_monitor = <(BlockHash, ChannelMonitor<TestChannelSigner>)>::read(
@@ -536,7 +536,8 @@ impl<'a> TestChainMonitor<'a> {
.1;
// Note that a ChannelMonitor might not round-trip exactly here as we have tests that were
// serialized prior to LDK 0.1 and re-serializing them will flip the "written after LDK
- // 0.1" flag.
+ // 0.1" flag. Thus, unlike the code in `watch_channel` below, we do not assert that the
+ // monitor is the same after a serialization round-trip.
self.latest_monitor_update_id
.lock()
.unwrap()
@@ -555,7 +556,8 @@ impl<'a> chain::Watch<TestChannelSigner> for TestChainMonitor<'a> {
}
// At every point where we get a monitor update, we should be able to send a useful monitor
- // to a watchtower and disk...
+ // to a watchtower and disk. At a minimum, this means we should be able to round-trip the
+ // monitor to a serialized copy and get he same one back.
let mut w = TestVecWriter(Vec::new());
monitor.write(&mut w).unwrap();
let new_monitor = <(BlockHash, ChannelMonitor<TestChannelSigner>)>::read(
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.