@@ -5541,6 +5541,27 @@ fn test_update_add_htlc_bolt2_sender_zero_value_msat() {
5541
5541
nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Cannot send 0-msat HTLC" . to_string ( ) , 1 ) ;
5542
5542
}
5543
5543
5544
+ #[ test]
5545
+ fn test_update_add_htlc_bolt2_receiver_zero_value_msat ( ) {
5546
+ //BOLT2 Requirement: MUST offer amount_msat greater than 0.
5547
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
5548
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
5549
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
5550
+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
5551
+ let _chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 95000000 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
5552
+ let route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & [ ] , 100000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
5553
+ let ( _, our_payment_hash) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
5554
+
5555
+ nodes[ 0 ] . node . send_payment ( route, our_payment_hash) ;
5556
+ check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
5557
+ let mut updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
5558
+ updates. update_add_htlcs [ 0 ] . amount_msat = 0 ;
5559
+
5560
+ nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. update_add_htlcs [ 0 ] ) ;
5561
+ nodes[ 1 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Remote side tried to send a 0-msat HTLC" . to_string ( ) , 1 ) ;
5562
+ check_closed_broadcast ! ( nodes[ 1 ] , true ) . unwrap ( ) ;
5563
+ }
5564
+
5544
5565
#[ test]
5545
5566
fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high ( ) {
5546
5567
//BOLT 2 Requirement: MUST set cltv_expiry less than 500000000.
0 commit comments