-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve debug of
RpcApi
(#307)
Improve debug representation of `RpcApi` to display the host name if available.
- Loading branch information
1 parent
f353ed3
commit 7a4695e
Showing
6 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::RpcApi; | ||
use ic_cdk::api::management_canister::http_request::HttpHeader; | ||
|
||
#[test] | ||
fn should_contain_host_without_sensitive_information() { | ||
for provider in [ | ||
RpcApi { | ||
url: "https://eth-mainnet.g.alchemy.com/v2".to_string(), | ||
headers: None, | ||
}, | ||
RpcApi { | ||
url: "https://eth-mainnet.g.alchemy.com/v2/key".to_string(), | ||
headers: None, | ||
}, | ||
RpcApi { | ||
url: "https://eth-mainnet.g.alchemy.com/v2".to_string(), | ||
headers: Some(vec![HttpHeader { | ||
name: "authorization".to_string(), | ||
value: "Bearer key".to_string(), | ||
}]), | ||
}, | ||
] { | ||
let debug = format!("{:?}", provider); | ||
assert_eq!( | ||
debug, | ||
"RpcApi { host: eth-mainnet.g.alchemy.com, url/headers: *** }" | ||
); | ||
} | ||
} |