@@ -549,6 +549,48 @@ fn test_quiescence_timeout_while_waiting_for_counterparty_stfu() {
549549 assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . iter( ) . find_map( f) . is_some( ) ) ;
550550}
551551
552+ #[ test]
553+ fn test_quiescence_timeout_while_waiting_for_counterparty_something_fundamental ( ) {
554+ // Test that we'll disconnect if the counterparty does not send their "something fundamental"
555+ // within a reasonable time if we've reached quiescence.
556+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
557+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
558+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
559+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
560+ let chan_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) . 2 ;
561+
562+ let node_id_0 = nodes[ 0 ] . node . get_our_node_id ( ) ;
563+ let node_id_1 = nodes[ 1 ] . node . get_our_node_id ( ) ;
564+
565+ nodes[ 1 ] . node . maybe_propose_quiescence ( & node_id_0, & chan_id) . unwrap ( ) ;
566+ let stfu = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendStfu , node_id_0) ;
567+
568+ nodes[ 0 ] . node . handle_stfu ( node_id_1, & stfu) ;
569+ let _stfu = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendStfu , node_id_1) ;
570+
571+ for _ in 0 ..DISCONNECT_PEER_AWAITING_RESPONSE_TICKS {
572+ nodes[ 0 ] . node . timer_tick_occurred ( ) ;
573+ nodes[ 1 ] . node . timer_tick_occurred ( ) ;
574+ }
575+
576+ // Node B didn't receive node A's stfu within the timeout so it'll disconnect.
577+ let f = |event| {
578+ if let MessageSendEvent :: HandleError { action, .. } = event {
579+ if let msgs:: ErrorAction :: DisconnectPeerWithWarning { .. } = action {
580+ Some ( ( ) )
581+ } else {
582+ None
583+ }
584+ } else {
585+ None
586+ }
587+ } ;
588+ // At this point, node A is waiting on B to do something fundamental, and node B is waiting on
589+ // A's stfu that we never delivered. Thus both should disconnect each other.
590+ assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . into_iter( ) . find_map( & f) . is_some( ) ) ;
591+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . into_iter( ) . find_map( & f) . is_some( ) ) ;
592+ }
593+
552594fn do_test_quiescence_during_disconnection ( with_pending_claim : bool , propose_disconnected : bool ) {
553595 // Test that we'll start trying for quiescence immediately after reconnection if we're waiting
554596 // to do some quiescence-required action.
0 commit comments