Skip to content

Commit c2782ac

Browse files
authored
test: add invalid api key response test (#57)
ref #56
1 parent 2a81c19 commit c2782ac

File tree

1 file changed

+11
-0
lines changed
  • crates/block-explorers/src

1 file changed

+11
-0
lines changed

crates/block-explorers/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,15 @@ mod tests {
581581
let err = Client::new_from_env(Chain::dev()).unwrap_err();
582582
assert!(matches!(err, EtherscanError::LocalNetworksNotSupported));
583583
}
584+
585+
#[test]
586+
fn can_parse_etherscan_mainnet_invalid_api_key() {
587+
let err = serde_json::json!({
588+
"status":"0",
589+
"message":"NOTOK",
590+
"result":"Missing/Invalid API Key"
591+
});
592+
let resp: ResponseData<Address> = serde_json::from_value(err).unwrap();
593+
assert!(matches!(resp, ResponseData::Error { .. }));
594+
}
584595
}

0 commit comments

Comments
 (0)