@@ -1193,3 +1193,59 @@ pub fn do_cannot_afford_on_holding_cell_release(
11931193 nodes[ 0 ] . logger . assert_log ( "lightning::ln::channel" , err, 1 ) ;
11941194 }
11951195}
1196+
1197+ #[ test]
1198+ pub fn test_zero_fee_commiments_no_update_fee ( ) {
1199+ // Tests that option_zero_fee_commitment channels do not sent update_fee messages, and that
1200+ // they'll disconnect and warn if they receive them.
1201+ let mut cfg = test_default_channel_config ( ) ;
1202+ cfg. channel_handshake_config . negotiate_anchor_zero_fee_commitments = true ;
1203+ cfg. manually_accept_inbound_channels = true ;
1204+
1205+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1206+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1207+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( cfg. clone ( ) ) , Some ( cfg) ] ) ;
1208+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1209+
1210+ let channel = create_chan_between_nodes ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
1211+
1212+ let assert_zero_fee = || {
1213+ for node in nodes. iter ( ) {
1214+ let channels = node. node . list_channels ( ) ;
1215+ assert_eq ! ( channels. len( ) , 1 ) ;
1216+ assert ! ( channels[ 0 ]
1217+ . channel_type
1218+ . as_ref( )
1219+ . unwrap( )
1220+ . supports_anchor_zero_fee_commitments( ) ) ;
1221+ assert_eq ! ( channels[ 0 ] . feerate_sat_per_1000_weight. unwrap( ) , 0 ) ;
1222+ }
1223+ } ;
1224+ assert_zero_fee ( ) ;
1225+
1226+ // Sender should not queue an update_fee message.
1227+ nodes[ 0 ] . node . timer_tick_occurred ( ) ;
1228+ let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
1229+ assert_eq ! ( events_0. len( ) , 0 ) ;
1230+
1231+ // Receiver should ignore and warn if sent update_fee.
1232+ let channel_id = channel. 3 ;
1233+ let update_fee_msg = msgs:: UpdateFee { channel_id, feerate_per_kw : 5000 } ;
1234+ nodes[ 1 ] . node . handle_update_fee ( nodes[ 0 ] . node . get_our_node_id ( ) , & update_fee_msg) ;
1235+
1236+ let events_1 = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1237+ assert_eq ! ( events_1. len( ) , 1 ) ;
1238+ match events_1[ 0 ] {
1239+ MessageSendEvent :: HandleError { ref action, .. } => match action {
1240+ ErrorAction :: DisconnectPeerWithWarning { ref msg, .. } => {
1241+ assert_eq ! ( msg. channel_id, channel_id) ;
1242+ assert ! ( msg
1243+ . data
1244+ . contains( "Update fee message received for zero fee commitment channel" ) ) ;
1245+ } ,
1246+ _ => panic ! ( "Expected DisconnectPeerWithWarning, got {:?}" , action) ,
1247+ } ,
1248+ _ => panic ! ( "Expected HandleError event, got {:?}" , events_1[ 0 ] ) ,
1249+ }
1250+ assert_zero_fee ( ) ;
1251+ }
0 commit comments