+ 0xff => {
+ // Test that no channel is in a stuck state where neither party can send funds even
+ // after we resolve all pending events.
+ // First make sure there are no pending monitor updates, resetting the error state
+ // and calling channel_monitor_updated for each monitor.
+ *monitor_a.update_ret.lock().unwrap() = Ok(());
+ *monitor_b.update_ret.lock().unwrap() = Ok(());
+ *monitor_c.update_ret.lock().unwrap() = Ok(());
+
+ if let Some((id, _)) = monitor_a.latest_monitors.lock().unwrap().get(&chan_1_funding) {
+ nodes[0].channel_monitor_updated(&chan_1_funding, *id);
+ }
+ if let Some((id, _)) = monitor_b.latest_monitors.lock().unwrap().get(&chan_1_funding) {
+ nodes[1].channel_monitor_updated(&chan_1_funding, *id);
+ }
+ if let Some((id, _)) = monitor_b.latest_monitors.lock().unwrap().get(&chan_2_funding) {
+ nodes[1].channel_monitor_updated(&chan_2_funding, *id);
+ }
+ if let Some((id, _)) = monitor_c.latest_monitors.lock().unwrap().get(&chan_2_funding) {
+ nodes[2].channel_monitor_updated(&chan_2_funding, *id);
+ }
+
+ // Next, make sure peers are all connected to each other
+ if chan_a_disconnected {
+ nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: InitFeatures::empty() });
+ nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: InitFeatures::empty() });
+ chan_a_disconnected = false;
+ }
+ if chan_b_disconnected {
+ nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: InitFeatures::empty() });
+ nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: InitFeatures::empty() });
+ chan_b_disconnected = false;
+ }
+
+ for i in 0..std::usize::MAX {
+ if i == 100 { panic!("It may take may iterations to settle the state, but it should not take forever"); }
+ // Then, make sure any current forwards make their way to their destination
+ if process_msg_events!(0, false) { continue; }
+ if process_msg_events!(1, false) { continue; }
+ if process_msg_events!(2, false) { continue; }
+ // ...making sure any pending PendingHTLCsForwardable events are handled and
+ // payments claimed.
+ if process_events!(0, false) { continue; }
+ if process_events!(1, false) { continue; }
+ if process_events!(2, false) { continue; }
+ break;
+ }
+
+ // Finally, make sure that at least one end of each channel can make a substantial payment.
+ assert!(
+ send_payment(&nodes[0], &nodes[1], chan_a, 10_000_000, &mut payment_id) ||
+ send_payment(&nodes[1], &nodes[0], chan_a, 10_000_000, &mut payment_id));
+ assert!(
+ send_payment(&nodes[1], &nodes[2], chan_b, 10_000_000, &mut payment_id) ||
+ send_payment(&nodes[2], &nodes[1], chan_b, 10_000_000, &mut payment_id));
+ },