@@ -5492,6 +5492,26 @@ mod tests {
5492
5492
assert ! ( path_plausibility. iter( ) . all( |x| * x) ) ;
5493
5493
}
5494
5494
5495
+ #[ test]
5496
+ fn builds_correct_path_from_hops ( ) {
5497
+ let ( secp_ctx, network, _, _, logger) = build_line_graph ( ) ;
5498
+ let ( _, our_id, _, nodes) = get_nodes ( & secp_ctx) ;
5499
+ let network_graph = network. read_only ( ) ;
5500
+
5501
+ let keys_manager = test_utils:: TestKeysInterface :: new ( & [ 0u8 ; 32 ] , Network :: Testnet ) ;
5502
+ let random_seed_bytes = keys_manager. get_secure_random_bytes ( ) ;
5503
+
5504
+ let payment_params = PaymentParameters :: from_node_id ( nodes[ 18 ] ) ;
5505
+ let hops = & nodes[ ..19 ] ;
5506
+ let route = build_route_from_hops_internal ( & our_id, hops, & payment_params,
5507
+ & network_graph, 100 , 0 , Arc :: clone ( & logger) , & random_seed_bytes) . unwrap ( ) ;
5508
+ let route_hop_pubkeys = route. paths [ 0 ] . iter ( ) . map ( |hop| hop. pubkey ) . collect :: < Vec < _ > > ( ) ;
5509
+ assert_eq ! ( hops. len( ) , route. paths[ 0 ] . len( ) ) ;
5510
+ for ( idx, hop_pubkey) in hops. iter ( ) . enumerate ( ) {
5511
+ assert ! ( * hop_pubkey == route_hop_pubkeys[ idx] ) ;
5512
+ }
5513
+ }
5514
+
5495
5515
#[ cfg( not( feature = "no-std" ) ) ]
5496
5516
pub ( super ) fn random_init_seed ( ) -> u64 {
5497
5517
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
0 commit comments