]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Restrict `ChannelManager` persist in fuzzing to when we're told to 2023-08-one-less-write
authorMatt Corallo <git@bluematt.me>
Mon, 28 Aug 2023 01:25:36 +0000 (01:25 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 12 Sep 2023 21:28:30 +0000 (21:28 +0000)
In the `chanmon_consistency` fuzz, we currently "persist" the
`ChannelManager` on each loop iteration. With the new logic in the
past few commits to reduce the frequency of `ChannelManager`
persistences, this behavior now leaves a gap in our test coverage -
missing persistence notifications.

In order to cath (common-case) persistence misses, we update the
`chanmon_consistency` fuzzer to no longer persist the
`ChannelManager` unless the waker was woken and signaled to
persist, possibly reloading with a previous `ChannelManager` if we
were not signaled.

fuzz/src/chanmon_consistency.rs

index 05df091104ed817d20da5377c4a07af44059fbd9..8afc2e15187edb5397474a64b2cf33e34359a667 100644 (file)
@@ -1296,12 +1296,18 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
                        _ => test_return!(),
                }
 
-               node_a_ser.0.clear();
-               nodes[0].write(&mut node_a_ser).unwrap();
-               node_b_ser.0.clear();
-               nodes[1].write(&mut node_b_ser).unwrap();
-               node_c_ser.0.clear();
-               nodes[2].write(&mut node_c_ser).unwrap();
+               if nodes[0].get_and_clear_needs_persistence() == true {
+                       node_a_ser.0.clear();
+                       nodes[0].write(&mut node_a_ser).unwrap();
+               }
+               if nodes[1].get_and_clear_needs_persistence() == true {
+                       node_b_ser.0.clear();
+                       nodes[1].write(&mut node_b_ser).unwrap();
+               }
+               if nodes[2].get_and_clear_needs_persistence() == true {
+                       node_c_ser.0.clear();
+                       nodes[2].write(&mut node_c_ser).unwrap();
+               }
        }
 }