Skip to content

Commit

Permalink
test: add invalid api key response test (#57)
Browse files Browse the repository at this point in the history
ref #56
  • Loading branch information
mattsse authored Jul 24, 2024
1 parent 2a81c19 commit c2782ac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/block-explorers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,15 @@ mod tests {
let err = Client::new_from_env(Chain::dev()).unwrap_err();
assert!(matches!(err, EtherscanError::LocalNetworksNotSupported));
}

#[test]
fn can_parse_etherscan_mainnet_invalid_api_key() {
let err = serde_json::json!({
"status":"0",
"message":"NOTOK",
"result":"Missing/Invalid API Key"
});
let resp: ResponseData<Address> = serde_json::from_value(err).unwrap();
assert!(matches!(resp, ResponseData::Error { .. }));
}
}

0 comments on commit c2782ac

Please sign in to comment.