Skip to content

Commit 94b420c

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 b36ca70 commit 94b420c

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

@@ -1296,12 +1297,19 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
12961297
_ => test_return!(),
12971298
}
12981299

1299-
node_a_ser.0.clear();
1300-
nodes[0].write(&mut node_a_ser).unwrap();
1301-
node_b_ser.0.clear();
1302-
nodes[1].write(&mut node_b_ser).unwrap();
1303-
node_c_ser.0.clear();
1304-
nodes[2].write(&mut node_c_ser).unwrap();
1300+
const NO_TIME: Duration = Duration::from_secs(0);
1301+
if nodes[0].get_event_or_persistence_needed_future().wait_timeout(NO_TIME) == Ok(true) {
1302+
node_a_ser.0.clear();
1303+
nodes[0].write(&mut node_a_ser).unwrap();
1304+
}
1305+
if nodes[1].get_event_or_persistence_needed_future().wait_timeout(NO_TIME) == Ok(true) {
1306+
node_b_ser.0.clear();
1307+
nodes[1].write(&mut node_b_ser).unwrap();
1308+
}
1309+
if nodes[2].get_event_or_persistence_needed_future().wait_timeout(NO_TIME) == Ok(true) {
1310+
node_c_ser.0.clear();
1311+
nodes[2].write(&mut node_c_ser).unwrap();
1312+
}
13051313
}
13061314
}
13071315

0 commit comments

Comments
 (0)