File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -5088,4 +5088,45 @@ mod tests {
5088
5088
. unwrap ( ) ;
5089
5089
assert_eq ! ( endpoint. url, "https://rpc.sophon.xyz" ) ;
5090
5090
}
5091
+
5092
+ #[ test]
5093
+ fn test_get_etherscan_config_with_unknown_chain ( ) {
5094
+ figment:: Jail :: expect_with ( |jail| {
5095
+ jail. create_file (
5096
+ "foundry.toml" ,
5097
+ r#"
5098
+ [etherscan]
5099
+ mainnet = { chain = 3658348, key = "api-key"}
5100
+ "# ,
5101
+ ) ?;
5102
+ let config = Config :: load ( ) . unwrap ( ) ;
5103
+ let unknown_chain = Chain :: from_id ( 3658348 ) ;
5104
+ let result = config. get_etherscan_config_with_chain ( Some ( unknown_chain) ) ;
5105
+ assert ! ( result. is_err( ) ) ;
5106
+ let error_msg = result. unwrap_err ( ) . to_string ( ) ;
5107
+ assert ! ( error_msg. contains( "No known Etherscan API URL for chain `3658348`" ) ) ;
5108
+ assert ! ( error_msg. contains( "Specify a `url`" ) ) ;
5109
+ assert ! ( error_msg. contains( "Verify the chain `3658348` is correct" ) ) ;
5110
+
5111
+ Ok ( ( ) )
5112
+ } ) ;
5113
+ }
5114
+
5115
+ #[ test]
5116
+ fn test_get_etherscan_config_with_existing_chain_and_url ( ) {
5117
+ figment:: Jail :: expect_with ( |jail| {
5118
+ jail. create_file (
5119
+ "foundry.toml" ,
5120
+ r#"
5121
+ [etherscan]
5122
+ mainnet = { chain = 1, key = "api-key" }
5123
+ "# ,
5124
+ ) ?;
5125
+ let config = Config :: load ( ) . unwrap ( ) ;
5126
+ let unknown_chain = Chain :: from_id ( 1 ) ;
5127
+ let result = config. get_etherscan_config_with_chain ( Some ( unknown_chain) ) ;
5128
+ assert ! ( result. is_ok( ) ) ;
5129
+ Ok ( ( ) )
5130
+ } ) ;
5131
+ }
5091
5132
}
You can’t perform that action at this time.
0 commit comments