@@ -1167,17 +1167,10 @@ macro_rules! get_payment_preimage_hash {
1167
1167
}
1168
1168
}
1169
1169
1170
- #[ cfg( test) ]
1171
1170
#[ macro_export]
1172
- macro_rules! get_route_and_payment_hash {
1173
- ( $send_node: expr, $recv_node: expr, $recv_value: expr) => { {
1174
- let payment_params = $crate:: routing:: router:: PaymentParameters :: from_node_id( $recv_node. node. get_our_node_id( ) )
1175
- . with_features( $crate:: ln:: features:: InvoiceFeatures :: known( ) ) ;
1176
- $crate:: get_route_and_payment_hash!( $send_node, $recv_node, payment_params, $recv_value, TEST_FINAL_CLTV )
1177
- } } ;
1178
- ( $send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $cltv: expr) => { {
1171
+ macro_rules! get_route {
1172
+ ( $send_node: expr, $payment_params: expr, $recv_value: expr, $cltv: expr) => { {
1179
1173
use $crate:: chain:: keysinterface:: KeysInterface ;
1180
- let ( payment_preimage, payment_hash, payment_secret) = $crate:: get_payment_preimage_hash!( $recv_node, Some ( $recv_value) ) ;
1181
1174
let scorer = $crate:: util:: test_utils:: TestScorer :: with_penalty( 0 ) ;
1182
1175
let keys_manager = $crate:: util:: test_utils:: TestKeysInterface :: new( & [ 0u8 ; 32 ] , bitcoin:: network:: constants:: Network :: Testnet ) ;
1183
1176
let random_seed_bytes = keys_manager. get_secure_random_bytes( ) ;
@@ -1186,6 +1179,21 @@ macro_rules! get_route_and_payment_hash {
1186
1179
Some ( & $send_node. node. list_usable_channels( ) . iter( ) . collect:: <Vec <_>>( ) ) ,
1187
1180
$recv_value, $cltv, $send_node. logger, & scorer, & random_seed_bytes
1188
1181
) . unwrap( ) ;
1182
+ route
1183
+ } }
1184
+ }
1185
+
1186
+ #[ cfg( test) ]
1187
+ #[ macro_export]
1188
+ macro_rules! get_route_and_payment_hash {
1189
+ ( $send_node: expr, $recv_node: expr, $recv_value: expr) => { {
1190
+ let payment_params = $crate:: routing:: router:: PaymentParameters :: from_node_id( $recv_node. node. get_our_node_id( ) )
1191
+ . with_features( $crate:: ln:: features:: InvoiceFeatures :: known( ) ) ;
1192
+ $crate:: get_route_and_payment_hash!( $send_node, $recv_node, payment_params, $recv_value, TEST_FINAL_CLTV )
1193
+ } } ;
1194
+ ( $send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $cltv: expr) => { {
1195
+ let ( payment_preimage, payment_hash, payment_secret) = $crate:: get_payment_preimage_hash!( $recv_node, Some ( $recv_value) ) ;
1196
+ let route = $crate:: get_route!( $send_node, $payment_params, $recv_value, $cltv) ;
1189
1197
( route, payment_hash, payment_preimage, payment_secret)
1190
1198
} }
1191
1199
}
@@ -1650,15 +1658,7 @@ pub const TEST_FINAL_CLTV: u32 = 70;
1650
1658
pub fn route_payment < ' a , ' b , ' c > ( origin_node : & Node < ' a , ' b , ' c > , expected_route : & [ & Node < ' a , ' b , ' c > ] , recv_value : u64 ) -> ( PaymentPreimage , PaymentHash , PaymentSecret ) {
1651
1659
let payment_params = PaymentParameters :: from_node_id ( expected_route. last ( ) . unwrap ( ) . node . get_our_node_id ( ) )
1652
1660
. with_features ( InvoiceFeatures :: known ( ) ) ;
1653
- let network_graph = origin_node. network_graph . read_only ( ) ;
1654
- let scorer = test_utils:: TestScorer :: with_penalty ( 0 ) ;
1655
- let seed = [ 0u8 ; 32 ] ;
1656
- let keys_manager = test_utils:: TestKeysInterface :: new ( & seed, Network :: Testnet ) ;
1657
- let random_seed_bytes = keys_manager. get_secure_random_bytes ( ) ;
1658
- let route = get_route (
1659
- & origin_node. node . get_our_node_id ( ) , & payment_params, & network_graph,
1660
- Some ( & origin_node. node . list_usable_channels ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ) ,
1661
- recv_value, TEST_FINAL_CLTV , origin_node. logger , & scorer, & random_seed_bytes) . unwrap ( ) ;
1661
+ let route = get_route ! ( origin_node, payment_params, recv_value, TEST_FINAL_CLTV ) ;
1662
1662
assert_eq ! ( route. paths. len( ) , 1 ) ;
1663
1663
assert_eq ! ( route. paths[ 0 ] . len( ) , expected_route. len( ) ) ;
1664
1664
for ( node, hop) in expected_route. iter ( ) . zip ( route. paths [ 0 ] . iter ( ) ) {
0 commit comments