@@ -5530,6 +5530,26 @@ mod tests {
5530
5530
assert ! ( path_plausibility. iter( ) . all( |x| * x) ) ;
5531
5531
}
5532
5532
5533
+ #[ test]
5534
+ fn builds_correct_path_from_hops ( ) {
5535
+ let ( secp_ctx, network, _, _, logger) = build_line_graph ( ) ;
5536
+ let ( _, our_id, _, nodes) = get_nodes ( & secp_ctx) ;
5537
+ let network_graph = network. read_only ( ) ;
5538
+
5539
+ let keys_manager = test_utils:: TestKeysInterface :: new ( & [ 0u8 ; 32 ] , Network :: Testnet ) ;
5540
+ let random_seed_bytes = keys_manager. get_secure_random_bytes ( ) ;
5541
+
5542
+ let payment_params = PaymentParameters :: from_node_id ( nodes[ 18 ] ) ;
5543
+ let hops = & nodes[ ..19 ] ;
5544
+ let route = build_route_from_hops_internal ( & our_id, hops, & payment_params,
5545
+ & network_graph, 100 , 0 , Arc :: clone ( & logger) , & random_seed_bytes) . unwrap ( ) ;
5546
+ let route_hop_pubkeys = route. paths [ 0 ] . iter ( ) . map ( |hop| hop. pubkey ) . collect :: < Vec < _ > > ( ) ;
5547
+ assert_eq ! ( hops. len( ) , route. paths[ 0 ] . len( ) ) ;
5548
+ for ( idx, hop_pubkey) in hops. iter ( ) . enumerate ( ) {
5549
+ assert ! ( * hop_pubkey == route_hop_pubkeys[ idx] ) ;
5550
+ }
5551
+ }
5552
+
5533
5553
#[ cfg( not( feature = "no-std" ) ) ]
5534
5554
pub ( super ) fn random_init_seed ( ) -> u64 {
5535
5555
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
0 commit comments