Skip to content

Commit 317c735

Browse files
committed
Restrict ChannelManager persist in fuzzing to when we're told to
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.
1 parent 497c017 commit 317c735

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ use std::cmp::{self, Ordering};
6666
use hashbrown::{HashSet, hash_map, HashMap};
6767
use std::sync::{Arc,Mutex};
6868
use std::sync::atomic;
69+
use std::time::Duration;
6970
use std::io::Cursor;
7071
use bitcoin::bech32::u5;
7172

@@ -1248,12 +1249,19 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
12481249
_ => test_return!(),
12491250
}
12501251

1251-
node_a_ser.0.clear();
1252-
nodes[0].write(&mut node_a_ser).unwrap();
1253-
node_b_ser.0.clear();
1254-
nodes[1].write(&mut node_b_ser).unwrap();
1255-
node_c_ser.0.clear();
1256-
nodes[2].write(&mut node_c_ser).unwrap();
1252+
const NO_TIME: Duration = Duration::from_secs(0);
1253+
if nodes[0].get_event_or_persistence_needed_future().wait_timeout(NO_TIME) == Ok(true) {
1254+
node_a_ser.0.clear();
1255+
nodes[0].write(&mut node_a_ser).unwrap();
1256+
}
1257+
if nodes[1].get_event_or_persistence_needed_future().wait_timeout(NO_TIME) == Ok(true) {
1258+
node_b_ser.0.clear();
1259+
nodes[1].write(&mut node_b_ser).unwrap();
1260+
}
1261+
if nodes[2].get_event_or_persistence_needed_future().wait_timeout(NO_TIME) == Ok(true) {
1262+
node_c_ser.0.clear();
1263+
nodes[2].write(&mut node_c_ser).unwrap();
1264+
}
12571265
}
12581266
}
12591267

0 commit comments

Comments
 (0)