@@ -5939,6 +5939,31 @@ fn bolt2_open_channel_sending_node_checks_part2() {
5939
5939
assert ! ( PublicKey :: from_slice( & node0_to_1_send_open_channel. delayed_payment_basepoint. serialize( ) ) . is_ok( ) ) ;
5940
5940
}
5941
5941
5942
+ #[ test]
5943
+ fn bolt2_open_channel_sane_dust_limit ( ) {
5944
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
5945
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
5946
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
5947
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
5948
+
5949
+ let channel_value_satoshis=1000000 ;
5950
+ let push_msat=10001 ;
5951
+ nodes[ 0 ] . node . create_channel ( nodes[ 1 ] . node . get_our_node_id ( ) , channel_value_satoshis, push_msat, 42 , None ) . unwrap ( ) ;
5952
+ let mut node0_to_1_send_open_channel = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendOpenChannel , nodes[ 1 ] . node. get_our_node_id( ) ) ;
5953
+ node0_to_1_send_open_channel. dust_limit_satoshis = 661 ;
5954
+ node0_to_1_send_open_channel. channel_reserve_satoshis = 100001 ;
5955
+
5956
+ nodes[ 1 ] . node . handle_open_channel ( & nodes[ 0 ] . node . get_our_node_id ( ) , InitFeatures :: known ( ) , & node0_to_1_send_open_channel) ;
5957
+ let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
5958
+ let err_msg = match events[ 0 ] {
5959
+ MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , node_id : _ } => {
5960
+ msg. clone ( )
5961
+ } ,
5962
+ _ => panic ! ( "Unexpected event" ) ,
5963
+ } ;
5964
+ assert_eq ! ( err_msg. data, "dust_limit_satoshis (661) is greater than the implementation limit (660)" ) ;
5965
+ }
5966
+
5942
5967
// Test that if we fail to send an HTLC that is being freed from the holding cell, and the HTLC
5943
5968
// originated from our node, its failure is surfaced to the user. We trigger this failure to
5944
5969
// free the HTLC by increasing our fee while the HTLC is in the holding cell such that the HTLC
0 commit comments