@@ -19,7 +19,7 @@ use ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs, HTLCForwa
19
19
use ln:: onion_utils;
20
20
use routing:: gossip:: { NetworkUpdate , RoutingFees , NodeId } ;
21
21
use routing:: router:: { get_route, PaymentParameters , Route , RouteHint , RouteHintHop } ;
22
- use ln:: features:: { InitFeatures , InvoiceFeatures , NodeFeatures } ;
22
+ use ln:: features:: InitFeatures ;
23
23
use ln:: msgs;
24
24
use ln:: msgs:: { ChannelMessageHandler , ChannelUpdate } ;
25
25
use ln:: wire:: Encode ;
@@ -791,10 +791,10 @@ fn test_onion_failure_stale_channel_update() {
791
791
}
792
792
793
793
#[ test]
794
- fn test_default_to_onion_payload_tlv_format ( ) {
795
- // Tests that we default to creating tlv format onion payloads when no `NodeAnnouncementInfo`
796
- // `features` for a node in the `network_graph` exists, or when the node isn't in the
797
- // `network_graph`, and no other known `features` for the node exists.
794
+ fn test_default_to_assume_support_of_variable_length_onions ( ) {
795
+ // Tests that we default to assuming support of variable length onions when no
796
+ // `NodeAnnouncementInfo` ` features` for a node in the `network_graph` exists, or when the node
797
+ // isn't in the `network_graph`, and no other known `features` for the node exists.
798
798
let mut priv_channels_conf = UserConfig :: default ( ) ;
799
799
priv_channels_conf. channel_handshake_config . announced_channel = false ;
800
800
let chanmon_cfgs = create_chanmon_cfgs ( 5 ) ;
@@ -858,100 +858,6 @@ fn test_default_to_onion_payload_tlv_format() {
858
858
// and no `InvoiceFeatures` for the `payment_params` exists, which would otherwise have been
859
859
// used.
860
860
assert ! ( unannounced_chan_hop. node_features. supports_variable_length_onion( ) ) ;
861
-
862
- let cur_height = nodes[ 0 ] . best_block_info ( ) . 1 + 1 ;
863
- let ( announced_route_payloads, _htlc_msat, _htlc_cltv) = onion_utils:: build_onion_payloads ( & announced_route. paths [ 0 ] , 40000 , & None , cur_height, & None ) . unwrap ( ) ;
864
- let ( unannounced_route_paylods, _htlc_msat, _htlc_cltv) = onion_utils:: build_onion_payloads ( & unannounced_route. paths [ 0 ] , 40000 , & None , cur_height, & None ) . unwrap ( ) ;
865
-
866
- for onion_payloads in vec ! [ announced_route_payloads, unannounced_route_paylods] {
867
- for onion_payload in onion_payloads. iter ( ) {
868
- match onion_payload. format {
869
- msgs:: OnionHopDataFormat :: Legacy { ..} => {
870
- panic ! ( "Generated a `msgs::OnionHopDataFormat::Legacy` payload, even though that shouldn't have happend." ) ;
871
- }
872
- _ => { }
873
- }
874
- }
875
- }
876
- }
877
-
878
- #[ test]
879
- fn test_do_not_default_to_onion_payload_tlv_format_when_unsupported ( ) {
880
- // Tests that we do not default to creating tlv onions if either of these types features
881
- // exists, which specifies no support for variable length onions for a specific hop, when
882
- // creating a route:
883
- // 1. `InitFeatures` to the counterparty node exchanged with the init message to the node.
884
- // 2. `NodeFeatures` in the `NodeAnnouncementInfo` of a node in sender node's `network_graph`.
885
- // 3. `InvoiceFeatures` specified by the receiving node, when no `NodeAnnouncementInfo`
886
- // `features` exists for the receiver in the sender's `network_graph`.
887
- let chanmon_cfgs = create_chanmon_cfgs ( 4 ) ;
888
- let mut node_cfgs = create_node_cfgs ( 4 , & chanmon_cfgs) ;
889
-
890
- // Set `node[1]` config to `InitFeatures::empty()` + `static_remote_key` which implies
891
- // `!supports_variable_length_onion()` but still supports the required static-remote-key
892
- // feature.
893
- let mut node_1_cfg = & mut node_cfgs[ 1 ] ;
894
- node_1_cfg. features = InitFeatures :: empty ( ) ;
895
- node_1_cfg. features . set_static_remote_key_required ( ) ;
896
-
897
- let node_chanmgrs = create_node_chanmgrs ( 4 , & node_cfgs, & [ None , None , None , None ] ) ;
898
- let mut nodes = create_network ( 4 , & node_cfgs, & node_chanmgrs) ;
899
-
900
- create_announced_chan_between_nodes ( & nodes, 0 , 1 , channelmanager:: provided_init_features ( ) , channelmanager:: provided_init_features ( ) ) ;
901
- create_announced_chan_between_nodes ( & nodes, 1 , 2 , channelmanager:: provided_init_features ( ) , channelmanager:: provided_init_features ( ) ) ;
902
- create_announced_chan_between_nodes ( & nodes, 2 , 3 , channelmanager:: provided_init_features ( ) , channelmanager:: provided_init_features ( ) ) ;
903
-
904
- let payment_params = PaymentParameters :: from_node_id ( nodes[ 3 ] . node . get_our_node_id ( ) )
905
- . with_features ( InvoiceFeatures :: empty ( ) ) ;
906
- let origin_node = & nodes[ 0 ] ;
907
- let network_graph = origin_node. network_graph ;
908
- network_graph. clear_nodes_announcement_info ( ) ;
909
-
910
- // Set `NodeAnnouncementInfo` `features` which do not support variable length onions for
911
- // `nodes[2]` in `nodes[0]`'s `network_graph`.
912
- let nodes_2_unsigned_node_announcement = msgs:: UnsignedNodeAnnouncement {
913
- features : NodeFeatures :: empty ( ) ,
914
- timestamp : 0 ,
915
- node_id : nodes[ 2 ] . node . get_our_node_id ( ) ,
916
- rgb : [ 32 ; 3 ] ,
917
- alias : [ 16 ; 32 ] ,
918
- addresses : Vec :: new ( ) ,
919
- excess_address_data : Vec :: new ( ) ,
920
- excess_data : Vec :: new ( ) ,
921
- } ;
922
- let _res = network_graph. update_node_from_unsigned_announcement ( & nodes_2_unsigned_node_announcement) ;
923
-
924
- let ( route, _, _, _) = get_route_and_payment_hash ! (
925
- origin_node, nodes[ 3 ] , payment_params, 10_000 , TEST_FINAL_CLTV ) ;
926
-
927
- let hops = & route. paths [ 0 ] ;
928
-
929
- // Assert that the hop between `nodes[0]` and `nodes[1]` doesn't support variable length
930
- // onions, as as the `InitFeatures` exchanged (`InitFeatures::empty()`) in the init message
931
- // between the nodes when setting up the channel is used when creating the `route` and that we
932
- // therefore do not default to supporting variable length onions. Despite `nodes[0]` having no
933
- // `NodeAnnouncementInfo` `features` for `node[1]`.
934
- assert ! ( !hops[ 0 ] . node_features. supports_variable_length_onion( ) ) ;
935
- // Assert that the hop between `nodes[1]` and `nodes[2]` uses the `features` from
936
- // `nodes_2_unsigned_node_announcement` that doesn't support variable length onions.
937
- assert ! ( !hops[ 1 ] . node_features. supports_variable_length_onion( ) ) ;
938
- // Assert that the hop between `nodes[2]` and `nodes[3]` uses the `InvoiceFeatures` set to the
939
- // `payment_params`, that doesn't support variable length onions. We therefore do not end up
940
- // defaulting to supporting variable length onions, despite `nodes[0]` having no
941
- // `NodeAnnouncementInfo` `features` for `node[3]`.
942
- assert ! ( !hops[ 2 ] . node_features. supports_variable_length_onion( ) ) ;
943
-
944
- let cur_height = nodes[ 0 ] . best_block_info ( ) . 1 + 1 ;
945
- let ( onion_payloads, _htlc_msat, _htlc_cltv) = onion_utils:: build_onion_payloads ( & route. paths [ 0 ] , 40000 , & None , cur_height, & None ) . unwrap ( ) ;
946
-
947
- for onion_payload in onion_payloads. iter ( ) {
948
- match onion_payload. format {
949
- msgs:: OnionHopDataFormat :: Legacy { ..} => { }
950
- _ => {
951
- panic ! ( "Should have only have generated `msgs::OnionHopDataFormat::Legacy` payloads" ) ;
952
- }
953
- }
954
- }
955
861
}
956
862
957
863
macro_rules! get_phantom_route {
0 commit comments