@@ -3869,8 +3869,8 @@ mod tests {
3869
3869
fn generate_routes ( ) {
3870
3870
let mut d = match super :: test_utils:: get_route_file ( ) {
3871
3871
Ok ( f) => f,
3872
- Err ( _ ) => {
3873
- eprintln ! ( "Please fetch https://bitcoin.ninja/ldk-net_graph-45d86ead641d-2021-05-27.bin and place it at lightning/net_graph-2021-05-27.bin" ) ;
3872
+ Err ( e ) => {
3873
+ eprintln ! ( "{}" , e ) ;
3874
3874
return ;
3875
3875
} ,
3876
3876
} ;
@@ -3896,8 +3896,8 @@ mod tests {
3896
3896
fn generate_routes_mpp ( ) {
3897
3897
let mut d = match super :: test_utils:: get_route_file ( ) {
3898
3898
Ok ( f) => f,
3899
- Err ( _ ) => {
3900
- eprintln ! ( "Please fetch https://bitcoin.ninja/ldk-net_graph-45d86ead641d-2021-05-27.bin and place it at lightning/net_graph-2021-05-27.bin" ) ;
3899
+ Err ( e ) => {
3900
+ eprintln ! ( "{}" , e ) ;
3901
3901
return ;
3902
3902
} ,
3903
3903
} ;
@@ -3924,7 +3924,7 @@ mod tests {
3924
3924
pub ( crate ) mod test_utils {
3925
3925
use std:: fs:: File ;
3926
3926
/// Tries to open a network graph file, or panics with a URL to fetch it.
3927
- pub ( crate ) fn get_route_file ( ) -> Result < std:: fs:: File , std :: io :: Error > {
3927
+ pub ( crate ) fn get_route_file ( ) -> Result < std:: fs:: File , & ' static str > {
3928
3928
let res = File :: open ( "net_graph-2021-05-27.bin" ) // By default we're run in RL/lightning
3929
3929
. or_else ( |_| File :: open ( "lightning/net_graph-2021-05-27.bin" ) ) // We may be run manually in RL/
3930
3930
. or_else ( |_| { // Fall back to guessing based on the binary location
@@ -3938,9 +3938,10 @@ pub(crate) mod test_utils {
3938
3938
path. push ( "net_graph-2021-05-27.bin" ) ;
3939
3939
eprintln ! ( "{}" , path. to_str( ) . unwrap( ) ) ;
3940
3940
File :: open ( path)
3941
- } ) ;
3941
+ } )
3942
+ . map_err ( |_| "Please fetch https://bitcoin.ninja/ldk-net_graph-45d86ead641d-2021-05-27.bin and place it at lightning/net_graph-2021-05-27.bin" ) ;
3942
3943
#[ cfg( require_route_graph_test) ]
3943
- return Ok ( res. expect ( "Didn't have route graph and was configured to require it" ) ) ;
3944
+ return Ok ( res. unwrap ( ) )
3944
3945
#[ cfg( not( require_route_graph_test) ) ]
3945
3946
return res;
3946
3947
}
@@ -3961,8 +3962,7 @@ mod benches {
3961
3962
3962
3963
#[ bench]
3963
3964
fn generate_routes ( bench : & mut Bencher ) {
3964
- let mut d = test_utils:: get_route_file ( )
3965
- . expect ( "Please fetch https://bitcoin.ninja/ldk-net_graph-45d86ead641d-2021-05-27.bin and place it at lightning/net_graph-2021-05-27.bin" ) ;
3965
+ let mut d = test_utils:: get_route_file ( ) . unwrap ( ) ;
3966
3966
let graph = NetworkGraph :: read ( & mut d) . unwrap ( ) ;
3967
3967
3968
3968
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
@@ -3993,8 +3993,7 @@ mod benches {
3993
3993
3994
3994
#[ bench]
3995
3995
fn generate_mpp_routes ( bench : & mut Bencher ) {
3996
- let mut d = test_utils:: get_route_file ( )
3997
- . expect ( "Please fetch https://bitcoin.ninja/ldk-net_graph-45d86ead641d-2021-05-27.bin and place it at lightning/net_graph-2021-05-27.bin" ) ;
3996
+ let mut d = test_utils:: get_route_file ( ) . unwrap ( ) ;
3998
3997
let graph = NetworkGraph :: read ( & mut d) . unwrap ( ) ;
3999
3998
4000
3999
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
0 commit comments