From b23dd83c0e34120ab32fdd1dd224f30499d8436a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 24 Jul 2024 11:19:57 +0200 Subject: [PATCH] test: add invalid api key response test --- crates/block-explorers/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/block-explorers/src/lib.rs b/crates/block-explorers/src/lib.rs index 5e78ef5..0fc7038 100644 --- a/crates/block-explorers/src/lib.rs +++ b/crates/block-explorers/src/lib.rs @@ -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
= serde_json::from_value(err).unwrap(); + assert!(matches!(resp, ResponseData::Error { .. })); + } }