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