@@ -1831,7 +1831,7 @@ fn build_route_from_hops_internal<L: Deref>(
1831
1831
#[ cfg( test) ]
1832
1832
mod tests {
1833
1833
use routing:: network_graph:: { NetworkGraph , NetGraphMsgHandler , NodeId } ;
1834
- use routing:: router:: { get_route, add_random_cltv_offset, default_node_features,
1834
+ use routing:: router:: { get_route, build_route_from_hops_internal , add_random_cltv_offset, default_node_features,
1835
1835
PaymentParameters , Route , RouteHint , RouteHintHop , RouteHop , RoutingFees ,
1836
1836
DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA , MAX_PATH_LENGTH_ESTIMATE } ;
1837
1837
use routing:: scoring:: { ChannelUsage , Score } ;
@@ -5529,6 +5529,26 @@ mod tests {
5529
5529
assert ! ( path_plausibility. iter( ) . all( |x| * x) ) ;
5530
5530
}
5531
5531
5532
+ #[ test]
5533
+ fn builds_correct_path_from_hops ( ) {
5534
+ let ( secp_ctx, network, _, _, logger) = build_graph ( ) ;
5535
+ let ( _, our_id, _, nodes) = get_nodes ( & secp_ctx) ;
5536
+ let network_graph = network. read_only ( ) ;
5537
+
5538
+ let keys_manager = test_utils:: TestKeysInterface :: new ( & [ 0u8 ; 32 ] , Network :: Testnet ) ;
5539
+ let random_seed_bytes = keys_manager. get_secure_random_bytes ( ) ;
5540
+
5541
+ let payment_params = PaymentParameters :: from_node_id ( nodes[ 3 ] ) ;
5542
+ let hops = [ nodes[ 1 ] , nodes[ 2 ] , nodes[ 4 ] , nodes[ 3 ] ] ;
5543
+ let route = build_route_from_hops_internal ( & our_id, & hops, & payment_params,
5544
+ & network_graph, 100 , 0 , Arc :: clone ( & logger) , & random_seed_bytes) . unwrap ( ) ;
5545
+ let route_hop_pubkeys = route. paths [ 0 ] . iter ( ) . map ( |hop| hop. pubkey ) . collect :: < Vec < _ > > ( ) ;
5546
+ assert_eq ! ( hops. len( ) , route. paths[ 0 ] . len( ) ) ;
5547
+ for ( idx, hop_pubkey) in hops. iter ( ) . enumerate ( ) {
5548
+ assert ! ( * hop_pubkey == route_hop_pubkeys[ idx] ) ;
5549
+ }
5550
+ }
5551
+
5532
5552
#[ cfg( not( feature = "no-std" ) ) ]
5533
5553
pub ( super ) fn random_init_seed ( ) -> u64 {
5534
5554
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
0 commit comments