@@ -5495,7 +5495,6 @@ fn bolt2_open_channel_sending_node_checks_part2() {
5495
5495
5496
5496
#[ test]
5497
5497
fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat ( ) {
5498
- //BOLT2 Requirement: MUST offer amount_msat greater than 0.
5499
5498
//BOLT2 Requirement: MUST NOT offer amount_msat below the receiving node's htlc_minimum_msat (same validation check catches both of these)
5500
5499
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
5501
5500
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
@@ -5505,7 +5504,7 @@ fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat() {
5505
5504
let mut route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & [ ] , 100000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
5506
5505
let ( _, our_payment_hash) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
5507
5506
5508
- route. hops [ 0 ] . fee_msat = 0 ;
5507
+ route. hops [ 0 ] . fee_msat = 100 ;
5509
5508
5510
5509
let err = nodes[ 0 ] . node . send_payment ( route, our_payment_hash) ;
5511
5510
@@ -5518,6 +5517,30 @@ fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat() {
5518
5517
nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Cannot send less than their minimum HTLC value" . to_string ( ) , 1 ) ;
5519
5518
}
5520
5519
5520
+ #[ test]
5521
+ fn test_update_add_htlc_bolt2_sender_zero_value_msat ( ) {
5522
+ //BOLT2 Requirement: MUST offer amount_msat greater than 0.
5523
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
5524
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
5525
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
5526
+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
5527
+ let _chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 95000000 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
5528
+ let mut route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & [ ] , 100000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
5529
+ let ( _, our_payment_hash) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
5530
+
5531
+ route. hops [ 0 ] . fee_msat = 0 ;
5532
+
5533
+ let err = nodes[ 0 ] . node . send_payment ( route, our_payment_hash) ;
5534
+
5535
+ if let Err ( APIError :: ChannelUnavailable { err} ) = err {
5536
+ assert_eq ! ( err, "Cannot send 0-msat HTLC" ) ;
5537
+ } else {
5538
+ assert ! ( false ) ;
5539
+ }
5540
+ assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
5541
+ nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Cannot send 0-msat HTLC" . to_string ( ) , 1 ) ;
5542
+ }
5543
+
5521
5544
#[ test]
5522
5545
fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high ( ) {
5523
5546
//BOLT 2 Requirement: MUST set cltv_expiry less than 500000000.
0 commit comments