@@ -860,6 +860,45 @@ fn test_default_to_assume_support_of_variable_length_onions() {
860
860
assert ! ( unannounced_chan_hop. node_features. supports_variable_length_onion( ) ) ;
861
861
}
862
862
863
+ #[ test]
864
+ fn test_always_create_onion_payload_tlv_format ( ) {
865
+ let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
866
+ let mut node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
867
+
868
+ // Set `node[1]` config to `InitFeatures::empty()` which return `false` for
869
+ // `supports_variable_length_onion()`
870
+ let mut node_1_cfg = & mut node_cfgs[ 1 ] ;
871
+ node_1_cfg. features = InitFeatures :: empty ( ) ;
872
+
873
+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
874
+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
875
+
876
+ create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: empty ( ) , InitFeatures :: empty ( ) ) ;
877
+ create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: empty ( ) , InitFeatures :: empty ( ) ) ;
878
+
879
+ let ( route, _payment_hash, _payment_preimage, _payment_secret) = get_route_and_payment_hash ! ( nodes[ 0 ] , nodes[ 2 ] , 40000 ) ;
880
+
881
+ let hops = & route. paths [ 0 ] ;
882
+ // Asserts that the first hop to `node[1]` returns `false` for
883
+ // `node_features.supports_variable_length_onion()`
884
+ assert ! ( !hops[ 0 ] . node_features. supports_variable_length_onion( ) ) ;
885
+ // Asserts that the second hop to `node[2]` returns `true` for
886
+ // `node_features.supports_variable_length_onion()`
887
+ assert ! ( hops[ 1 ] . node_features. supports_variable_length_onion( ) ) ;
888
+
889
+ let cur_height = nodes[ 0 ] . best_block_info ( ) . 1 + 1 ;
890
+ let ( onion_payloads, _htlc_msat, _htlc_cltv) = onion_utils:: build_onion_payloads ( & route. paths [ 0 ] , 40000 , & None , cur_height, & None ) . unwrap ( ) ;
891
+
892
+ for onion_payload in onion_payloads. iter ( ) {
893
+ match onion_payload. format {
894
+ msgs:: OnionHopDataFormat :: Legacy { ..} => {
895
+ panic ! ( "`onion_utils::build_onion_payloads` generated a `msgs::OnionHopDataFormat::Legacy` payload" ) ;
896
+ }
897
+ _ => { }
898
+ }
899
+ }
900
+ }
901
+
863
902
macro_rules! get_phantom_route {
864
903
( $nodes: expr, $amt: expr, $channel: expr) => { {
865
904
let secp_ctx = Secp256k1 :: new( ) ;
0 commit comments