File tree 1 file changed +29
-1
lines changed
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -1453,7 +1453,14 @@ impl Config {
1453
1453
///
1454
1454
/// See also [Self::get_etherscan_config_with_chain]
1455
1455
pub fn get_etherscan_api_key ( & self , chain : Option < Chain > ) -> Option < String > {
1456
- self . get_etherscan_config_with_chain ( chain) . ok ( ) . flatten ( ) . map ( |c| c. key )
1456
+ self . get_etherscan_config_with_chain ( chain)
1457
+ . map_err ( |e| {
1458
+ // `sh_warn!` is a circular dependency, preventing us from using it here.
1459
+ eprintln ! ( "Error getting etherscan config: {}" , e) ;
1460
+ } )
1461
+ . ok ( )
1462
+ . flatten ( )
1463
+ . map ( |c| c. key )
1457
1464
}
1458
1465
1459
1466
/// Returns the remapping for the project's _src_ directory
@@ -3137,6 +3144,27 @@ mod tests {
3137
3144
} ) ;
3138
3145
}
3139
3146
3147
+ // any invalid entry invalidates whole [etherscan] sections
3148
+ #[ test]
3149
+ fn test_resolve_etherscan_with_invalid_name ( ) {
3150
+ figment:: Jail :: expect_with ( |jail| {
3151
+ jail. create_file (
3152
+ "foundry.toml" ,
3153
+ r#"
3154
+ [etherscan]
3155
+ mainnet = { key = "FX42Z3BBJJEWXWGYV2X1CIPRSCN" }
3156
+ an_invalid_name = { key = "FX42Z3BBJJEWXWGYV2X1CIPRSCN" }
3157
+ "# ,
3158
+ ) ?;
3159
+
3160
+ let config = Config :: load ( ) . unwrap ( ) ;
3161
+ let etherscan_config = config. get_etherscan_config ( ) ;
3162
+ assert ! ( etherscan_config. is_none( ) ) ;
3163
+
3164
+ Ok ( ( ) )
3165
+ } ) ;
3166
+ }
3167
+
3140
3168
#[ test]
3141
3169
fn test_resolve_rpc_url ( ) {
3142
3170
figment:: Jail :: expect_with ( |jail| {
You can’t perform that action at this time.
0 commit comments