@@ -645,6 +645,30 @@ fn test_onion_failure() {
645645		} ,  || nodes[ 2 ] . node . fail_htlc_backwards ( & payment_hash) ,  false ,  None , 
646646		Some ( NetworkUpdate :: NodeFailure  {  node_id :  route. paths [ 0 ] . hops [ 1 ] . pubkey ,  is_permanent :  true  } ) , 
647647		Some ( channels[ 1 ] . 0 . contents . short_channel_id ) ) ; 
648+ 	run_onion_failure_test_with_fail_intercept ( "0-length channel update in UPDATE onion failure" ,  200 ,  & nodes, 
649+ 		& route,  & payment_hash,  & payment_secret,  |_msg| { } ,  |msg| { 
650+ 			let  session_priv = SecretKey :: from_slice ( & [ 3 ;  32 ] ) . unwrap ( ) ; 
651+ 			let  onion_keys = onion_utils:: construct_onion_keys ( & Secp256k1 :: new ( ) ,  & route. paths [ 0 ] ,  & session_priv) . unwrap ( ) ; 
652+ 			let  mut  decoded_err_packet = msgs:: DecodedOnionErrorPacket  { 
653+ 				failuremsg :  vec ! [ 
654+ 					0x10 ,  0x7 ,  // UPDATE|7 
655+ 					0x0 ,  0x0  // 0-len channel update 
656+ 				] , 
657+ 				pad :  vec ! [ 0 ;  255  - 4  /* 4-byte error message */ ] , 
658+ 				hmac :  [ 0 ;  32 ] , 
659+ 			} ; 
660+ 			let  um = onion_utils:: gen_um_from_shared_secret ( & onion_keys[ 1 ] . shared_secret . as_ref ( ) ) ; 
661+ 			let  mut  hmac = HmacEngine :: < Sha256 > :: new ( & um) ; 
662+ 			hmac. input ( & decoded_err_packet. encode ( ) [ 32 ..] ) ; 
663+ 			decoded_err_packet. hmac  = Hmac :: from_engine ( hmac) . into_inner ( ) ; 
664+ 			msg. reason  = onion_utils:: encrypt_failure_packet ( 
665+ 				& onion_keys[ 1 ] . shared_secret . as_ref ( ) ,  & decoded_err_packet. encode ( ) [ ..] ) 
666+ 		} ,  || nodes[ 2 ] . node . fail_htlc_backwards ( & payment_hash) ,  true ,  Some ( 0x1000 |7 ) , 
667+ 		Some ( NetworkUpdate :: ChannelFailure  { 
668+ 			short_channel_id :  channels[ 1 ] . 0 . contents . short_channel_id , 
669+ 			is_permanent :  false , 
670+ 		} ) , 
671+ 		Some ( channels[ 1 ] . 0 . contents . short_channel_id ) ) ; 
648672} 
649673
650674#[ test]  
0 commit comments