@@ -5486,7 +5486,6 @@ fn bolt2_open_channel_sending_node_checks_part2() {
54865486
54875487#[ test]
54885488fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat ( ) {
5489- //BOLT2 Requirement: MUST offer amount_msat greater than 0.
54905489 //BOLT2 Requirement: MUST NOT offer amount_msat below the receiving node's htlc_minimum_msat (same validation check catches both of these)
54915490 let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
54925491 let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
@@ -5496,7 +5495,7 @@ fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat() {
54965495 let mut route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & [ ] , 100000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
54975496 let ( _, our_payment_hash) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
54985497
5499- route. hops [ 0 ] . fee_msat = 0 ;
5498+ route. hops [ 0 ] . fee_msat = 100 ;
55005499
55015500 let err = nodes[ 0 ] . node . send_payment ( route, our_payment_hash) ;
55025501
@@ -5509,6 +5508,30 @@ fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat() {
55095508 nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Cannot send less than their minimum HTLC value" . to_string ( ) , 1 ) ;
55105509}
55115510
5511+ #[ test]
5512+ fn test_update_add_htlc_bolt2_sender_zero_value_msat ( ) {
5513+ //BOLT2 Requirement: MUST offer amount_msat greater than 0.
5514+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
5515+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
5516+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
5517+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
5518+ let _chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 95000000 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
5519+ let mut route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & [ ] , 100000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
5520+ let ( _, our_payment_hash) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
5521+
5522+ route. hops [ 0 ] . fee_msat = 0 ;
5523+
5524+ let err = nodes[ 0 ] . node . send_payment ( route, our_payment_hash) ;
5525+
5526+ if let Err ( APIError :: ChannelUnavailable { err} ) = err {
5527+ assert_eq ! ( err, "Cannot send 0-msat HTLC" ) ;
5528+ } else {
5529+ assert ! ( false ) ;
5530+ }
5531+ assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
5532+ nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Cannot send 0-msat HTLC" . to_string ( ) , 1 ) ;
5533+ }
5534+
55125535#[ test]
55135536fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high ( ) {
55145537 //BOLT 2 Requirement: MUST set cltv_expiry less than 500000000.
0 commit comments