]> git.bitcoin.ninja Git - rust-lightning/commitdiff
[fuzz] Handle monitor updates during get_and_clear_pending_msg_events
authorMatt Corallo <git@bluematt.me>
Wed, 21 Apr 2021 02:37:02 +0000 (02:37 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 21 May 2021 15:10:45 +0000 (15:10 +0000)
Because we may now generate a monitor update during
get_and_clear_pending_msg_events calls, we need to ensure we
re-serialize the relevant ChannelManager before attempting to
reload it, if such a monitor update occurred.

fuzz/src/chanmon_consistency.rs

index d2848112341d912815e1625b5e7421f00a195240..b564e556d39f29ba493109ac53f2ccea1ba4a456 100644 (file)
@@ -800,6 +800,10 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                                        chan_a_disconnected = true;
                                        drain_msg_events_on_disconnect!(0);
                                }
+                               if monitor_a.should_update_manager.load(atomic::Ordering::Relaxed) {
+                                       node_a_ser.0.clear();
+                                       nodes[0].write(&mut node_a_ser).unwrap();
+                               }
                                let (new_node_a, new_monitor_a) = reload_node!(node_a_ser, 0, monitor_a, keys_manager_a);
                                nodes[0] = new_node_a;
                                monitor_a = new_monitor_a;
@@ -827,6 +831,10 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                                        chan_b_disconnected = true;
                                        drain_msg_events_on_disconnect!(2);
                                }
+                               if monitor_c.should_update_manager.load(atomic::Ordering::Relaxed) {
+                                       node_c_ser.0.clear();
+                                       nodes[2].write(&mut node_c_ser).unwrap();
+                               }
                                let (new_node_c, new_monitor_c) = reload_node!(node_c_ser, 2, monitor_c, keys_manager_c);
                                nodes[2] = new_node_c;
                                monitor_c = new_monitor_c;